Skip to content

Commit b32b756

Browse files
committed
CI/Nix: add cache-nix-action
Use nixbuild/nix-quick-install-action which pairs well with nix-community/cache-nix-action. Should help with build times by reducing the number of packages needing to be re-downloaded on each run. Parameters are taken from https://github.com/nix-community/cache-nix-action and may be tweaked later.
1 parent 4528cca commit b32b756

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

.github/workflows/nix-build.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,35 @@ jobs:
77
steps:
88
- uses: actions/checkout@v4
99

10-
- uses: DeterminateSystems/nix-installer-action@main
10+
- name: Install Nix
11+
uses: nixbuild/nix-quick-install-action@v31
12+
with:
13+
nix_conf: |
14+
keep-env-derivations = true
15+
keep-outputs = true
16+
17+
- name: Restore and save Nix store
18+
uses: nix-community/cache-nix-action@v6
19+
with:
20+
# restore and save a cache using this key
21+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
22+
# if there's no cache hit, restore a cache by this prefix
23+
restore-prefixes-first-match: nix-${{ runner.os }}-
24+
# collect garbage until the Nix store size (in bytes) is at most this number
25+
# before trying to save a new cache
26+
# 1G = 1073741824
27+
gc-max-store-size-linux: 1G
28+
# do purge caches
29+
purge: true
30+
# purge all versions of the cache
31+
purge-prefixes: nix-${{ runner.os }}-
32+
# created more than this number of seconds ago
33+
purge-created: 0
34+
# or, last accessed more than this number of seconds ago
35+
# relative to the start of the `Post Restore and save Nix store` phase
36+
purge-last-accessed: 0
37+
# except any version with the key that is the same as the `primary-key`
38+
purge-primary-key: never
1139

1240
# not needed (yet)
1341
# - uses: cachix/cachix-action@v12

0 commit comments

Comments
 (0)