Skip to content

feat(nix-setup): add a composite action that installs Nix and caches the store - #24

Merged
furedea merged 6 commits into
mainfrom
feat/23-nix-setup-action
Nov 9, 2026
Merged

furedea merged 6 commits into
mainfrom
feat/23-nix-setup-action

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

概要

composite action .github/actions/nix-setup(Nix のインストールと store キャッシュ)を足し,README に使い方を書く.各 repo が 1 行で呼べるようにするのが目的(#23 のレーン 0).merge すると release-please が minor(v1.3.0)を切る.

項目 内容
Nix cachix/install-nix-action v31.11.3(nix-check / nix-lint と同じ SHA)
キャッシュ nix-community/cache-nix-action v7.0.2(agent-config の CI と同じ SHA と設定)
キー <key-prefix>-<OS>-<arch>-<hashFiles('**/*.nix','**/flake.lock')>.miss 時は同じ prefix の最新を restore
サイズ 保存前に gc-max-store-size: 5G(GitHub のキャッシュ上限 10 GiB の内側)
入力 key-prefix(既定 nix),save(既定 push のときだけ true.PR は restore のみ)

確認

  • コミット時の ls-lint,commitlint が通る
  • CI の gha-lint(actionlint と zizmor)が通る
  • all-green,claude-review,codex-review が緑
  • 未確認:キャッシュの hit と miss は,この action を使う各 repo の CI でないと測れない(レーン 1〜8 で測って各 PR に書く)
判断と除外
  • キーに flake.lock だけでなく全 .nix と入れ子の flake.lock も入れた.devShell の中身は import 先の .nix でも変わり,cache-nix-action は exact なキーがないときだけ保存するため(Codex のレビュー対応).
  • nix-lint / nix-check からは使わない.reusable workflow 内の ./.github/actions/... は呼び出し側 repo を指して解決され,自身のリリース SHA も指定できないため.README に理由を書いた.
  • 計画からの変更:なし.Issue ci: run language tools from each repository's flake dev shell #23 に別の計画コメントは投稿していない(本文の計画表に従った).
  • 範囲外:release,各 repo の CI の移行,CI 時間の測定(ci: run language tools from each repository's flake dev shell #23 の他レーン).

Refs #23

🤖 Generated with Claude Code

furedea and others added 2 commits November 9, 2026 21:14
…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]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T12:46:01.092735Z 28e64d0 Manual request
ℹ️ 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" or "@codex security review".

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Fixed in 9961389: ci.yml now has a nix-setup job that runs uses: ./.github/actions/nix-setup and nix --version at the PR commit, and all-green needs it. The README mention is in 10dfee3. Both commits are waiting for the user to push.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

No blocking findings (0 × P0/P1).

  • The actions are pinned to full SHAs. install-nix-action uses the same SHA as nix-check, nix-lint and gha-lint.
  • The cache key and restore prefix are consistent, and the save default (save only on push events) is a valid input-default expression.
  • The README explanation of why the reusable workflows can't use ./.github/actions/... is correct.

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 ci.yml would catch them before release (see inline comment).

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: c999baa025

ℹ️ 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".

furedea and others added 2 commits November 9, 2026 21:19
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]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary: no findings.

I checked the new composite action .github/actions/nix-setup, the nix-setup job in ci.yml and its entry in all-green, and the README section:

  • save default: the default ${{ github.event_name == 'push' }} is allowed in composite-action metadata, and it comes out as true or false.
  • Cache key and restore prefix: both are scoped to key-prefix, the OS and the architecture, so caches from other prefixes or runners are not restored by mistake.
  • CI job: the job has least-privilege permissions, does not persist credentials, and is wired into all-green.

Not covered by tests: the CI job only checks nix --version, so cache restore and save are not exercised here. The PR description already says this will be measured in the consuming repos.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread .github/actions/nix-setup/action.yml Outdated
- 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') }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread .github/workflows/ci.yml
uses: ./.github/actions/nix-setup # zizmor: ignore[self-repository]

- name: Check that Nix works
run: nix --version

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary (read-only)

No P0/P1 findings.

  • P3 (.github/workflows/ci.yml): the new nix-setup job only runs nix --version. The cache inputs and the dev-shell usage aren't checked, and on PRs the save path never runs.

Notes, not findings:

  • The PR description says the key hashes flake.nix and flake.lock, but the code hashes **/*.nix and flake.lock. The README matches the code.
  • I couldn't fetch the pinned cache-nix-action v7.0.2 action.yml in this environment, so I didn't check the input names (save, restore-prefixes-first-match, gc-max-store-size) against that SHA. The PR says they match agent-config's CI.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread .github/actions/nix-setup/action.yml Outdated
- 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') }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

No blocking findings. I checked:

  • action.yml: cache-nix-action v7 accepts the inputs primary-key, restore-prefixes-first-match, save and gc-max-store-size. The save default ${{ github.event_name == 'push' }} is evaluated in the composite action's input defaults, which is the same pattern actions/checkout uses for github.token. hashFiles resolves against GITHUB_WORKSPACE, so it covers the caller's checked-out flake.nix and flake.lock.
  • ci.yml: the new nix-setup job is wired into all-green. Its contents: read permission is enough, because saving the cache uses the runtime token, not GITHUB_TOKEN. Pull requests only restore.
  • README: the usage example matches the action's inputs. The nix-check/nix-lint exclusion is explained.

Not covered by tests: cache hit and miss behaviour is not exercised here. The CI job only runs nix --version. The PR description already says this and defers it to the downstream lanes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 28e64d0787

ℹ️ 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".

@furedea
furedea merged commit f446f69 into main Nov 9, 2026
14 checks passed
@furedea
furedea deleted the feat/23-nix-setup-action branch November 9, 2026 12:49
furedea pushed a commit that referenced this pull request Nov 9, 2026
🤖 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>
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.

1 participant