mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
parent
258d41bfb6
commit
bccdb95a86
3 changed files with 8 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ struct InputCache
|
||||||
ref<SourceAccessor> accessor;
|
ref<SourceAccessor> accessor;
|
||||||
Input resolvedInput;
|
Input resolvedInput;
|
||||||
Input lockedInput;
|
Input lockedInput;
|
||||||
|
Attrs extraAttrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
CachedResult getAccessor(ref<Store> store, const Input & originalInput, UseRegistries useRegistries);
|
CachedResult getAccessor(ref<Store> store, const Input & originalInput, UseRegistries useRegistries);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace nix::fetchers {
|
||||||
InputCache::CachedResult
|
InputCache::CachedResult
|
||||||
InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegistries useRegistries)
|
InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegistries useRegistries)
|
||||||
{
|
{
|
||||||
|
Attrs extraAttrs;
|
||||||
auto fetched = lookup(originalInput);
|
auto fetched = lookup(originalInput);
|
||||||
Input resolvedInput = originalInput;
|
Input resolvedInput = originalInput;
|
||||||
|
|
||||||
|
|
@ -17,7 +18,8 @@ InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegist
|
||||||
fetched.emplace(CachedInput{.lockedInput = lockedInput, .accessor = accessor});
|
fetched.emplace(CachedInput{.lockedInput = lockedInput, .accessor = accessor});
|
||||||
} else {
|
} else {
|
||||||
if (useRegistries != UseRegistries::No) {
|
if (useRegistries != UseRegistries::No) {
|
||||||
auto [res, extraAttrs] = lookupInRegistries(store, originalInput, useRegistries);
|
auto [res, extraAttrs_] = lookupInRegistries(store, originalInput, useRegistries);
|
||||||
|
extraAttrs = extraAttrs_;
|
||||||
resolvedInput = std::move(res);
|
resolvedInput = std::move(res);
|
||||||
fetched = lookup(resolvedInput);
|
fetched = lookup(resolvedInput);
|
||||||
if (!fetched) {
|
if (!fetched) {
|
||||||
|
|
@ -36,7 +38,7 @@ InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegist
|
||||||
|
|
||||||
debug("got tree '%s' from '%s'", fetched->accessor, fetched->lockedInput.to_string());
|
debug("got tree '%s' from '%s'", fetched->accessor, fetched->lockedInput.to_string());
|
||||||
|
|
||||||
return {fetched->accessor, resolvedInput, fetched->lockedInput};
|
return {fetched->accessor, resolvedInput, fetched->lockedInput, extraAttrs};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InputCacheImpl : InputCache
|
struct InputCacheImpl : InputCache
|
||||||
|
|
|
||||||
|
|
@ -341,8 +341,9 @@ static Flake getFlake(
|
||||||
// Fetch a lazy tree first.
|
// Fetch a lazy tree first.
|
||||||
auto cachedInput = state.inputCache->getAccessor(state.store, originalRef.input, useRegistries);
|
auto cachedInput = state.inputCache->getAccessor(state.store, originalRef.input, useRegistries);
|
||||||
|
|
||||||
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), originalRef.subdir);
|
auto subdir = fetchers::maybeGetStrAttr(cachedInput.extraAttrs, "dir").value_or(originalRef.subdir);
|
||||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), originalRef.subdir);
|
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), subdir);
|
||||||
|
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), subdir);
|
||||||
|
|
||||||
// Parse/eval flake.nix to get at the input.self attributes.
|
// Parse/eval flake.nix to get at the input.self attributes.
|
||||||
auto flake = readFlake(state, originalRef, resolvedRef, lockedRef, {cachedInput.accessor}, lockRootAttrPath);
|
auto flake = readFlake(state, originalRef, resolvedRef, lockedRef, {cachedInput.accessor}, lockRootAttrPath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue