mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Merge pull request #2323 from samueldr/feature/selective-impurity
Allows selectively adding environment variables to pure shells.
This commit is contained in:
commit
122e1a61f8
3 changed files with 21 additions and 1 deletions
|
@ -98,6 +98,9 @@ void mainWrapped(int argc, char * * argv)
|
|||
|
||||
std::string outLink = "./result";
|
||||
|
||||
// List of environment variables kept for --pure
|
||||
std::set<string> keepVars{"HOME", "USER", "LOGNAME", "DISPLAY", "PATH", "TERM", "IN_NIX_SHELL", "TZ", "PAGER", "NIX_BUILD_SHELL", "SHLVL"};
|
||||
|
||||
Strings args;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
args.push_back(argv[i]);
|
||||
|
@ -217,6 +220,9 @@ void mainWrapped(int argc, char * * argv)
|
|||
}
|
||||
}
|
||||
|
||||
else if (*arg == "--keep")
|
||||
keepVars.insert(getArg(*arg, arg, end));
|
||||
|
||||
else if (*arg == "-")
|
||||
readStdin = true;
|
||||
|
||||
|
@ -367,7 +373,6 @@ void mainWrapped(int argc, char * * argv)
|
|||
auto tmp = getEnv("TMPDIR", getEnv("XDG_RUNTIME_DIR", "/tmp"));
|
||||
|
||||
if (pure) {
|
||||
std::set<string> keepVars{"HOME", "USER", "LOGNAME", "DISPLAY", "PATH", "TERM", "IN_NIX_SHELL", "TZ", "PAGER", "NIX_BUILD_SHELL", "SHLVL"};
|
||||
decltype(env) newEnv;
|
||||
for (auto & i : env)
|
||||
if (keepVars.count(i.first))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue