aboutsummaryrefslogtreecommitdiff
path: root/src/nix/develop.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-07-14 16:15:37 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-07-14 16:15:37 -0400
commit6cafe308c946af7658514ad0e6970cc464554fbb (patch)
tree9354e960015fda89087f15808e6573b5ae39e025 /src/nix/develop.cc
parentb585548dfee1bf12c63894c751f1449636e32565 (diff)
parentca4d5bee09df0393dd525b3cd5159a23d4683f2e (diff)
Merge remote-tracking branch 'upstream/master' into indexed-store-path-outputs
Diffstat (limited to 'src/nix/develop.cc')
-rw-r--r--src/nix/develop.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 2a3fc0213..6d9ad9942 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -276,15 +276,25 @@ struct Common : InstallableCommand, MixProfile
const BuildEnvironment & buildEnvironment,
const Path & outputsDir = absPath(".") + "/outputs")
{
+ // A list of colon-separated environment variables that should be
+ // prepended to, rather than overwritten, in order to keep the shell usable.
+ // Please keep this list minimal in order to avoid impurities.
+ static const char * const savedVars[] = {
+ "PATH", // for commands
+ "XDG_DATA_DIRS", // for loadable completion
+ };
+
std::ostringstream out;
out << "unset shellHook\n";
- out << "nix_saved_PATH=\"$PATH\"\n";
+ for (auto & var : savedVars)
+ out << fmt("nix_saved_%s=\"$%s\"\n", var, var);
buildEnvironment.toBash(out, ignoreVars);
- out << "PATH=\"$PATH:$nix_saved_PATH\"\n";
+ for (auto & var : savedVars)
+ out << fmt("%s=\"$%s:$nix_saved_%s\"\n", var, var, var);
out << "export NIX_BUILD_TOP=\"$(mktemp -d -t nix-shell.XXXXXX)\"\n";
for (auto & i : {"TMP", "TMPDIR", "TEMP", "TEMPDIR"})