From 2fccef0c59f57ad276a60f6d3ae59dcc36a51027 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 28 Mar 2020 19:09:36 +0100 Subject: [PATCH] Warn about --override-input / --update-input flags that don't match an input --- src/libexpr/flake/flake.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 18b776727..9517e3645 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -314,6 +314,7 @@ LockedFlake lockFlake( // FIXME: check whether all overrides are used. std::map overrides; + std::set overridesUsed, updatesUsed; for (auto & i : lockFlags.inputOverrides) overrides.insert_or_assign(i.first, FlakeInput { .ref = i.second }); @@ -363,6 +364,7 @@ LockedFlake lockFlake( ancestors? */ auto i = overrides.find(inputPath); bool hasOverride = i != overrides.end(); + if (hasOverride) overridesUsed.insert(inputPath); auto & input = hasOverride ? i->second : input2; /* Resolve 'follows' later (since it may refer to an input @@ -385,6 +387,8 @@ LockedFlake lockFlake( don't have a --update-input flag for this input? */ std::shared_ptr oldLock; + updatesUsed.insert(inputPath); + if (oldNode && !lockFlags.inputUpdates.count(inputPath)) { auto oldLockIt = oldNode->inputs.find(id); if (oldLockIt != oldNode->inputs.end()) @@ -515,6 +519,15 @@ LockedFlake lockFlake( fromParentNode->inputs.insert_or_assign(from.back(), toNode); } + for (auto & i : lockFlags.inputOverrides) + if (!overridesUsed.count(i.first)) + warn("the flag '--override-input %s %s' does not match any input", + concatStringsSep("/", i.first), i.second); + + for (auto & i : lockFlags.inputUpdates) + if (!updatesUsed.count(i)) + warn("the flag '--update-input %s' does not match any input", concatStringsSep("/", i)); + debug("new lock file: %s", newLockFile); /* Check whether we need to / can write the new lock file. */