Post

Add Nix Store Cache to Validation Workflow

Add Nix Store Cache to Validation Workflow

I added a Nix store cache step to our CI validation workflow, which speeds up builds and guarantees that each run uses the exact flake inputs we tested.

Introduce the cache step in validate.yml

I inserted three new jobs into validate.yml: a Restore Nix Store Cache step, a Cache Nix Store step, and a revised Check flake step. The primary‑key for both cache steps is derived from the runner OS, architecture, and the hash of flake.nix and flake.lock. The Cache Nix Store step is lookup‑only on pushes and saves only on the main branch, while the Restore Nix Store Cache step is always saved. This makes the workflow reproducible and avoids re‑downloading signed artifacts.

Define cache trust and freshness across docs and validation gates

I clarified how the cache key is built and how jobs interact with it in docs/nix-cache.md and docs/ci-cd.md. The validate repository job on main verifies signed offline outputs before populating the Actions cache, then looks up the archive without downloading it on a miss. PR and runtime validation jobs only restore the cache, and a miss triggers normal Nix substitution. The validation‑gates document now notes that a shallow checkout lacking the event base commit fetches that commit, and that the Cache Nix Store or Restore Nix Store Cache steps should be checked on later runs to confirm reuse. This ensures consistent environments and prevents stale artifacts from bypassing signature checks.

Update validation test script and offline checks

I modified validate-runtime-scope-test.py so the scope function now accepts a checkout argument and runs the script in that directory, using a shallow clone to fetch only the needed commit depth. The script also adds a check for image‑policy, network‑policy, and harbor‑core settings. The offline-static-checks.sh script was tweaked with a single line change, and validate-runtime-scope.sh now fetches the base SHA if the commit is missing before proceeding. These updates guarantee that the test runs against the exact code base that the cache was built from, and that offline verification happens before any cache reuse.

This post is licensed under CC BY 4.0 by the author.