aboutsummaryrefslogtreecommitdiff
path: root/src/nix/develop.cc
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-05-10 18:01:29 +0200
committerGitHub <noreply@github.com>2023-05-10 18:01:29 +0200
commitf60b21563990ec11d87dd4abe57b8b187d6b6fb3 (patch)
treec199184cb8c31b16d14f9f8ca8659e4d772028d8 /src/nix/develop.cc
parent53a1354acfa9a3d7e0a6c3914ff3c53115d4c452 (diff)
parenta93110ab19085eeda1b4244fef49d18f91a1d7b8 (diff)
Merge pull request #8310 from obsidiansystems/fix-8141
Fix `nix print-dev-env` & `nix develop` with drv paths
Diffstat (limited to 'src/nix/develop.cc')
-rw-r--r--src/nix/develop.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 9e2dcff61..195eeaa21 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -252,7 +252,7 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
throw Error("get-env.sh failed to produce an environment");
}
-struct Common : InstallableValueCommand, MixProfile
+struct Common : InstallableCommand, MixProfile
{
std::set<std::string> ignoreVars{
"BASHOPTS",
@@ -374,7 +374,7 @@ struct Common : InstallableValueCommand, MixProfile
return res;
}
- StorePath getShellOutPath(ref<Store> store, ref<InstallableValue> installable)
+ StorePath getShellOutPath(ref<Store> store, ref<Installable> installable)
{
auto path = installable->getStorePath();
if (path && hasSuffix(path->to_string(), "-env"))
@@ -393,7 +393,7 @@ struct Common : InstallableValueCommand, MixProfile
}
std::pair<BuildEnvironment, std::string>
- getBuildEnvironment(ref<Store> store, ref<InstallableValue> installable)
+ getBuildEnvironment(ref<Store> store, ref<Installable> installable)
{
auto shellOutPath = getShellOutPath(store, installable);
@@ -481,7 +481,7 @@ struct CmdDevelop : Common, MixEnvironment
;
}
- void run(ref<Store> store, ref<InstallableValue> installable) override
+ void run(ref<Store> store, ref<Installable> installable) override
{
auto [buildEnvironment, gcroot] = getBuildEnvironment(store, installable);
@@ -538,10 +538,14 @@ struct CmdDevelop : Common, MixEnvironment
nixpkgsLockFlags.inputOverrides = {};
nixpkgsLockFlags.inputUpdates = {};
+ auto nixpkgs = defaultNixpkgsFlakeRef();
+ if (auto * i = dynamic_cast<const InstallableFlake *>(&*installable))
+ nixpkgs = i->nixpkgsFlakeRef();
+
auto bashInstallable = make_ref<InstallableFlake>(
this,
state,
- installable->nixpkgsFlakeRef(),
+ std::move(nixpkgs),
"bashInteractive",
DefaultOutputs(),
Strings{},
@@ -605,7 +609,7 @@ struct CmdPrintDevEnv : Common, MixJSON
Category category() override { return catUtility; }
- void run(ref<Store> store, ref<InstallableValue> installable) override
+ void run(ref<Store> store, ref<Installable> installable) override
{
auto buildEnvironment = getBuildEnvironment(store, installable).first;