Skip to content

Commit 34da50f

Browse files
committed
ci: cache gnu32 nix store
1 parent 22bec91 commit 34da50f

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ jobs:
130130
runs-on: ubuntu-latest
131131

132132
env:
133+
NIXPKGS_CHANNEL: nixos-25.05
134+
NIX_EXTRA_CONFIG: |
135+
keep-env-derivations = true
136+
keep-outputs = true
133137
NIX_EXTRA_CONFIG_ACT: |
134138
sandbox = false
135139
filter-syscalls = false
@@ -147,11 +151,29 @@ jobs:
147151
- name: Install Nix
148152
uses: cachix/install-nix-action@v31 # 2025-05-27, from https://github.com/cachix/install-nix-action/tags
149153
with:
150-
nix_path: nixpkgs=channel:nixos-25.05 # latest release
154+
nix_path: nixpkgs=channel:${{ env.NIXPKGS_CHANNEL }} # latest release
151155
# Act executes inside an unprivileged container (Docker or Podman),
152156
# so KVM support isn't available.
153157
enable_kvm: "${{ github.actor != 'nektos/act' }}"
154-
extra_nix_config: ${{ github.actor == 'nektos/act' && env.NIX_EXTRA_CONFIG_ACT || '' }}
158+
extra_nix_config: |
159+
${{ env.NIX_EXTRA_CONFIG }}
160+
${{ github.actor == 'nektos/act' && env.NIX_EXTRA_CONFIG_ACT || '' }}
161+
162+
# Cache the heaviest Nix job to stay within GitHub's cache budget while
163+
# still avoiding repeated gnu32 cross-toolchain downloads and builds.
164+
# Include the commit SHA in the write key so later runs can replace an
165+
# incomplete cache while restores still match on the stable prefix.
166+
- name: Cache Nix store
167+
if: matrix.config == 'gnu32'
168+
uses: nix-community/cache-nix-action@v7
169+
with:
170+
primary-key: nix-${{ runner.os }}-${{ matrix.config }}-${{ env.NIXPKGS_CHANNEL }}-${{ hashFiles('shell.nix', 'ci/patches/*.patch', 'ci/configs/gnu32.bash') }}-${{ github.sha }}
171+
restore-prefixes-first-match: |
172+
nix-${{ runner.os }}-${{ matrix.config }}-${{ env.NIXPKGS_CHANNEL }}-${{ hashFiles('shell.nix', 'ci/patches/*.patch', 'ci/configs/gnu32.bash') }}-
173+
nix-${{ runner.os }}-${{ matrix.config }}-${{ env.NIXPKGS_CHANNEL }}-
174+
nix-${{ runner.os }}-${{ matrix.config }}-
175+
nix-${{ runner.os }}-
176+
gc-max-store-size-linux: 10G
155177

156178
- name: Run CI script
157179
env:

0 commit comments

Comments
 (0)