Skip to content

Commit 279ceb3

Browse files
committed
Add nix-community/cache-nix-action for Nix store caching
Replaces the dropped magic-nix-cache-action. Uses GitHub Actions cache to persist /nix between runs, keyed by hashes of all .nix files plus flake.lock so a flake change invalidates the cache. Falls back to the most recent same-OS cache via restore-prefixes-first-match. Per-OS GC ceilings (5G linux, 3G macOS) keep cached store size under GitHub's 10G per-repo limit while leaving room for other caches.
1 parent 15a6c5e commit 279ceb3

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313

1414
- uses: DeterminateSystems/nix-installer-action@main
1515

16+
- uses: nix-community/cache-nix-action@v7
17+
with:
18+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
19+
restore-prefixes-first-match: nix-${{ runner.os }}-
20+
gc-max-store-size-linux: 5G
21+
1622
- name: Build
1723
run: nix build
1824

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ jobs:
1414

1515
- uses: DeterminateSystems/nix-installer-action@main
1616

17+
- uses: nix-community/cache-nix-action@v7
18+
with:
19+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
20+
restore-prefixes-first-match: nix-${{ runner.os }}-
21+
gc-max-store-size-linux: 5G
22+
1723
- name: Build release tarball
1824
run: |
1925
nix build .#packages.x86_64-linux.release -o result-release
@@ -35,6 +41,12 @@ jobs:
3541
- uses: actions/checkout@v4
3642
- uses: DeterminateSystems/nix-installer-action@main
3743

44+
- uses: nix-community/cache-nix-action@v7
45+
with:
46+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
47+
restore-prefixes-first-match: nix-${{ runner.os }}-
48+
gc-max-store-size-macos: 3G
49+
3850
- name: Build package
3951
run: nix build .#packages.aarch64-darwin.default -o result
4052

0 commit comments

Comments
 (0)