Skip to content

Commit 2fa4aa5

Browse files
committed
fix(cargo-pgrx): disable sccache on Darwin
1 parent 17cb841 commit 2fa4aa5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

nix/cargo-pgrx/buildPgrxExtension.nix

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,21 @@ let
165165
buildPhase = ''
166166
runHook preBuild
167167
168-
169-
if [[ -d "/nix/var/cache/sccache" && -w "/nix/var/cache/sccache" ]]; then
170-
echo "sccache: cache directory available, enabling"
171-
export RUSTC_WRAPPER="${sccache}/bin/sccache"
172-
export SCCACHE_DIR="/nix/var/cache/sccache"
173-
export SCCACHE_CACHE_SIZE="50G"
174-
else
175-
echo "sccache: cache directory not available, skipping"
176-
fi
168+
${lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
169+
if [[ -d "/nix/var/cache/sccache" && -w "/nix/var/cache/sccache" ]]; then
170+
# Test if sccache can actually write to the directory (sandbox check)
171+
if touch "/nix/var/cache/sccache/.test" 2>/dev/null && rm -f "/nix/var/cache/sccache/.test" 2>/dev/null; then
172+
echo "sccache: cache directory available and writable in sandbox, enabling"
173+
export RUSTC_WRAPPER="${sccache}/bin/sccache"
174+
export SCCACHE_DIR="/nix/var/cache/sccache"
175+
export SCCACHE_CACHE_SIZE="50G"
176+
else
177+
echo "sccache: cache directory not accessible in sandbox (needs extra-sandbox-paths configuration), skipping"
178+
fi
179+
else
180+
echo "sccache: cache directory not available, skipping"
181+
fi
182+
''}
177183
178184
echo "Executing cargo-pgrx buildPhase"
179185
${preBuildAndTest}

0 commit comments

Comments
 (0)