Repository navigation
feat(nix-setup): add a composite action that installs Nix and caches the store - #24
Conversation
…the store Install Nix with the SHA that nix-check and nix-lint pin, then restore the Nix store cache keyed on the runner and on flake.nix and flake.lock. The store is garbage-collected to 5 GiB before saving. The cache is saved on push events only by default, so pull requests only restore. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
||
| # The store is garbage-collected to the limit just before saving, below GitHub's 10 GiB cache quota per repository. | ||
| - name: Cache the Nix store | ||
| uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2 |
There was a problem hiding this comment.
P3: Nothing in this repo's CI runs this action. gha-lint only lints it statically, and the PR says cache hit/miss can only be checked in downstream repos. That means problems like a wrong cache-nix-action input name, save failing to resolve from the default expression, or the post-step save not running inside the composite action would first show up after release, in every caller. A small job in ci.yml that runs uses: ./.github/actions/nix-setup followed by nix --version would test the action at the PR's own SHA, as the other shared workflows here are tested.
Review summaryNo blocking findings (0 × P0/P1).
P3 (1): Nothing in this repo's CI runs the action, so runtime mistakes would first appear in downstream repos. Adding a small smoke-test job to 🤖 Generated with Claude Code |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Add a job that uses the composite action at the pull request's own commit and gate merging on it through all-green, so that a wrong input or a broken post step shows up before release rather than in every caller. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@codex review |
|
Review summary: no findings. I checked the new composite action
Not covered by tests: the CI job only checks |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99613892ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Cache the Nix store | ||
| uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2 | ||
| with: | ||
| primary-key: ${{ inputs.key-prefix }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} |
There was a problem hiding this comment.
Include imported Nix files in the cache key
When flake.nix imports files such as nix/dev-shell.nix, changing those files can alter the store closure without changing either file hashed here. The pinned cache action documents that it saves a new cache only when the exact primary key is absent, so after an exact hit the newly built paths are never added and every subsequent run must fetch or rebuild them. Hash all relevant Nix sources (the upstream example uses **/*.nix) or provide an input that lets callers specify the key files.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in the next commit (fix(nix-setup): include every .nix file in the cache key, waiting for the user to push): the key now hashes **/*.nix and flake.lock, so a change to any imported Nix file produces a new key. The README says why.
A file that flake.nix imports can change the store closure without changing flake.nix or flake.lock. The cache action saves only when the exact primary key is absent, so after an exact hit the new paths were never added. Hash every .nix file and flake.lock instead. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@codex review |
| uses: ./.github/actions/nix-setup # zizmor: ignore[self-repository] | ||
|
|
||
| - name: Check that Nix works | ||
| run: nix --version |
There was a problem hiding this comment.
P3: This job only checks that Nix installed (nix --version). It doesn't check the parts this action adds on top of install-nix-action: the cache key/restore and the dev-shell use from the README example. On pull requests save is false, so this job never runs the save or gc-max-store-size path. A typo in a cache-nix-action input, or a key that never hits, would still pass all-green. Consider running nix develop --command true here, so the README's usage pattern actually runs (the repo has a flake.nix). Also consider checking the restore outcome (for example, through the cache step's outputs) on push runs.
There was a problem hiding this comment.
Partly refuted. (1) nix develop --command true cannot run here: flake.nix defines devShells only for aarch64-darwin (flake.nix:16), so it fails on the ubuntu-24.04 runner. Adding x86_64-linux changes the flake and is out of scope for this PR. (2) Asserting a cache hit would make the job flaky: the first run after any .nix or flake.lock change legitimately misses, and PRs cannot save. (3) A typo in a cache-nix-action input would not go unnoticed: the missing required primary-key fails the step, and the save and gc path runs on push to main, where the same job runs with save=true. The job stays as an install and restore smoke test; the cache hit rate is measured in the consuming repositories.
|
Review summary (read-only) No P0/P1 findings.
Notes, not findings:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1002b84ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Cache the Nix store | ||
| uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2 | ||
| with: | ||
| primary-key: ${{ inputs.key-prefix }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.nix', 'flake.lock') }} |
There was a problem hiding this comment.
Hash nested flake locks in the cache key
In repositories whose dev shell is defined by a nested flake, hashFiles('flake.lock') only hashes the workspace-root lock file, so changing (for example) tools/flake.lock leaves the primary key unchanged. The job then repeatedly fetches or rebuilds the updated closure without saving it after the exact cache hit; use a recursive lock pattern such as **/flake.lock alongside the recursive .nix pattern.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in the next commit (fix(nix-setup): include nested flake.lock files in the cache key, waiting for the user to push): the key now hashes **/*.nix and **/flake.lock. The README is updated too.
A dev shell defined by a nested flake has its own lock file, which the root-only pattern did not hash. Use a recursive pattern next to the recursive .nix one. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@codex review |
Review summaryNo blocking findings. I checked:
Not covered by tests: cache hit and miss behaviour is not exercised here. The CI job only runs |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🤖 I have created a release *beep* *boop* --- ## [1.3.0](v1.2.0...v1.3.0) (2026-11-09) ### Features * **nix-setup:** add a composite action that installs Nix and caches the store ([#24](#24)) ([f446f69](f446f69)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
概要
composite action
.github/actions/nix-setup(Nix のインストールと store キャッシュ)を足し,README に使い方を書く.各 repo が 1 行で呼べるようにするのが目的(#23 のレーン 0).merge すると release-please が minor(v1.3.0)を切る.cachix/install-nix-actionv31.11.3(nix-check / nix-lint と同じ SHA)nix-community/cache-nix-actionv7.0.2(agent-config の CI と同じ SHA と設定)<key-prefix>-<OS>-<arch>-<hashFiles('**/*.nix','**/flake.lock')>.miss 時は同じ prefix の最新を restoregc-max-store-size: 5G(GitHub のキャッシュ上限 10 GiB の内側)key-prefix(既定nix),save(既定 push のときだけ true.PR は restore のみ)確認
gha-lint(actionlint と zizmor)が通るall-green,claude-review,codex-reviewが緑判断と除外
flake.lockだけでなく全.nixと入れ子のflake.lockも入れた.devShell の中身は import 先の.nixでも変わり,cache-nix-action は exact なキーがないときだけ保存するため(Codex のレビュー対応)../.github/actions/...は呼び出し側 repo を指して解決され,自身のリリース SHA も指定できないため.README に理由を書いた.Refs #23
🤖 Generated with Claude Code