diff options
-rw-r--r-- | src/libexpr/flake/flake.cc | 47 | ||||
-rw-r--r-- | tests/flakes.sh | 4 |
2 files changed, 15 insertions, 36 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 233e52407..cc9be1336 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -353,39 +353,6 @@ LockedFlake lockFlake( std::vector<FlakeRef> parents; std::function<void( - const InputPath & inputPathPrefix, - const FlakeInputs & flakeInputs - )> - checkFollowsDeclarations; - - checkFollowsDeclarations = [&]( - const InputPath & inputPathPrefix, - const FlakeInputs & flakeInputs - ) { - for (auto [inputPath, inputOverride] : overrides) { - auto inputPath2(inputPath); - auto follow = inputPath2.back(); - inputPath2.pop_back(); - if (inputPath2 == inputPathPrefix - && flakeInputs.find(follow) == flakeInputs.end() - ) { - std::string root; - for (auto & element : inputPath2) { - root.append(element); - if (element != inputPath2.back()) { - root.append(".inputs."); - } - } - warn( - "%s has a `follows'-declaration for a non-existent input %s!", - root, - follow - ); - } - } - }; - - std::function<void( const FlakeInputs & flakeInputs, std::shared_ptr<Node> node, const InputPath & inputPathPrefix, @@ -406,8 +373,6 @@ LockedFlake lockFlake( { debug("computing lock file node '%s'", printInputPath(inputPathPrefix)); - checkFollowsDeclarations(inputPathPrefix, flakeInputs); - /* Get the overrides (i.e. attributes of the form 'inputs.nixops.inputs.nixpkgs.url = ...'). */ for (auto & [id, input] : flakeInputs) { @@ -419,6 +384,18 @@ LockedFlake lockFlake( } } + /* Check whether this input has overrides for a + non-existent input. */ + for (auto [inputPath, inputOverride] : overrides) { + auto inputPath2(inputPath); + auto follow = inputPath2.back(); + inputPath2.pop_back(); + if (inputPath2 == inputPathPrefix && !flakeInputs.count(follow)) + warn( + "input '%s' has an override for a non-existent input '%s'", + printInputPath(inputPathPrefix), follow); + } + /* Go over the flake inputs, resolve/fetch them if necessary (i.e. if they're new or the flakeref changed from what's in the lock file). */ diff --git a/tests/flakes.sh b/tests/flakes.sh index 265e4a456..6574cabf1 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -877,6 +877,7 @@ cat >$flakeFollowsA/flake.nix <<EOF inputs.B = { url = "path:./flakeB"; inputs.invalid.follows = "D"; + inputs.invalid2.url = "path:./flakeD"; }; inputs.D.url = "path:./flakeD"; outputs = { ... }: {}; @@ -885,4 +886,5 @@ EOF git -C $flakeFollowsA add flake.nix -nix flake lock $flakeFollowsA 2>&1 | grep "warning: B has a \`follows'-declaration for a non-existant input invalid!" +nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid'" +nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid2'" |