aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-08-03 16:58:18 +0200
committerGitHub <noreply@github.com>2018-08-03 16:58:18 +0200
commit122e1a61f8deb55a38a00534c502fd8c6700d539 (patch)
treec6a83d4db01d2c692f44904892cfd3c2b80fcbce /src/nix-build
parent49a53c1d3f77ff33e14a95d004a6ce0720293997 (diff)
parent438e02529dfb4b26603e2a06992df977cd80ecd9 (diff)
Merge pull request #2323 from samueldr/feature/selective-impurity
Allows selectively adding environment variables to pure shells.
Diffstat (limited to 'src/nix-build')
-rwxr-xr-xsrc/nix-build/nix-build.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 35ad98731..34f1cba9d 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -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))