Skip to content

ci(mac): cache nix store between runs#22

Closed
Typas wants to merge 3 commits into
masterfrom
ci/mac-nix-cache
Closed

ci(mac): cache nix store between runs#22
Typas wants to merge 3 commits into
masterfrom
ci/mac-nix-cache

Conversation

@Typas

@Typas Typas commented Apr 26, 2026

Copy link
Copy Markdown
Owner

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.

Typas and others added 3 commits April 26, 2026 09:48
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>
@Typas Typas closed this Apr 26, 2026
@Typas Typas deleted the ci/mac-nix-cache branch April 26, 2026 02:11
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