diff options
author | Matthew Kenigsberg <matthewkenigsberg@gmail.com> | 2020-05-12 23:45:45 -0600 |
---|---|---|
committer | Matthew Kenigsberg <matthewkenigsberg@gmail.com> | 2020-05-16 11:03:06 -0600 |
commit | 085879360415a2c667c6d75dce5765f01afbb25d (patch) | |
tree | 09fd01a06b29ce61d792473fe872cccfe29aad10 /src/nix/installables.cc | |
parent | 04821bc1718aff975b51e98ce7bfb91888167c6d (diff) |
Call lockFlake once and store in _lockedFlake
Diffstat (limited to 'src/nix/installables.cc')
-rw-r--r-- | src/nix/installables.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 4e38876ca..21fd54f64 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -408,8 +408,7 @@ ref<eval_cache::EvalCache> openEvalCache( std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation() { - auto lockedFlake = std::make_shared<flake::LockedFlake>( - lockFlake(*state, flakeRef, lockFlags)); + auto lockedFlake = getLockedFlake(); auto cache = openEvalCache(*state, lockedFlake, true); auto root = cache->getRoot(); @@ -455,9 +454,9 @@ std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations() std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state) { - auto lockedFlake = lockFlake(state, flakeRef, lockFlags); + auto lockedFlake = getLockedFlake(); - auto vOutputs = getFlakeOutputs(state, lockedFlake); + auto vOutputs = getFlakeOutputs(state, *lockedFlake); auto emptyArgs = state.allocBindings(0); @@ -493,12 +492,19 @@ InstallableFlake::getCursor(EvalState & state, bool useEvalCache) return res; } +std::shared_ptr<flake::LockedFlake> InstallableFlake::getLockedFlake() const +{ + if (!_lockedFlake) + _lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, flakeRef, lockFlags)); + return _lockedFlake; +} + FlakeRef InstallableFlake::nixpkgsFlakeRef() const { - auto lockedFlake = lockFlake(*(cmd.getEvalState()), flakeRef, cmd.lockFlags); + auto lockedFlake = getLockedFlake(); - auto nixpkgsInput = lockedFlake.flake.inputs.find("nixpkgs"); - if (nixpkgsInput != lockedFlake.flake.inputs.end()) { + auto nixpkgsInput = lockedFlake->flake.inputs.find("nixpkgs"); + if (nixpkgsInput != lockedFlake->flake.inputs.end()) { return std::move(nixpkgsInput->second.ref); } |