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,23 @@ 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 cache directory
139+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
140+ run : |
141+ mkdir -p /nix/var/cache/sccache || true
142+ # Stop any existing sccache daemon to avoid stale TMPDIR state
143+ if command -v sccache &> /dev/null; then
144+ sccache --stop-server 2>/dev/null || true
145+ fi
132146 - name : nix build
133147 if : ${{ matrix.attr != '' }}
134148 shell : bash
@@ -149,9 +163,23 @@ jobs:
149163 - name : Checkout Repo
150164 if : ${{ matrix.attr != '' }}
151165 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
166+ - name : Mount sccache disk
167+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
168+ uses : useblacksmith/stickydisk@v1
169+ with :
170+ key : ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
171+ path : /nix/var/cache/sccache
152172 - name : Install nix
153173 if : ${{ matrix.attr != '' }}
154174 uses : ./.github/actions/nix-install-self-hosted
175+ - name : Configure sccache cache directory
176+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
177+ run : |
178+ mkdir -p /nix/var/cache/sccache || true
179+ # Stop any existing sccache daemon to avoid stale TMPDIR state
180+ if command -v sccache &> /dev/null; then
181+ sccache --stop-server 2>/dev/null || true
182+ fi
155183 - name : nix build
156184 if : ${{ matrix.attr != '' }}
157185 shell : bash
@@ -192,8 +220,8 @@ jobs:
192220 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
193221 run : |
194222 # 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
223+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
224+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
197225 - name : nix build
198226 if : ${{ matrix.attr != '' }}
199227 shell : bash
@@ -234,8 +262,8 @@ jobs:
234262 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
235263 run : |
236264 # 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
265+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
266+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
239267 - name : nix build
240268 if : ${{ matrix.attr != '' }}
241269 shell : bash
0 commit comments