Skip to content

Commit 0a1f6f5

Browse files
committed
Set all Nix builder runtime vars for devx wrapper outside builds
setup.sh runs with set -eu and expects NIX_BUILD_TOP, TMPDIR, out, and other variables that the Nix builder sets at runtime. The previous fix only set $out; NIX_BUILD_TOP was the next failure. Set all required builder runtime variables (NIX_BUILD_TOP, TMPDIR, TMP, TEMP, TEMPDIR, NIX_STORE, out) in both mkEnvScript and the CI validate step. Verified locally on hydra: both static (ghc96-static-env) and dynamic (ghc98-minimal-env) wrappers work correctly.
1 parent a8f218f commit 0a1f6f5

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

.github/workflows/pr-validate.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ jobs:
104104
echo "Cabal: $(cabal --version 2>/dev/null | head -1 || echo N/A)"
105105
TESTEOF
106106
107-
# stdenv's setup.sh requires $out for output variable assignment.
108-
# Inside a Nix build $out is set automatically; when running
109-
# directly we must provide a dummy value.
110-
export out=$(mktemp -d)
107+
# stdenv's setup.sh expects Nix builder runtime variables
108+
# (NIX_BUILD_TOP, out, etc.) that only exist inside nix build.
109+
# Provide them so the devx wrapper can source setup.sh.
110+
export NIX_BUILD_TOP="$(mktemp -d)"
111+
export TMPDIR="$NIX_BUILD_TOP"
112+
export TMP="$NIX_BUILD_TOP"
113+
export TEMP="$NIX_BUILD_TOP"
114+
export TEMPDIR="$NIX_BUILD_TOP"
115+
export NIX_STORE="/nix/store"
116+
export out="$NIX_BUILD_TOP/out"
117+
mkdir -p "$out"
111118
"$DEVX_PATH" "$SMOKE_TEST"
112119
echo "::endgroup::"
113120

flake.nix

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,18 @@
349349
# attributes needed to initialize the full dev environment.
350350
${envExports}
351351
352-
# setup.sh requires $out for output variable assignment
353-
# (_assignFirst). Inside a Nix build $out is set by the
354-
# builder; when running directly (container, CLI) we
355-
# provide a temporary directory so setup.sh succeeds.
356-
if [ -z "''${out:-}" ]; then
357-
export out=$(mktemp -d)
352+
# setup.sh expects Nix builder runtime variables that are
353+
# only set inside `nix build`. When running directly
354+
# (container, CI, CLI) we provide sensible defaults.
355+
if [ -z "''${NIX_BUILD_TOP:-}" ]; then
356+
export NIX_BUILD_TOP="$(mktemp -d)"
357+
export TMPDIR="$NIX_BUILD_TOP"
358+
export TMP="$NIX_BUILD_TOP"
359+
export TEMP="$NIX_BUILD_TOP"
360+
export TEMPDIR="$NIX_BUILD_TOP"
361+
export NIX_STORE="/nix/store"
362+
export out="$NIX_BUILD_TOP/out"
363+
mkdir -p "$out"
358364
fi
359365
360366
# Source stdenv's setup.sh to initialize the development

0 commit comments

Comments
 (0)