Skip to content

Commit e80b96a

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

1 file changed

Lines changed: 27 additions & 28 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ 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+
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
4460
- name: Mount nix store cache
4561
id: cache-nix-store
4662
uses: actions/cache/restore@v4
@@ -55,7 +71,7 @@ jobs:
5571
/nix/var/nix
5672
key: nix-store-${{ hashFiles('shell.nix', 'flake.lock') }}
5773

58-
- name: Build devShell
74+
- name: Build devShell to populate Nix store
5975
run: nix develop -c echo devShell built
6076

6177
- name: Save nix store cache
@@ -70,6 +86,16 @@ jobs:
7086
/nix/store
7187
/nix/var/nix
7288
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
7399

74100
# Install npm packages, unless we restored them from cache.
75101
# Since `npm ci` removes the node_modules folder before running it’s
@@ -117,37 +143,10 @@ jobs:
117143

118144
- uses: DeterminateSystems/determinate-nix-action@v3
119145

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-
134146
- name: Build devShell (branch)
135147
run: nix develop -c echo devShell built
136148
working-directory: branch
137149

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-
151150
- name: Build devShell (main)
152151
run: nix develop -c echo devShell built
153152
working-directory: main

0 commit comments

Comments
 (0)