aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-07-13 13:39:06 +0200
committerEelco Dolstra <edolstra@gmail.com>2022-07-13 13:40:40 +0200
commit12df8885cc70499cc8fa2bfe73992c6d37ec332e (patch)
tree5eb82acb2ef9c5c07fdf1215334a570ff044cd6a /src/libexpr/flake
parent438776cce73832470a5d30b2e77312643402ec41 (diff)
Simplify the check for overrides on non-existent inputs
Diffstat (limited to 'src/libexpr/flake')
-rw-r--r--src/libexpr/flake/flake.cc47
1 files changed, 12 insertions, 35 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). */