ci(mac): cache nix store between runs#22
Closed
Typas wants to merge 3 commits into
Closed
Conversation
Repeated runs re-download the same Nix packages from cache.nixos.org every time, adding ~2m to the mac job. Cache the store keyed on init.sh's hash so subsequent runs find packages already present. A fallback prefix allows partial hits when only some deps changed. Store is capped at 1 GiB to stay within GHA cache limits. Co-Authored-By: Claude <noreply@anthropic.com>
Three issues made the cache ineffective: the key hashed init.sh but not flake.lock, so nix-darwin rebuilds from a nixpkgs update would reuse stale cache entries and miss when flake.lock changed. Flake input tarballs (~/.cache/nix) were not cached, so nixpkgs was re-downloaded every run regardless of store hits. The 1 GiB cap was too small for a full nix-darwin activation, causing evictions that forced re-downloads on the next run. Raised to 5 GiB to stay within the 10 GiB per-repo GitHub cache quota. Co-Authored-By: Claude <noreply@anthropic.com>
cache-nix-action's post-job step runs nix --version to calculate store size before saving. Because mac-nix-setup never wrote to GITHUB_PATH, nix was absent from PATH in the post-run environment, causing an exit 127 that silently skipped the cache save — meaning the cache was never populated and every run stayed slow. Writing /nix/var/nix/profiles/default/bin to GITHUB_PATH persists nix across all subsequent steps and post-run hooks. The explicit profile source in bash init.sh is no longer needed and is removed. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated runs re-download the same Nix packages from cache.nixos.org every time, adding ~2m to the mac job. Cache the store keyed on init.sh's hash so subsequent runs find packages already present. A fallback prefix allows partial hits when only some deps changed. Store is capped at 1 GiB to stay within GHA cache limits.