mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #13934 from DeterminateSystems/fix-flake-registry-ignoring-dir-param-upstreaming
Fix flake registry ignoring `dir` parameter
This commit is contained in:
commit
12db0726e9
4 changed files with 25 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ struct InputCache
|
|||
ref<SourceAccessor> accessor;
|
||||
Input resolvedInput;
|
||||
Input lockedInput;
|
||||
Attrs extraAttrs;
|
||||
};
|
||||
|
||||
CachedResult getAccessor(ref<Store> store, const Input & originalInput, UseRegistries useRegistries);
|
||||
|
|
@ -19,6 +20,7 @@ struct InputCache
|
|||
{
|
||||
Input lockedInput;
|
||||
ref<SourceAccessor> accessor;
|
||||
Attrs extraAttrs;
|
||||
};
|
||||
|
||||
virtual std::optional<CachedInput> lookup(const Input & originalInput) const = 0;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegist
|
|||
fetched = lookup(resolvedInput);
|
||||
if (!fetched) {
|
||||
auto [accessor, lockedInput] = resolvedInput.getAccessor(store);
|
||||
fetched.emplace(CachedInput{.lockedInput = lockedInput, .accessor = accessor});
|
||||
fetched.emplace(
|
||||
CachedInput{.lockedInput = lockedInput, .accessor = accessor, .extraAttrs = extraAttrs});
|
||||
}
|
||||
upsert(resolvedInput, *fetched);
|
||||
} else {
|
||||
|
|
@ -36,7 +37,7 @@ InputCache::getAccessor(ref<Store> store, const Input & originalInput, UseRegist
|
|||
|
||||
debug("got tree '%s' from '%s'", fetched->accessor, fetched->lockedInput.to_string());
|
||||
|
||||
return {fetched->accessor, resolvedInput, fetched->lockedInput};
|
||||
return {fetched->accessor, resolvedInput, fetched->lockedInput, fetched->extraAttrs};
|
||||
}
|
||||
|
||||
struct InputCacheImpl : InputCache
|
||||
|
|
|
|||
|
|
@ -341,8 +341,9 @@ static Flake getFlake(
|
|||
// Fetch a lazy tree first.
|
||||
auto cachedInput = state.inputCache->getAccessor(state.store, originalRef.input, useRegistries);
|
||||
|
||||
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), originalRef.subdir);
|
||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), originalRef.subdir);
|
||||
auto subdir = fetchers::maybeGetStrAttr(cachedInput.extraAttrs, "dir").value_or(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.
|
||||
auto flake = readFlake(state, originalRef, resolvedRef, lockedRef, {cachedInput.accessor}, lockRootAttrPath);
|
||||
|
|
|
|||
|
|
@ -470,3 +470,20 @@ cat > "$flake3Dir/flake.nix" <<EOF
|
|||
EOF
|
||||
|
||||
[[ "$(nix flake metadata --json "$flake3Dir" | jq -r .locks.nodes.flake1.locked.rev)" = $prevFlake1Rev ]]
|
||||
|
||||
baseDir=$TEST_ROOT/$RANDOM
|
||||
subdirFlakeDir=$baseDir/foo
|
||||
mkdir -p "$subdirFlakeDir"
|
||||
|
||||
writeSimpleFlake "$baseDir"
|
||||
|
||||
cat > "$subdirFlakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: {
|
||||
shouldBeOne = 1;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
nix registry add --registry "$registry" flake2 "path:$baseDir?dir=foo"
|
||||
[[ "$(nix eval --flake-registry "$registry" flake2#shouldBeOne)" = 1 ]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue