nix dev-shell: Less purity

This commit is contained in:
Eelco Dolstra 2019-05-02 21:28:52 +02:00
parent 8ec77614f6
commit 7ba0f98e64

View file

@ -124,6 +124,7 @@ struct Common : InstallableCommand
std::set<string> ignoreVars{ std::set<string> ignoreVars{
"BASHOPTS", "BASHOPTS",
"EUID", "EUID",
"HOME", // FIXME: don't ignore in pure mode?
"NIX_BUILD_TOP", "NIX_BUILD_TOP",
"NIX_ENFORCE_PURITY", "NIX_ENFORCE_PURITY",
"PPID", "PPID",
@ -134,11 +135,15 @@ struct Common : InstallableCommand
"TEMPDIR", "TEMPDIR",
"TMP", "TMP",
"TMPDIR", "TMPDIR",
"TZ",
"UID", "UID",
}; };
void makeRcScript(const BuildEnvironment & buildEnvironment, std::ostream & out) void makeRcScript(const BuildEnvironment & buildEnvironment, std::ostream & out)
{ {
out << "export IN_NIX_SHELL=1\n";
out << "nix_saved_PATH=\"$PATH\"\n";
for (auto & i : buildEnvironment.env) { for (auto & i : buildEnvironment.env) {
// FIXME: shellEscape // FIXME: shellEscape
// FIXME: figure out what to export // FIXME: figure out what to export
@ -147,6 +152,8 @@ struct Common : InstallableCommand
out << fmt("export %s=%s\n", i.first, i.second); out << fmt("export %s=%s\n", i.first, i.second);
} }
out << "PATH=\"$PATH:$nix_saved_PATH\"\n";
for (auto & i : buildEnvironment.functions) { for (auto & i : buildEnvironment.functions) {
out << fmt("%s () {\n%s\n}\n", i.first, i.second); out << fmt("%s () {\n%s\n}\n", i.first, i.second);
} }