5959 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
6060 run : |
6161 # With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
62- sudo chown -R 872415232 /nix/var/cache/sccache
63- sudo chmod -R 2777 /nix/var/cache/sccache
62+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
63+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
6464 - name : nix build
6565 if : ${{ matrix.attr != '' }}
6666 shell : bash
@@ -104,8 +104,8 @@ jobs:
104104 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
105105 run : |
106106 # With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
107- sudo chown -R 872415232 /nix/var/cache/sccache
108- sudo chmod -R 2777 /nix/var/cache/sccache
107+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
108+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
109109 - name : nix build
110110 if : ${{ matrix.attr != '' }}
111111 shell : bash
@@ -126,9 +126,26 @@ jobs:
126126 - name : Checkout Repo
127127 if : ${{ matrix.attr != '' }}
128128 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
129+ - name : Mount sccache disk
130+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
131+ uses : useblacksmith/stickydisk@v1
132+ with :
133+ key : ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
134+ path : /nix/var/cache/sccache
129135 - name : Install nix
130136 if : ${{ matrix.attr != '' }}
131137 uses : ./.github/actions/nix-install-self-hosted
138+ - name : Configure sccache for Nix builds
139+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
140+ run : |
141+ # Ensure sccache directory exists
142+ mkdir -p /nix/var/cache/sccache
143+ # Update Nix configuration to allow access to sccache directory in sandbox
144+ if [ -w /etc/nix/nix.conf ]; then
145+ tee -a /etc/nix/nix.conf > /dev/null <<EOF
146+ extra-sandbox-paths = /nix/var/cache/sccache
147+ EOF
148+ fi
132149 - name : nix build
133150 if : ${{ matrix.attr != '' }}
134151 shell : bash
@@ -149,9 +166,26 @@ jobs:
149166 - name : Checkout Repo
150167 if : ${{ matrix.attr != '' }}
151168 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
169+ - name : Mount sccache disk
170+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
171+ uses : useblacksmith/stickydisk@v1
172+ with :
173+ key : ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
174+ path : /nix/var/cache/sccache
152175 - name : Install nix
153176 if : ${{ matrix.attr != '' }}
154177 uses : ./.github/actions/nix-install-self-hosted
178+ - name : Configure sccache for Nix builds
179+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
180+ run : |
181+ # Ensure sccache directory exists
182+ mkdir -p /nix/var/cache/sccache
183+ # Update Nix configuration to allow access to sccache directory in sandbox
184+ if [ -w /etc/nix/nix.conf ]; then
185+ tee -a /etc/nix/nix.conf > /dev/null <<EOF
186+ extra-sandbox-paths = /nix/var/cache/sccache
187+ EOF
188+ fi
155189 - name : nix build
156190 if : ${{ matrix.attr != '' }}
157191 shell : bash
@@ -192,8 +226,8 @@ jobs:
192226 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
193227 run : |
194228 # With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
195- sudo chown -R 872415232 /nix/var/cache/sccache
196- sudo chmod -R 2777 /nix/var/cache/sccache
229+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
230+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
197231 - name : nix build
198232 if : ${{ matrix.attr != '' }}
199233 shell : bash
@@ -234,8 +268,8 @@ jobs:
234268 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
235269 run : |
236270 # With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
237- sudo chown -R 872415232 /nix/var/cache/sccache
238- sudo chmod -R 2777 /nix/var/cache/sccache
271+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
272+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
239273 - name : nix build
240274 if : ${{ matrix.attr != '' }}
241275 shell : bash
0 commit comments