mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Simplify the check for overrides on non-existent inputs
This commit is contained in:
parent
438776cce7
commit
12df8885cc
2 changed files with 15 additions and 36 deletions
|
@ -352,39 +352,6 @@ LockedFlake lockFlake(
|
||||||
|
|
||||||
std::vector<FlakeRef> parents;
|
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(
|
std::function<void(
|
||||||
const FlakeInputs & flakeInputs,
|
const FlakeInputs & flakeInputs,
|
||||||
std::shared_ptr<Node> node,
|
std::shared_ptr<Node> node,
|
||||||
|
@ -406,8 +373,6 @@ LockedFlake lockFlake(
|
||||||
{
|
{
|
||||||
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
||||||
|
|
||||||
checkFollowsDeclarations(inputPathPrefix, flakeInputs);
|
|
||||||
|
|
||||||
/* Get the overrides (i.e. attributes of the form
|
/* Get the overrides (i.e. attributes of the form
|
||||||
'inputs.nixops.inputs.nixpkgs.url = ...'). */
|
'inputs.nixops.inputs.nixpkgs.url = ...'). */
|
||||||
for (auto & [id, input] : flakeInputs) {
|
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
|
/* Go over the flake inputs, resolve/fetch them if
|
||||||
necessary (i.e. if they're new or the flakeref changed
|
necessary (i.e. if they're new or the flakeref changed
|
||||||
from what's in the lock file). */
|
from what's in the lock file). */
|
||||||
|
|
|
@ -869,6 +869,7 @@ cat >$flakeFollowsA/flake.nix <<EOF
|
||||||
inputs.B = {
|
inputs.B = {
|
||||||
url = "path:./flakeB";
|
url = "path:./flakeB";
|
||||||
inputs.invalid.follows = "D";
|
inputs.invalid.follows = "D";
|
||||||
|
inputs.invalid2.url = "path:./flakeD";
|
||||||
};
|
};
|
||||||
inputs.D.url = "path:./flakeD";
|
inputs.D.url = "path:./flakeD";
|
||||||
outputs = { ... }: {};
|
outputs = { ... }: {};
|
||||||
|
@ -877,4 +878,5 @@ EOF
|
||||||
|
|
||||||
git -C $flakeFollowsA add flake.nix
|
git -C $flakeFollowsA add flake.nix
|
||||||
|
|
||||||
nix flake lock $flakeFollowsA 2>&1 | grep "warning: B has a \`follows'-declaration for a non-existant input invalid!"
|
nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid'"
|
||||||
|
nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid2'"
|
||||||
|
|
Loading…
Reference in a new issue