Skip to content

feat(ci): keep only what cache.nixos.org lacks in the Actions cache - #2

Merged
clhodapp merged 1 commit into
mainfrom
feat/ci-cache-slim
Sep 8, 2026
Merged

clhodapp merged 1 commit into
mainfrom
feat/ci-cache-slim

Conversation

@clhodapp

@clhodapp clhodapp commented Sep 8, 2026

Copy link
Copy Markdown
Owner

The same change the other five pipeline repos carry (ch-ai-workbench #8, ch-emacs-config #15, merman #4, big-console #13, ch-zsh-config #4), with their two follow-up fixes folded in. This repository's copy of the pipeline landed after those branches were cut, so it gets its own.

The Actions cache entry this pipeline keeps between runs held the whole rooted Nix store: everything the checks' closures reach, including the paths cache.nixos.org serves, which every run could fetch from there instead. This changes what the entry holds so that those paths stay out of it.

How it works now

  • The entry is a Nix binary cache on disk (/home/runner/ci-cache: narinfo files and zstd-compressed NARs) plus the root tree under roots/. Nix reads it as a substituter, listed in nix.conf as file:///home/runner/ci-cache?trusted=true; the trusted store parameter accepts that store's unsigned paths and no other's.
  • After nix flake check, the run copies the closure of the flake's checks and packages into the binary cache, asks cache.nixos.org which of those paths it serves (a HEAD request per path for its narinfo file, 32 in parallel; a failed request counts as not served, which only keeps more), and records the rest as this build's root (roots/<class>/<id>/paths). The whole closure has to go in first, because a binary cache refuses a path whose references it does not hold; the served paths are deleted again before the save, and compressing them with zstd costs seconds.
  • The priority order and the 10 GB budget are unchanged. Sizes now come from the narinfo FileSize fields, the compressed sizes GitHub counts, instead of uncompressed closure sizes.
  • Before the save, every narinfo that no surviving root lists is deleted, then every NAR that no remaining narinfo names.
  • Restore and save use actions/cache/restore and actions/cache/save (v4.3.0) directly. cache-nix-action and its store garbage collection are gone, and the root step needs no sudo.

Transition

Keys move from nix-Linux-<sha> to cache-Linux-<sha>, so no run restores an entry of the earlier form (a store archive, which the new restore step would extract before Nix is installed). The first run on main after this lands is cold and saves the first new entry; the earlier entries expire unused within GitHub's seven-day window. This pull request changes .github/, so check-pr builds it under the request's own scope, which is the first exercise of the new pipeline here.

cachix

The push to the clhodapp cache now covers the closure of this run's outputs; earlier runs pushed theirs when they were built, and cachix push still skips what the cache holds. Before, each run re-pushed the closure of every kept root.

Verified

actionlint and the repository formatter are clean, and the diff is line for line the one ch-zsh-config carries apart from this repository's two prose passages. In the other repos the check-pr runs on the final commits are green; the workbench entry went from 1.35 GB to 38 MB and ch-emacs-config's from 1.63 GB to 48 MB.

🤖 Generated with Claude Code

Result on this branch

The check-pr run saw 133 paths in the closure, 130 of them served by cache.nixos.org, and kept 3; the saved entry is 20 KB, against 277 MB for the whole-store entry main holds today.

The cache entry becomes a Nix binary cache on disk (narinfo files and zstd-compressed NARs) that the checks read as a trusted substituter, instead of an archive of the whole rooted store. After the checks, the run copies the closure of its outputs into it, asks cache.nixos.org which of those paths it serves (a HEAD request per narinfo file), records the rest as this build's root, and prunes the cache to the union of the surviving roots' lists before the save. Sizes for the 10 GB budget come from the narinfo FileSize fields, so they are the compressed sizes GitHub counts rather than the uncompressed closure sizes used before.

Keys move from the nix- prefix to cache- so that no entry of the earlier form is restored; the earlier entries expire unused. The push to the clhodapp cache covers this run's outputs; earlier runs pushed theirs. This is the same change the other five pipeline repos carry, with their two follow-up fixes folded in.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@clhodapp clhodapp self-assigned this Sep 8, 2026
@clhodapp
clhodapp merged commit 1ba07f8 into main Sep 8, 2026
2 checks passed
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