Unverified Commit e20232ea authored by Jared Baur's avatar Jared Baur
Browse files

zig: move ZIG_GLOBAL_CACHE_DIR setup to configurePhase

This allows users to put zig in their `mkShell` without ending up with a
ZIG_GLOBAL_CACHE_DIR value set that points back to a location that only
would exist in the sandbox.
parent 5bfbbc27
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ stdenv.mkDerivation {

The variables below are exclusive to `zig`.

#### `dontUseZigConfigure` {#dont-use-zig-configure}

Disables using `zigConfigurePhase`.

#### `dontUseZigBuild` {#dont-use-zig-build}

Disables using `zigBuildPhase`.
+3 −0
Original line number Diff line number Diff line
@@ -2762,6 +2762,9 @@
    "index.html#zig-exclusive-variables",
    "index.html#zig-hook-exclusive-variables"
  ],
  "dont-use-zig-configure": [
    "index.html#dont-use-zig-configure"
  ],
  "dont-use-zig-build": [
    "index.html#dont-use-zig-build"
  ],
+8 −3
Original line number Diff line number Diff line
@@ -4,9 +4,13 @@
readonly zigDefaultCpuFlag=@zig_default_cpu_flag@
readonly zigDefaultOptimizeFlag=@zig_default_optimize_flag@

function zigSetGlobalCacheDir {
function zigConfigurePhase {
  runHook preConfigure

  ZIG_GLOBAL_CACHE_DIR=$(mktemp -d)
  export ZIG_GLOBAL_CACHE_DIR

  runHook postConfigure
}

function zigBuildPhase {
@@ -97,8 +101,9 @@ function zigInstallPhase {
  runHook postInstall
}

# shellcheck disable=SC2154
addEnvHooks "$hostOffset" zigSetGlobalCacheDir
if [ -z "${dontUseZigConfigure-}" ] && [ -z "${configurePhase-}" ]; then
  configurePhase=zigConfigurePhase
fi

if [ -z "${dontUseZigBuild-}" ] && [ -z "${buildPhase-}" ]; then
  buildPhase=zigBuildPhase