aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Kenigsberg <matthewkenigsberg@gmail.com>2020-04-27 11:12:54 -0600
committerMatthew Kenigsberg <matthewkenigsberg@gmail.com>2020-04-27 11:22:20 -0600
commita3bc695e7dd60a0f1860942ba0343572b85e05e4 (patch)
treefb60d52aa7be73afebf5f86865e1143d386f72d4
parentc9d0cf7e02d4b3af3c027d7d74d5caa3c8963d26 (diff)
Set GCROOT to store path to prevent garbage collection
-rw-r--r--src/nix/shell.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nix/shell.cc b/src/nix/shell.cc
index 71e640667..bd07104cf 100644
--- a/src/nix/shell.cc
+++ b/src/nix/shell.cc
@@ -200,13 +200,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};
}
};
@@ -253,7 +255,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");
@@ -276,6 +278,7 @@ struct CmdDevShell : Common, MixEnvironment
auto shell = getEnv("SHELL").value_or("bash");
setEnviron();
+ setenv("GCROOT", gcroot.data(), 1);
auto args = Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath};
@@ -307,7 +310,7 @@ struct CmdPrintDevEnv : Common
void run(ref<Store> store) override
{
- auto buildEnvironment = getBuildEnvironment(store);
+ auto buildEnvironment = getBuildEnvironment(store).first;
stopProgressBar();