-
Notifications
You must be signed in to change notification settings - Fork 3
ci(nix): add Nix store caching to setup-nix action #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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).
commit: |
There was a problem hiding this 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@v7step 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 }} |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
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') }}
| primary-key: nix-${{ runner.os }} | |
| primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} |
There was a problem hiding this 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 }} |
There was a problem hiding this comment.
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>
| primary-key: nix-${{ runner.os }} | |
| primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} |
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.
Add
nix-community/cache-nix-actionto 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.