Skip to content

Commit 78c0ac4

Browse files
committed
ci: Fix nix store caching
1 parent ded0297 commit 78c0ac4

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ jobs:
4141
)}}
4242
4343
# Caching based on https://github.com/jetify-com/devbox-install-action/blob/main/action.yml
44+
- name: Workaround nix store cache permission issue
45+
if: inputs.enable-cache == 'true'
46+
shell: bash
47+
run: |
48+
if [ "$RUNNER_OS" == "macOS" ]; then
49+
gtar_path=$(which gtar)
50+
sudo mv $gtar_path $gtar_path.orig
51+
echo "#!/bin/sh" >> $gtar_path
52+
echo "exec sudo $gtar_path.orig \"\$@\"" >> $gtar_path
53+
sudo chmod +x $gtar_path
54+
elif [ "$RUNNER_OS" == "Linux" ]; then
55+
mkdir -p ~/.cache
56+
mkdir -p ~/.local/bin
57+
echo "#!/bin/sh" >> ~/.local/bin/tar
58+
echo 'exec sudo /usr/bin/tar "$@"' >> ~/.local/bin/tar
59+
sudo chmod +x ~/.local/bin/tar
60+
fi
4461
- name: Mount nix store cache
4562
id: cache-nix-store
4663
uses: actions/cache/restore@v4
@@ -54,10 +71,8 @@ jobs:
5471
/nix/store
5572
/nix/var/nix
5673
key: nix-store-${{ hashFiles('shell.nix', 'flake.lock') }}
57-
58-
- name: Build devShell
74+
- name: Build devShell to populate Nix store
5975
run: nix develop -c echo devShell built
60-
6176
- name: Save nix store cache
6277
if: steps.cache-nix-store.outputs.cache-hit != 'true'
6378
uses: actions/cache/save@v4
@@ -71,6 +86,18 @@ jobs:
7186
/nix/var/nix
7287
key: nix-store-${{ hashFiles('shell.nix', 'flake.lock') }}
7388

89+
- name: Restore tar command
90+
if: inputs.enable-cache == 'true'
91+
shell: bash
92+
run: |
93+
if [ "$RUNNER_OS" == "macOS" ]; then
94+
gtar_path=$(which gtar)
95+
sudo mv $gtar_path.orig $gtar_path
96+
elif [ "$RUNNER_OS" == "Linux" ]; then
97+
rm ~/.local/bin/tar
98+
fi
99+
# END of Nix store caching
100+
74101
# Install npm packages, unless we restored them from cache.
75102
# Since `npm ci` removes the node_modules folder before running it’s
76103
# important to skip this step if cache was restored.
@@ -117,37 +144,10 @@ jobs:
117144

118145
- uses: DeterminateSystems/determinate-nix-action@v3
119146

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-
134147
- name: Build devShell (branch)
135148
run: nix develop -c echo devShell built
136149
working-directory: branch
137150

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-
151151
- name: Build devShell (main)
152152
run: nix develop -c echo devShell built
153153
working-directory: main

0 commit comments

Comments
 (0)