flakes: Make checkOverlay less strict
I'm sorry but checking the name of the function arguments to be "final" and "prev" is just absurd. That's like worst of type-checking-meets-static-analysis. And the error message of the second `throw` was not even good, as it mixed all three failure cases together. Change-Id: Id4244171123dd8a228be71ce9f04d8e9f647c111
This commit is contained in:
+4
-15
@@ -391,14 +391,6 @@ struct CmdFlakeCheck : FlakeCommand
|
||||
return evaluator->positions[p];
|
||||
};
|
||||
|
||||
auto argHasName = [&] (Symbol arg, std::string_view expected) {
|
||||
std::string_view name = evaluator->symbols[arg];
|
||||
return
|
||||
name == expected
|
||||
|| name == "_"
|
||||
|| (name.starts_with("_") && name.substr(1) == expected);
|
||||
};
|
||||
|
||||
auto checkSystemName = [&](const std::string & system, const PosIdx pos) {
|
||||
// FIXME: what's the format of "system"?
|
||||
if (system.find('-') == std::string::npos)
|
||||
@@ -464,14 +456,11 @@ struct CmdFlakeCheck : FlakeCommand
|
||||
if (!v.isLambda()) {
|
||||
throw Error("overlay is not a function, but %s instead", showType(v));
|
||||
}
|
||||
if (v.lambda.fun->hasFormals()
|
||||
|| !argHasName(v.lambda.fun->arg, "final"))
|
||||
throw Error("overlay does not take an argument named 'final'");
|
||||
auto body = dynamic_cast<ExprLambda *>(v.lambda.fun->body.get());
|
||||
if (!body
|
||||
|| body->hasFormals()
|
||||
|| !argHasName(body->arg, "prev"))
|
||||
throw Error("overlay does not take an argument named 'prev'");
|
||||
if (!body)
|
||||
throw Error("overlay is not a function with two arguments, but only takes one");
|
||||
if (dynamic_cast<ExprLambda *>(body->body.get()))
|
||||
throw Error("overlay is not a function with two arguments, but takes more than two");
|
||||
// FIXME: if we have a 'nixpkgs' input, use it to
|
||||
// evaluate the overlay.
|
||||
} catch (Error & e) {
|
||||
|
||||
@@ -23,6 +23,28 @@ cat > $flakeDir/flake.nix <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
(nix flake check $flakeDir)
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
overlay = one: two: three: {
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
(! nix flake check $flakeDir)
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
overlay = one: {
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
(! nix flake check $flakeDir)
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
|
||||
Reference in New Issue
Block a user