Fix nix print-dev-env & nix develop with drv paths
Fixes #8309 This regression was because both `CmdDevelop` and `CmdPrintDevEnv` were switched to be `InstallableValueCommand` subclasses, but actually neither should have been. The `nixpkgsFlakeRef` method should indeed not be on the base installable class, because "flake refs" and "nixpkgs" are not installable-wide notions, but that doesn't mean these commands should only accept installable values.
This commit is contained in:
+10
-6
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user