|
41 | 41 | )}} |
42 | 42 |
|
43 | 43 | # Caching based on https://github.com/jetify-com/devbox-install-action/blob/main/action.yml |
| 44 | + - name: Workaround nix store cache permission issue |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 48 | + gtar_path=$(which gtar) |
| 49 | + sudo mv $gtar_path $gtar_path.orig |
| 50 | + echo "#!/bin/sh" >> $gtar_path |
| 51 | + echo "exec sudo $gtar_path.orig \"\$@\"" >> $gtar_path |
| 52 | + sudo chmod +x $gtar_path |
| 53 | + elif [ "$RUNNER_OS" == "Linux" ]; then |
| 54 | + mkdir -p ~/.cache |
| 55 | + mkdir -p ~/.local/bin |
| 56 | + echo "#!/bin/sh" >> ~/.local/bin/tar |
| 57 | + echo 'exec sudo /usr/bin/tar "$@"' >> ~/.local/bin/tar |
| 58 | + sudo chmod +x ~/.local/bin/tar |
| 59 | + fi |
44 | 60 | - name: Mount nix store cache |
45 | 61 | id: cache-nix-store |
46 | 62 | uses: actions/cache/restore@v4 |
|
55 | 71 | /nix/var/nix |
56 | 72 | key: nix-store-${{ hashFiles('shell.nix', 'flake.lock') }} |
57 | 73 |
|
58 | | - - name: Build devShell |
| 74 | + - name: Build devShell to populate Nix store |
59 | 75 | run: nix develop -c echo devShell built |
60 | 76 |
|
61 | 77 | - name: Save nix store cache |
|
70 | 86 | /nix/store |
71 | 87 | /nix/var/nix |
72 | 88 | key: nix-store-${{ hashFiles('shell.nix', 'flake.lock') }} |
| 89 | + - name: Restore tar command |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 93 | + gtar_path=$(which gtar) |
| 94 | + sudo mv $gtar_path.orig $gtar_path |
| 95 | + elif [ "$RUNNER_OS" == "Linux" ]; then |
| 96 | + rm ~/.local/bin/tar |
| 97 | + fi |
| 98 | + # END of Nix store caching |
73 | 99 |
|
74 | 100 | # Install npm packages, unless we restored them from cache. |
75 | 101 | # Since `npm ci` removes the node_modules folder before running it’s |
@@ -117,37 +143,10 @@ jobs: |
117 | 143 |
|
118 | 144 | - uses: DeterminateSystems/determinate-nix-action@v3 |
119 | 145 |
|
120 | | - - name: Mount nix store cache |
121 | | - id: cache-nix-store |
122 | | - uses: actions/cache/restore@v4 |
123 | | - with: |
124 | | - path: | |
125 | | - ~/.cache/devbox |
126 | | - ~/.cache/nix |
127 | | - ~/.local/state/nix |
128 | | - ~/.nix-defexpr |
129 | | - ~/.nix-profile |
130 | | - /nix/store |
131 | | - /nix/var/nix |
132 | | - key: nix-store-${{ hashFiles('branch/shell.nix', 'branch/flake.lock') }} |
133 | | - |
134 | 146 | - name: Build devShell (branch) |
135 | 147 | run: nix develop -c echo devShell built |
136 | 148 | working-directory: branch |
137 | 149 |
|
138 | | - - name: Save nix store cache |
139 | | - if: steps.cache-nix-store.outputs.cache-hit != 'true' |
140 | | - uses: actions/cache/save@v4 |
141 | | - with: |
142 | | - path: | |
143 | | - ~/.cache/nix |
144 | | - ~/.local/state/nix |
145 | | - ~/.nix-defexpr |
146 | | - ~/.nix-profile |
147 | | - /nix/store |
148 | | - /nix/var/nix |
149 | | - key: nix-store-${{ hashFiles('branch/shell.nix', 'branch/flake.lock') }} |
150 | | - |
151 | 150 | - name: Build devShell (main) |
152 | 151 | run: nix develop -c echo devShell built |
153 | 152 | working-directory: main |
|
0 commit comments