use flake's nixpkgs to find bashInteractive

This commit is contained in:
Matthew Kenigsberg 2020-05-05 10:49:39 -06:00
parent 8fbc8540d3
commit 04821bc171
3 changed files with 20 additions and 2 deletions

View file

@ -286,9 +286,8 @@ struct CmdDevShell : Common, MixEnvironment
std::string getBashPath(ref<Store> store) std::string getBashPath(ref<Store> store)
{ {
auto flakeRef = FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}});
auto state = getEvalState(); auto state = getEvalState();
auto lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, flakeRef, lockFlags)); auto lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, installable->nixpkgsFlakeRef(), lockFlags));
auto cache = openEvalCache(*state, lockedFlake, true); auto cache = openEvalCache(*state, lockedFlake, true);
auto root = cache->getRoot(); auto root = cache->getRoot();

View file

@ -493,6 +493,18 @@ InstallableFlake::getCursor(EvalState & state, bool useEvalCache)
return res; return res;
} }
FlakeRef InstallableFlake::nixpkgsFlakeRef() const
{
auto lockedFlake = lockFlake(*(cmd.getEvalState()), flakeRef, cmd.lockFlags);
auto nixpkgsInput = lockedFlake.flake.inputs.find("nixpkgs");
if (nixpkgsInput != lockedFlake.flake.inputs.end()) {
return std::move(nixpkgsInput->second.ref);
}
return Installable::nixpkgsFlakeRef();
}
std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables( std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
ref<Store> store, std::vector<std::string> ss) ref<Store> store, std::vector<std::string> ss)
{ {

View file

@ -57,6 +57,11 @@ struct Installable
virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>> virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
getCursor(EvalState & state, bool useEvalCache); getCursor(EvalState & state, bool useEvalCache);
virtual FlakeRef nixpkgsFlakeRef() const
{
return std::move(FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}}));
}
}; };
struct InstallableValue : Installable struct InstallableValue : Installable
@ -104,6 +109,8 @@ struct InstallableFlake : InstallableValue
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>> std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
getCursor(EvalState & state, bool useEvalCache) override; getCursor(EvalState & state, bool useEvalCache) override;
FlakeRef nixpkgsFlakeRef() const override;
}; };
ref<eval_cache::EvalCache> openEvalCache( ref<eval_cache::EvalCache> openEvalCache(