Skip to content

Commit 7e4b495

Browse files
committed
Bound nix cache size in CI
magic-nix-cache-action writes one GitHub cache entry per nix store path, which churns through the Actions cache API and leaves over a thousand entries behind. Swap it for nix-community/cache-nix-action, which keeps the store as a single bounded entry per job, purging all but the newest. Keys are scoped by `github.job` because jobs realise different store closures, and job ids are unique across the workflows that set nix up. Note this reduces entry count and churn but does not by itself free the cache quota: Swatinem/rust-cache accounts for 9.52 GiB of the 10 GB against magic-nix-cache's 1.11 GiB. See #1131 for the numbers.
1 parent 249d28d commit 7e4b495

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

.github/actions/setup-nix/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ runs:
99
- name: Install nix
1010
uses: DeterminateSystems/determinate-nix-action@main
1111
- name: Use nix cache
12-
uses: DeterminateSystems/magic-nix-cache-action@main
12+
uses: nix-community/cache-nix-action@v7
1313
with:
14-
use-flakehub: false
14+
primary-key: nix-${{ runner.os }}-${{ github.job }}-${{ hashFiles('flake.nix', 'flake.lock') }}
15+
restore-prefixes-first-match: nix-${{ runner.os }}-${{ github.job }}-
16+
gc-max-store-size: 1G
17+
purge: true
18+
purge-prefixes: nix-${{ runner.os }}-${{ github.job }}-
19+
purge-created: 0
20+
purge-primary-key: never

.github/workflows/rust.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ jobs:
3030
- name: "Install nix"
3131
uses: DeterminateSystems/determinate-nix-action@main
3232
- name: "Use nix cache"
33-
uses: DeterminateSystems/magic-nix-cache-action@main
33+
uses: nix-community/cache-nix-action@v7
3434
with:
35-
use-flakehub: false
35+
primary-key: nix-${{ runner.os }}-${{ github.job }}-${{ hashFiles('flake.nix', 'flake.lock') }}
36+
restore-prefixes-first-match: nix-${{ runner.os }}-${{ github.job }}-
37+
gc-max-store-size: 1G
38+
purge: true
39+
purge-prefixes: nix-${{ runner.os }}-${{ github.job }}-
40+
purge-created: 0
41+
purge-primary-key: never
3642
- name: "Add nginxWithStream to PATH"
3743
run: |
3844
# This is necessary for payjoin-mailroom integration tests
@@ -52,9 +58,15 @@ jobs:
5258
- name: "Install nix"
5359
uses: DeterminateSystems/determinate-nix-action@main
5460
- name: "Use nix cache"
55-
uses: DeterminateSystems/magic-nix-cache-action@main
61+
uses: nix-community/cache-nix-action@v7
5662
with:
57-
use-flakehub: false
63+
primary-key: nix-${{ runner.os }}-${{ github.job }}-${{ hashFiles('flake.nix', 'flake.lock') }}
64+
restore-prefixes-first-match: nix-${{ runner.os }}-${{ github.job }}-
65+
gc-max-store-size: 1G
66+
purge: true
67+
purge-prefixes: nix-${{ runner.os }}-${{ github.job }}-
68+
purge-created: 0
69+
purge-primary-key: never
5870
- name: "Run code linting"
5971
run: nix develop -c ./contrib/lint.sh
6072
- name: "Run documentation linting"
@@ -80,9 +92,15 @@ jobs:
8092
- name: "Install nix"
8193
uses: DeterminateSystems/determinate-nix-action@main
8294
- name: "Use nix cache"
83-
uses: DeterminateSystems/magic-nix-cache-action@main
95+
uses: nix-community/cache-nix-action@v7
8496
with:
85-
use-flakehub: false
97+
primary-key: nix-${{ runner.os }}-${{ github.job }}-${{ hashFiles('flake.nix', 'flake.lock') }}
98+
restore-prefixes-first-match: nix-${{ runner.os }}-${{ github.job }}-
99+
gc-max-store-size: 1G
100+
purge: true
101+
purge-prefixes: nix-${{ runner.os }}-${{ github.job }}-
102+
purge-created: 0
103+
purge-primary-key: never
86104
- name: "Add nginxWithStream to PATH"
87105
run: |
88106
# This is necessary for payjoin-mailroom integration tests

0 commit comments

Comments
 (0)