aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2022-07-12 16:44:22 +0200
committerGitHub <noreply@github.com>2022-07-12 16:44:22 +0200
commit2dbd5ed0b4022fc7b22d4fe53924abc7b5a021b5 (patch)
tree2fc1f415df1cf6135637b072ce89bfe059a8adda /src/libexpr
parentf6a434c8a4d76973a26e8cbd938be2beb29696de (diff)
parent1f771065f1353ba462d73641b047b4fb2f02f482 (diff)
Merge pull request #6663 from Ma27/follows-invalid-input
flakes: throw an error if `follows`-declaration for an input is invalid
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flake.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 920726b73..906e11251 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -353,6 +353,39 @@ 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-existant input %s!",
+ root,
+ follow
+ );
+ }
+ }
+ };
+
+ std::function<void(
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
const InputPath & inputPathPrefix,
@@ -373,6 +406,8 @@ 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) {