diff --git a/lix/nix/develop.cc b/lix/nix/develop.cc index 264286e0c..1dd8eb0d6 100644 --- a/lix/nix/develop.cc +++ b/lix/nix/develop.cc @@ -364,6 +364,9 @@ struct Common : InstallableCommand, MixProfile out << fmt("%s=\"$%s${nix_saved_%s:+:$nix_saved_%s}\"\n", var, var, var, var); out << "export NIX_BUILD_TOP=\"$(mktemp -d -t nix-shell.XXXXXX)\"\n"; + // We re-export similarly to what occurs inside of a derivation goal `NIX_LOG_FD` to stderr. + // So that stdenv hooks that logs information can be observed inside this debugging tool. + out << "export NIX_LOG_FD=2\n"; for (auto & i : {"TMP", "TMPDIR", "TEMP", "TEMPDIR"}) out << fmt("export %s=\"$NIX_BUILD_TOP\"\n", i); diff --git a/tests/functional/nix-shell/basic.sh b/tests/functional/nix-shell/basic.sh index 784eb2617..d9ecb3432 100644 --- a/tests/functional/nix-shell/basic.sh +++ b/tests/functional/nix-shell/basic.sh @@ -173,6 +173,9 @@ shellDrv=$(nix-instantiate "$shellDotNix" -A shellDrv.out) nix develop $shellDrv -c bash -c '[[ -n $stdenv ]]' +# Test $NIX_LOG_FD +expectStderr 0 nix develop $shellDrv -c bash -c 'echo hello > $NIX_LOG_FD' |& grepQuiet 'hello' + nix print-dev-env $shellDrv > $TEST_ROOT/dev-env2.sh nix print-dev-env $shellDrv --json > $TEST_ROOT/dev-env2.json