From 5cdff541c3fdb0a0888693254bebd6524e757db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 9 Feb 2024 15:30:29 +0200 Subject: [PATCH] zig: fix cache folder handling - `env.ZIG_GLOBAL_CACHE_DIR` does not resolve variables, so all actions had their cache dir in the current directory, named '$TMPDIR/zig-cache'. - zig cache does not conflict, so it's totally fine to reuse it in both build and tests (thus removing `--cache-dir`). While we're at this, fix a `substituteInPlace` deprecation warning. --- pkgs/development/compilers/zig/generic.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/zig/generic.nix b/pkgs/development/compilers/zig/generic.nix index 27c193c0567d..3da36c083bd3 100644 --- a/pkgs/development/compilers/zig/generic.nix +++ b/pkgs/development/compilers/zig/generic.nix @@ -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. @@ -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 '';