mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Merge pull request #13029 from NixOS/mergify/bp/2.28-maintenance/pr-13026
Fix issue #13018, `sourceInfo` strict in `outputs` (backport #13026)
This commit is contained in:
commit
5ecbf6b9dc
2 changed files with 43 additions and 9 deletions
|
@ -14,6 +14,7 @@ overrides:
|
||||||
fetchTreeFinal:
|
fetchTreeFinal:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (builtins) mapAttrs;
|
||||||
|
|
||||||
lockFile = builtins.fromJSON lockFileStr;
|
lockFile = builtins.fromJSON lockFileStr;
|
||||||
|
|
||||||
|
@ -35,19 +36,26 @@ let
|
||||||
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
|
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
|
||||||
(builtins.tail path);
|
(builtins.tail path);
|
||||||
|
|
||||||
allNodes = builtins.mapAttrs (
|
allNodes = mapAttrs (
|
||||||
key: node:
|
key: node:
|
||||||
let
|
let
|
||||||
|
|
||||||
parentNode = allNodes.${getInputByPath lockFile.root node.parent};
|
parentNode = allNodes.${getInputByPath lockFile.root node.parent};
|
||||||
|
|
||||||
|
flakeDir =
|
||||||
|
let
|
||||||
|
dir = overrides.${key}.dir or node.locked.path or "";
|
||||||
|
parentDir = parentNode.flakeDir;
|
||||||
|
in
|
||||||
|
if node ? parent then parentDir + ("/" + dir) else dir;
|
||||||
|
|
||||||
sourceInfo =
|
sourceInfo =
|
||||||
if overrides ? ${key} then
|
if overrides ? ${key} then
|
||||||
overrides.${key}.sourceInfo
|
overrides.${key}.sourceInfo
|
||||||
else if node.locked.type == "path" && builtins.substring 0 1 node.locked.path != "/" then
|
else if node.locked.type == "path" && builtins.substring 0 1 node.locked.path != "/" then
|
||||||
parentNode.sourceInfo
|
parentNode.sourceInfo
|
||||||
// {
|
// {
|
||||||
outPath = parentNode.outPath + ("/" + node.locked.path);
|
outPath = parentNode.sourceInfo.outPath + ("/" + flakeDir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# FIXME: remove obsolete node.info.
|
# FIXME: remove obsolete node.info.
|
||||||
|
@ -60,7 +68,7 @@ let
|
||||||
|
|
||||||
flake = import (outPath + "/flake.nix");
|
flake = import (outPath + "/flake.nix");
|
||||||
|
|
||||||
inputs = builtins.mapAttrs (inputName: inputSpec: allNodes.${resolveInput inputSpec}) (
|
inputs = mapAttrs (inputName: inputSpec: allNodes.${resolveInput inputSpec}.result) (
|
||||||
node.inputs or { }
|
node.inputs or { }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -85,12 +93,17 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
if node.flake or true then
|
{
|
||||||
assert builtins.isFunction flake.outputs;
|
result =
|
||||||
result
|
if node.flake or true then
|
||||||
else
|
assert builtins.isFunction flake.outputs;
|
||||||
sourceInfo
|
result
|
||||||
|
else
|
||||||
|
sourceInfo;
|
||||||
|
|
||||||
|
inherit flakeDir sourceInfo;
|
||||||
|
}
|
||||||
) lockFile.nodes;
|
) lockFile.nodes;
|
||||||
|
|
||||||
in
|
in
|
||||||
allNodes.${lockFile.root}
|
allNodes.${lockFile.root}.result
|
||||||
|
|
|
@ -108,3 +108,24 @@ EOF
|
||||||
[[ $(nix eval "$rootFlake#z") = 90 ]]
|
[[ $(nix eval "$rootFlake#z") = 90 ]]
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nix/pull/10089#discussion_r2041984987
|
||||||
|
# https://github.com/NixOS/nix/issues/13018
|
||||||
|
mkdir -p "$TEST_ROOT/issue-13018/example"
|
||||||
|
(
|
||||||
|
cd "$TEST_ROOT/issue-13018"
|
||||||
|
git init
|
||||||
|
echo '{ outputs = _: { }; }' >flake.nix
|
||||||
|
cat >example/flake.nix <<EOF
|
||||||
|
{
|
||||||
|
inputs.parent.url = ../.;
|
||||||
|
outputs = { parent, ... }: builtins.seq parent { ok = null; };
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
git add -N .
|
||||||
|
cd example
|
||||||
|
# Important: the error does not trigger for an in-memory lock!
|
||||||
|
nix flake lock
|
||||||
|
# would fail:
|
||||||
|
nix eval .#ok
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue