Skip to content

Commit 5f6f40c

Browse files
committed
feat: cache eval nix store to speed up evaluation job
1 parent f8cdc3d commit 5f6f40c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/actions/nix-install-ephemeral/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ inputs:
55
description: 'Whether to push build outputs to the Nix binary cache'
66
required: false
77
default: 'true'
8+
restore-nix-store:
9+
description: 'Whether to restore the Nix store from the binary cache before building'
10+
required: false
11+
default: 'false'
12+
restore-cache-name:
13+
description: 'The name to use for the Nix store cache (if restoring)'
14+
required: false
815
runs:
916
using: 'composite'
1017
steps:
@@ -44,3 +51,8 @@ runs:
4451
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
4552
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
4653
${{ inputs.push-to-cache == 'true' && 'post-build-hook = /etc/nix/upload-to-cache.sh' || '' }}
54+
- name: Restore and save Nix store
55+
uses: nix-community/cache-nix-action@v6
56+
with:
57+
primary-key: nix-${{ inputs.restore-cache-name }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
58+
restore-prefixes-first-match: nix-${{ inputs.restore-cache-name }}-${{ runner.os }}-${{ runner.arch }}-

.github/workflows/nix-eval.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ jobs:
2525
env:
2626
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
2727
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
28+
with:
29+
restore-nix-store: true
30+
restore-cache-name: nix-eval
2831
- id: set-matrix
2932
name: Generate Nix Matrix
3033
run: |
3134
set -Eeu
32-
echo matrix="$(nix run .\#github-matrix checks legacyPackages)" >> "$GITHUB_OUTPUT"
35+
echo matrix="$(nix run --accept-flake-config .\#github-matrix checks legacyPackages)" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)