|
1 | 1 | name: Setup Nix |
2 | | -description: Install Nix and optionally mount a Blacksmith sticky disk for the Nix store |
| 2 | +description: Install Nix with platform-specific cache setup |
3 | 3 | inputs: |
4 | 4 | warm-dev-shell: |
5 | 5 | description: Whether to instantiate the CI dev shell during setup |
6 | 6 | default: 'false' |
7 | 7 | runs: |
8 | 8 | using: composite |
9 | 9 | steps: |
10 | | - - name: Detect Blacksmith sticky disk support |
11 | | - id: blacksmith |
12 | | - shell: bash |
13 | | - run: | |
14 | | - if [ -n "${BLACKSMITH_STICKYDISK_TOKEN:-}" ]; then |
15 | | - echo "enabled=true" >> "$GITHUB_OUTPUT" |
16 | | - else |
17 | | - echo "enabled=false" >> "$GITHUB_OUTPUT" |
18 | | - fi |
19 | | -
|
20 | | - - name: Resolve pnpm version |
21 | | - id: pnpm |
22 | | - if: steps.blacksmith.outputs.enabled == 'true' |
23 | | - shell: bash |
24 | | - run: | |
25 | | - package_manager="$(node -p "require('./package.json').packageManager ?? ''")" |
26 | | - case "$package_manager" in |
27 | | - pnpm@*) echo "version=${package_manager#pnpm@}" >> "$GITHUB_OUTPUT" ;; |
28 | | - *) echo "version=unknown" >> "$GITHUB_OUTPUT" ;; |
29 | | - esac |
30 | | -
|
31 | | - - name: Prepare Nix store mount point |
32 | | - if: runner.os == 'Linux' && steps.blacksmith.outputs.enabled == 'true' |
33 | | - shell: bash |
34 | | - run: | |
35 | | - sudo mkdir -p /nix/store |
36 | | - sudo chmod 755 /nix |
37 | | -
|
38 | | - - name: Mount Nix store sticky disk |
39 | | - if: runner.os == 'Linux' && steps.blacksmith.outputs.enabled == 'true' |
40 | | - uses: useblacksmith/stickydisk@d58829ad6f9be8822ec5efe74256c82cd62915ab # v1 |
41 | | - with: |
42 | | - key: ${{ github.repository }}-nix-${{ runner.os }}-${{ runner.arch }} |
43 | | - path: /nix |
44 | | - |
45 | | - - name: Prepare mounted Nix store ownership |
46 | | - if: runner.os == 'Linux' && steps.blacksmith.outputs.enabled == 'true' |
47 | | - shell: bash |
48 | | - run: | |
49 | | - sudo mkdir -p /nix/store |
50 | | - sudo chown "$USER:$(id -gn)" /nix /nix/store |
51 | | - for path in /nix/var/log/nix /nix/var/nix; do |
52 | | - if [ -e "$path" ]; then |
53 | | - sudo chown -R "$USER:$(id -gn)" "$path" |
54 | | - fi |
55 | | - done |
56 | | -
|
57 | | - - name: Mount root node_modules sticky disk |
58 | | - if: runner.os == 'Linux' && steps.blacksmith.outputs.enabled == 'true' |
59 | | - uses: useblacksmith/stickydisk@d58829ad6f9be8822ec5efe74256c82cd62915ab # v1 |
60 | | - with: |
61 | | - key: ${{ github.repository }}-node-modules-pnpm-${{ steps.pnpm.outputs.version }}-${{ runner.os }}-${{ runner.arch }} |
62 | | - path: ./node_modules |
| 10 | + - uses: ./.github/actions/setup-linux-blacksmith-sticky-disk |
| 11 | + if: runner.os == 'Linux' |
63 | 12 |
|
64 | 13 | - name: Install Nix |
65 | 14 | uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 |
|
68 | 17 | nix_conf: | |
69 | 18 | access-tokens = github.com=${{ github.token }} |
70 | 19 |
|
71 | | - - name: Cache macOS Nix store |
| 20 | + - uses: ./.github/actions/setup-macos-nix-cache |
72 | 21 | if: runner.os == 'macOS' |
73 | | - uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2 |
74 | | - with: |
75 | | - primary-key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.lock', 'flake.nix', 'dev/flake.lock', 'dev/flake.nix', 'default.nix', 'package.nix', 'package.json', 'nix/**/*.nix', 'rust-toolchain.toml', 'rust/Cargo.lock', 'rust/**/Cargo.toml') }} |
76 | | - restore-prefixes-first-match: nix-${{ runner.os }}-${{ runner.arch }}- |
77 | | - gc-max-store-size-macos: 3500000000 |
78 | | - purge: true |
79 | | - purge-prefixes: nix-${{ runner.os }}-${{ runner.arch }}- |
80 | | - purge-created: 172800 |
81 | | - purge-primary-key: never |
82 | 22 |
|
83 | 23 | - name: Fix single-user Nix store ownership |
84 | 24 | if: runner.os != 'Windows' |
|
0 commit comments