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,13 +126,43 @@ 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
135149 run : nix build --accept-flake-config -L .#${{ matrix.attr }}
150+ - name : Setup tmate session on failure
151+ if : ${{ failure() && matrix.attr != '' && matrix.postgresql_version }}
152+ timeout-minutes : 30
153+ shell : bash
154+ run : |
155+ nix profile install nixpkgs#tmate
156+ export PATH="$HOME/.nix-profile/bin:$PATH"
157+ mkdir -p ~/.tmate
158+ killall tmate 2>/dev/null || true
159+ rm -f /tmp/tmate.sock
160+ rm -f /tmp/tmate.sock
161+ tmate -S /tmp/tmate.sock new-session -d
162+ tmate -S /tmp/tmate.sock wait tmate-ready
163+ tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
164+ echo "Session active for 30 minutes. Cancel workflow to exit."
165+ sleep 1800
136166
137167 nix-build-checks-aarch64-darwin :
138168 name : >-
@@ -149,9 +179,23 @@ jobs:
149179 - name : Checkout Repo
150180 if : ${{ matrix.attr != '' }}
151181 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
182+ - name : Mount sccache disk
183+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
184+ uses : useblacksmith/stickydisk@v1
185+ with :
186+ key : ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
187+ path : /nix/var/cache/sccache
152188 - name : Install nix
153189 if : ${{ matrix.attr != '' }}
154190 uses : ./.github/actions/nix-install-self-hosted
191+ - name : Configure sccache cache directory
192+ if : ${{ matrix.attr != '' && matrix.postgresql_version }}
193+ run : |
194+ mkdir -p /nix/var/cache/sccache || true
195+ # Stop any existing sccache daemon to avoid stale TMPDIR state
196+ if command -v sccache &> /dev/null; then
197+ sccache --stop-server 2>/dev/null || true
198+ fi
155199 - name : nix build
156200 if : ${{ matrix.attr != '' }}
157201 shell : bash
@@ -192,12 +236,28 @@ jobs:
192236 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
193237 run : |
194238 # 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
239+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
240+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
197241 - name : nix build
198242 if : ${{ matrix.attr != '' }}
199243 shell : bash
200244 run : nix build --accept-flake-config -L .#${{ matrix.attr }}
245+ - name : Setup tmate session on failure
246+ if : ${{ failure() && matrix.attr != '' && matrix.postgresql_version }}
247+ timeout-minutes : 30
248+ shell : bash
249+ run : |
250+ nix profile install nixpkgs#tmate
251+ export PATH="$HOME/.nix-profile/bin:$PATH"
252+ mkdir -p ~/.tmate
253+ killall tmate 2>/dev/null || true
254+ rm -f /tmp/tmate.sock
255+ rm -f /tmp/tmate.sock
256+ tmate -S /tmp/tmate.sock new-session -d
257+ tmate -S /tmp/tmate.sock wait tmate-ready
258+ tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
259+ echo "Session active for 30 minutes. Cancel workflow to exit."
260+ sleep 1800
201261
202262 nix-build-checks-x86_64-linux :
203263 name : >-
@@ -234,8 +294,8 @@ jobs:
234294 if : ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
235295 run : |
236296 # 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
297+ if [ -d /nix/var/cache/sccache ]; then sudo chown -R 872415232 /nix/var/cache/sccache; fi
298+ if [ -d /nix/var/cache/sccache ]; then sudo chmod -R 2777 /nix/var/cache/sccache; fi
239299 - name : nix build
240300 if : ${{ matrix.attr != '' }}
241301 shell : bash
0 commit comments