aboutsummaryrefslogtreecommitdiff
path: root/src/nix/develop.cc
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-07-16 13:32:28 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-07-16 13:32:28 -0400
commit048e916f6477acc7e57e1d85e832d3efb42ad3f6 (patch)
tree3261da4d301fc6bd9df375a8bab3a4a555dc6199 /src/nix/develop.cc
parent886c91dfcc462d157dc2ce5265800e98d1bc45dd (diff)
parent16c9f6762d082155b967710a5fd3a095937d76ba (diff)
Merge branch 'master' of github.com:NixOS/nix into optional-derivation-output-storepath
Diffstat (limited to 'src/nix/develop.cc')
-rw-r--r--src/nix/develop.cc37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 654f62f38..2f590f53f 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -130,7 +130,9 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
drvName += "-env";
for (auto & output : drv.outputs)
drv.env.erase(output.first);
+ drv.outputs = {{"out", DerivationOutput { .output = DerivationOutputInputAddressed { .path = StorePath::dummy }}}};
drv.env["out"] = "";
+ drv.env["_outputs_saved"] = drv.env["outputs"];
drv.env["outputs"] = "out";
drv.inputSrcs.insert(std::move(getEnvShPath));
Hash h = hashDerivationModulo(*store, drv, true);
@@ -203,6 +205,11 @@ struct Common : InstallableCommand, MixProfile
out << "eval \"$shellHook\"\n";
}
+ Strings getDefaultFlakeAttrPaths() override
+ {
+ return {"devShell." + settings.thisSystem.get(), "defaultPackage." + settings.thisSystem.get()};
+ }
+
StorePath getShellOutPath(ref<Store> store)
{
auto path = installable->getStorePath();
@@ -261,11 +268,15 @@ struct CmdDevelop : Common, MixEnvironment
return {
Example{
"To get the build environment of GNU hello:",
- "nix develop nixpkgs.hello"
+ "nix develop nixpkgs#hello"
+ },
+ Example{
+ "To get the build environment of the default package of flake in the current directory:",
+ "nix develop"
},
Example{
"To store the build environment in a profile:",
- "nix develop --profile /tmp/my-shell nixpkgs.hello"
+ "nix develop --profile /tmp/my-shell nixpkgs#hello"
},
Example{
"To use a build environment previously recorded in a profile:",
@@ -296,12 +307,28 @@ struct CmdDevelop : Common, MixEnvironment
stopProgressBar();
- auto shell = getEnv("SHELL").value_or("bash");
-
setEnviron();
// prevent garbage collection until shell exits
setenv("NIX_GCROOT", gcroot.data(), 1);
+ Path shell = "bash";
+
+ try {
+ auto state = getEvalState();
+
+ auto bashInstallable = std::make_shared<InstallableFlake>(
+ state,
+ std::move(installable->nixpkgsFlakeRef()),
+ Strings{"bashInteractive"},
+ Strings{"legacyPackages." + settings.thisSystem.get() + "."},
+ lockFlags);
+
+ shell = state->store->printStorePath(
+ toStorePath(state->store, Realise::Outputs, OperateOn::Output, bashInstallable)) + "/bin/bash";
+ } catch (Error &) {
+ ignoreException();
+ }
+
auto args = Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath};
restoreAffinity();
@@ -325,7 +352,7 @@ struct CmdPrintDevEnv : Common
return {
Example{
"To apply the build environment of GNU hello to the current shell:",
- ". <(nix print-dev-env nixpkgs.hello)"
+ ". <(nix print-dev-env nixpkgs#hello)"
},
};
}