1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-25 19:51:00 +01:00

Move getAccessorCached() to InputCache

Also, make fetchTree use InputCache.
This commit is contained in:
Eelco Dolstra 2025-04-09 23:06:03 +02:00
parent 3bbf917707
commit dd15c8a20d
4 changed files with 70 additions and 66 deletions

View file

@ -10,6 +10,7 @@
#include "nix/util/url.hh"
#include "nix/expr/value-to-json.hh"
#include "nix/fetchers/fetch-to-store.hh"
#include "nix/fetchers/input-cache.hh"
#include "nix/util/mounted-source-accessor.hh"
#include <nlohmann/json.hpp>
@ -201,16 +202,15 @@ static void fetchTree(
throw Error("input '%s' is not allowed to use the '__final' attribute", input.to_string());
}
// FIXME: use fetchOrSubstituteTree().
auto [accessor, lockedInput] = input.getAccessor(state.store);
auto cachedInput = fetchers::InputCache::getCache()->getAccessor(state.store, input, false);
auto storePath = StorePath::random(input.getName());
state.allowPath(storePath);
state.storeFS->mount(CanonPath(state.store->printStorePath(storePath)), accessor);
state.storeFS->mount(CanonPath(state.store->printStorePath(storePath)), cachedInput.accessor);
emitTreeAttrs(state, storePath, lockedInput, v, params.emptyRevFallback, false);
emitTreeAttrs(state, storePath, cachedInput.lockedInput, v, params.emptyRevFallback, false);
}
static void prim_fetchTree(EvalState & state, const PosIdx pos, Value * * args, Value & v)