mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
Don't allow flake inputs to have both a flakeref and a follows
Having both doesn't make sense so it's best to disallow it. If this causes issues we could turn into a warning.
This commit is contained in:
parent
637c4f3ad7
commit
b415faceca
2 changed files with 15 additions and 1 deletions
|
@ -170,6 +170,9 @@ static FlakeInput parseFlakeInput(
|
|||
input.ref = parseFlakeRef(state.fetchSettings, *url, {}, true, input.isFlake, true);
|
||||
}
|
||||
|
||||
if (input.ref && input.follows)
|
||||
throw Error("flake input has both a flake reference and a follows attribute, at %s", state.positions[pos]);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,6 @@ EOF
|
|||
cat <<EOF > $flakeFollowsB/flake.nix
|
||||
{
|
||||
inputs.C.url = "path:nosuchflake";
|
||||
inputs.D.url = "path:nosuchflake";
|
||||
inputs.D.follows = "C/D";
|
||||
outputs = _: {};
|
||||
}
|
||||
|
@ -419,3 +418,15 @@ EOF
|
|||
nix flake lock $flakeFollowsA --recreate-lock-file
|
||||
|
||||
[[ $(jq -c .nodes.B.inputs.D $flakeFollowsA/flake.lock) = '["B","C","D"]' ]]
|
||||
|
||||
# Check that you can't have both a flakeref and a follows attribute on an input.
|
||||
cat <<EOF > $flakeFollowsB/flake.nix
|
||||
{
|
||||
inputs.C.url = "path:nosuchflake";
|
||||
inputs.D.url = "path:nosuchflake";
|
||||
inputs.D.follows = "C/D";
|
||||
outputs = _: {};
|
||||
}
|
||||
EOF
|
||||
|
||||
expectStderr 1 nix flake lock $flakeFollowsA --recreate-lock-file | grepQuiet "flake input has both a flake reference and a follows attribute"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue