diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-04-29 13:32:27 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-04-29 13:32:27 +0200 |
commit | 5ada0831cfe1c8afb44bd9905901818696caaffa (patch) | |
tree | 8931c23148362d7f6ffff607b9bc5442af1a0abb /src/nix/shell.cc | |
parent | 6521c92ce8289a5f9e959c6789ab24dacdad082e (diff) | |
parent | 06849c3090615d85dbba17b674e97dff71bd41bc (diff) |
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/nix/shell.cc')
-rw-r--r-- | src/nix/shell.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nix/shell.cc b/src/nix/shell.cc index 439ef02ed..b0710906b 100644 --- a/src/nix/shell.cc +++ b/src/nix/shell.cc @@ -205,13 +205,15 @@ struct Common : InstallableCommand, MixProfile } } - BuildEnvironment getBuildEnvironment(ref<Store> store) + std::pair<BuildEnvironment, std::string> getBuildEnvironment(ref<Store> store) { auto shellOutPath = getShellOutPath(store); + auto strPath = store->printStorePath(shellOutPath); + updateProfile(shellOutPath); - return readEnvironment(store->printStorePath(shellOutPath)); + return {readEnvironment(strPath), strPath}; } }; @@ -262,7 +264,7 @@ struct CmdDevShell : Common, MixEnvironment void run(ref<Store> store) override { - auto buildEnvironment = getBuildEnvironment(store); + auto [buildEnvironment, gcroot] = getBuildEnvironment(store); auto [rcFileFd, rcFilePath] = createTempFile("nix-shell"); @@ -285,6 +287,8 @@ struct CmdDevShell : Common, MixEnvironment auto shell = getEnv("SHELL").value_or("bash"); setEnviron(); + // prevent garbage collection until shell exits + setenv("NIX_GCROOT", gcroot.data(), 1); auto args = Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath}; @@ -316,7 +320,7 @@ struct CmdPrintDevEnv : Common void run(ref<Store> store) override { - auto buildEnvironment = getBuildEnvironment(store); + auto buildEnvironment = getBuildEnvironment(store).first; stopProgressBar(); |