diff options
author | Matthew Kenigsberg <matthewkenigsberg@gmail.com> | 2020-05-05 10:49:39 -0600 |
---|---|---|
committer | Matthew Kenigsberg <matthewkenigsberg@gmail.com> | 2020-05-16 11:03:06 -0600 |
commit | 04821bc1718aff975b51e98ce7bfb91888167c6d (patch) | |
tree | 78df7c3e87148379eb5c890d690e15454309d2c8 | |
parent | 8fbc8540d3ea540d985b577166a1168d472c2d70 (diff) |
use flake's nixpkgs to find bashInteractive
-rw-r--r-- | src/nix/dev-shell.cc | 3 | ||||
-rw-r--r-- | src/nix/installables.cc | 12 | ||||
-rw-r--r-- | src/nix/installables.hh | 7 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/nix/dev-shell.cc b/src/nix/dev-shell.cc index d842be79f..b3314021f 100644 --- a/src/nix/dev-shell.cc +++ b/src/nix/dev-shell.cc @@ -286,9 +286,8 @@ struct CmdDevShell : Common, MixEnvironment std::string getBashPath(ref<Store> store) { - auto flakeRef = FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}}); 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 root = cache->getRoot(); diff --git a/src/nix/installables.cc b/src/nix/installables.cc index cae85b34e..4e38876ca 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -493,6 +493,18 @@ InstallableFlake::getCursor(EvalState & state, bool useEvalCache) 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( ref<Store> store, std::vector<std::string> ss) { diff --git a/src/nix/installables.hh b/src/nix/installables.hh index 531720de6..57e3d6c8e 100644 --- a/src/nix/installables.hh +++ b/src/nix/installables.hh @@ -57,6 +57,11 @@ struct Installable virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>> getCursor(EvalState & state, bool useEvalCache); + + virtual FlakeRef nixpkgsFlakeRef() const + { + return std::move(FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}})); + } }; struct InstallableValue : Installable @@ -104,6 +109,8 @@ struct InstallableFlake : InstallableValue std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>> getCursor(EvalState & state, bool useEvalCache) override; + + FlakeRef nixpkgsFlakeRef() const override; }; ref<eval_cache::EvalCache> openEvalCache( |