Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Jan 3, 2026

Add nix-community/cache-nix-action to cache the Nix store between CI runs. This speeds up subsequent builds by avoiding redundant downloads and builds of Nix dependencies.

Inspired by skanehira/version-lsp.


Summary by cubic

Add Nix store caching to the setup-nix action to speed up CI by reusing built dependencies between runs and avoiding redundant downloads/builds. Replace Cachix with nix-community/cache-nix-action and bump install-nix-action to v31.9.0; the cache key is scoped to the runner OS (e.g., nix-Linux, nix-macOS).

Written for commit 96bcc8e. Summary will update on new commits.

Add nix-community/cache-nix-action to cache the Nix store between CI
runs. This speeds up subsequent builds by avoiding redundant downloads
and builds of Nix dependencies.

The cache key is based on the runner OS (e.g. nix-Linux, nix-macOS).
Copilot AI review requested due to automatic review settings January 3, 2026 12:07
@ryoppippi ryoppippi requested a review from a team as a code owner January 3, 2026 12:07
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@268

commit: 96bcc8e

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Nix store caching to the setup-nix composite action using the nix-community/cache-nix-action to improve CI performance by avoiding redundant downloads and builds of Nix dependencies across workflow runs.

Key changes:

  • Adds cache-nix-action@v7 step between Nix installation and Cachix setup
  • Configures cache with a simple OS-based key

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- name: Cache Nix store
uses: nix-community/cache-nix-action@b426b118b6dc86d6952988d396aa7c6b09776d08 # v7
with:
primary-key: nix-${{ runner.os }}
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache key should include a hash of the flake.lock file to ensure the cache is invalidated when Nix dependencies change. Currently, using only runner.os means the cache will persist even when flake.lock is updated, potentially causing builds to use outdated dependencies.

Consider changing the primary-key to include the flake.lock hash, for example:
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}

Suggested change
primary-key: nix-${{ runner.os }}
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".github/actions/setup-nix/action.yaml">

<violation number="1" location=".github/actions/setup-nix/action.yaml:14">
P2: Cache key should include a hash of `flake.lock` to ensure cache invalidation when dependencies change. Without this, the cache may serve stale dependencies after lock file updates.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- name: Cache Nix store
uses: nix-community/cache-nix-action@b426b118b6dc86d6952988d396aa7c6b09776d08 # v7
with:
primary-key: nix-${{ runner.os }}
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Cache key should include a hash of flake.lock to ensure cache invalidation when dependencies change. Without this, the cache may serve stale dependencies after lock file updates.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/actions/setup-nix/action.yaml, line 14:

<comment>Cache key should include a hash of `flake.lock` to ensure cache invalidation when dependencies change. Without this, the cache may serve stale dependencies after lock file updates.</comment>

<file context>
@@ -8,6 +8,11 @@ runs:
+    - name: Cache Nix store
+      uses: nix-community/cache-nix-action@b426b118b6dc86d6952988d396aa7c6b09776d08 # v7
+      with:
+        primary-key: nix-${{ runner.os }}
+
     - name: Setup Cachix (numtide)
</file context>
Suggested change
primary-key: nix-${{ runner.os }}
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
Fix with Cubic

Remove cachix-action in favour of nix-community/cache-nix-action for
caching the Nix store. Also update install-nix-action to v31.9.0.

This simplifies the caching setup and aligns with stackone-ai-python.
@ryoppippi ryoppippi merged commit 6c38298 into main Jan 3, 2026
18 checks passed
@ryoppippi ryoppippi deleted the chore/add-nix-store-cache branch January 3, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants