diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-28 19:09:36 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-28 19:09:36 +0100 |
commit | 2fccef0c59f57ad276a60f6d3ae59dcc36a51027 (patch) | |
tree | 52da65e4da15c9f176ec99b1293bcc3459256d67 /src/libexpr | |
parent | 2287e2f279ac544a2c11921be51f2f556cb78abc (diff) |
Warn about --override-input / --update-input flags that don't match an input
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/flake/flake.cc | 13 |
1 files changed, 13 insertions, 0 deletions
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<InputPath, FlakeInput> overrides; + std::set<InputPath> 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<const LockedNode> 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. */ |