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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user