1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 17:51:15 +02:00

Merge pull request #6663 from Ma27/follows-invalid-input

flakes: throw an error if `follows`-declaration for an input is invalid
This commit is contained in:
Théophane Hufschmitt 2022-07-12 16:44:22 +02:00 committed by GitHub
commit 2dbd5ed0b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 1 deletions

View file

@ -352,6 +352,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,
@ -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) {