Fixes fj#940. When running `nix-shell`, the `$NIX_BUILD_TOP` environment variable is set to `$TMPDIR` or `/tmp`. nixpkgs stdenv uses $NIX_BUILD_TOP to create `$NIX_BUILD_TOP/env-vars` which contains all the environment variables set by stdenv. This is used for debugging purposes in combination with `--keep-failed` to reload the bash environment of a derivation. `$TMPDIR` is often unset, therefore, `/tmp/env-vars` was constantly being created. On a multi-user system or, when you run Lix as root, you might create a `/tmp/env-vars` with different permission bits. As a result, `nix-shell` can cease to function because that file will fail creation for an unprivileged user for example. fj#940 rightfully remark that the code is not consistent between nix3-develop and nix-shell and it should be reworked. Change-Id: Iddf15945385d8bd497b2800b37fee5e1f97689b7 Signed-off-by: Raito Bezarius <raito@lix.systems>
661 B
661 B
synopsis, cls, issues, category, credits
| synopsis | cls | issues | category | credits | ||
|---|---|---|---|---|---|---|
| `nix-shell` default shell directory is not `/tmp` anymore for `$NIX_BUILD_TOP` |
|
Fixes |
|
Previously, Lix nix-shells could exit non-zero status when stdenv's dumpVars phase failed to write to $NIX_BUILD_TOP/env-vars, despite dumpVars being intended as a debugging aid.
This happens when TMPDIR is not set and defaults therefore to /tmp, resulting in a /tmp/env-vars global file that every nix-shell wants to write.
We fix this issue by reusing a pre-created, unique, and writable location, as the build top directory, avoiding shell exiting from write failures silently.