Skip to content

Commit

Permalink
zig: fix cache folder handling (#287491)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-vdp authored Oct 21, 2024
2 parents f50dfa8 + 5cdff54 commit 2339cf9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkgs/development/compilers/zig/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ stdenv.mkDerivation (finalAttrs: {
"/System/Library/CoreServices/SystemVersion.plist"
];

env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
preBuild = ''
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache";
'';

# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
# work in Nix's sandbox. Use env from our coreutils instead.
Expand All @@ -55,14 +57,14 @@ stdenv.mkDerivation (finalAttrs: {
--replace "/usr/bin/env" "${coreutils}/bin/env"
'' else ''
substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
--replace "/usr/bin/env" "${coreutils}/bin/env"
--replace-fail "/usr/bin/env" "${coreutils}/bin/env"
'';

doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/zig test --cache-dir "$TMPDIR/zig-test-cache" -I $src/test $src/test/behavior.zig
$out/bin/zig test -I $src/test $src/test/behavior.zig
runHook postInstallCheck
'';
Expand Down

0 comments on commit 2339cf9

Please sign in to comment.