flakes: checkOverlay: Don't check the second argument
It's software archaeology time. - In 2019 (Nix 2.4), Eelco added `checkOverlays`, which strictly checked that the overlay must be a function of two arguments, one called `final` and the other `prev`. (dc3f52a144, gh#3573) - In 2024, NofairKing opened an issue about checking the exact name being a silly idea (gh#10516). Instead of trying to make the check more sensible, the first fix attempt simply expanded the check to allow `previous` instead of `prev` (the author's preferred name for the attribute, supposedly; gh#10553). After some discussion, instead a PR got merged which simply removed the `prev` check altogether, while leaving the `final` argument check intact for some reason (ad65a50a94a97bf1f1a1902f43542d28a2e8206b, gh#10572). - In 2025, over at Lix and oblivious to the latest change over at CppNix, I came across this stupid check while trying to improve the abstractions of the AST in Nixexpr. I spent (wasted, retrospect) considerable amounts of time removing the exact name checks while also improving the check overall (making it check for more than two arguments, and also generally improved error message). (0928d4d87a, Id4244171123dd8a228be71ce9f04d8e9f647c111) - Fast forward to 2026, where I run into this becursed piece of code once again, and once again during some Lixexpr cleanups. Now that I have seen how carlessly the issue was handled at CppNix, I can't be arsed to give a flying fuck anymore. Out the code goes. Bye. With this commit, all casts on `Expr` subclasses outside of libexpr itself have been removed. No more violation of abstraction boundaries. Good riddance. Change-Id: I939968bb01d461764cfa0f4ea7152b4fcf1acf93
This commit is contained in:
@@ -469,11 +469,6 @@ struct CmdFlakeCheck : FlakeCommand
|
||||
if (!v.isLambda()) {
|
||||
throw Error("overlay is not a function, but %s instead", showType(v));
|
||||
}
|
||||
auto body = v.lambda().fun->body->try_cast<ExprLambda>();
|
||||
if (!body)
|
||||
throw Error("overlay is not a function with two arguments, but only takes one");
|
||||
if (body->body->try_cast<ExprLambda>())
|
||||
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) {
|
||||
|
||||
@@ -34,34 +34,6 @@ def test_check_overlay_args_good(nix: Nix, files: Path):
|
||||
nix.nix(["flake", "check", str(files)]).run().ok()
|
||||
|
||||
|
||||
@with_files(
|
||||
make_flake("""{
|
||||
outputs = { self }: {
|
||||
overlay = one: two: three: {};
|
||||
};
|
||||
}""")
|
||||
)
|
||||
def test_check_overlay_too_many_args(nix: Nix, files: Path):
|
||||
assert (
|
||||
"error: overlay is not a function with two arguments, but takes more than two"
|
||||
in nix.nix(["flake", "check", str(files)]).run().expect(1).stderr_s
|
||||
)
|
||||
|
||||
|
||||
@with_files(
|
||||
make_flake("""{
|
||||
outputs = { self }: {
|
||||
overlay = one: {};
|
||||
};
|
||||
}""")
|
||||
)
|
||||
def test_check_overlay_not_enough_args(nix: Nix, files: Path):
|
||||
assert (
|
||||
"error: overlay is not a function with two arguments, but only takes one"
|
||||
in nix.nix(["flake", "check", str(files)]).run().expect(1).stderr_s
|
||||
)
|
||||
|
||||
|
||||
@with_files(
|
||||
make_flake("""{
|
||||
outputs = { self, ... }: {
|
||||
|
||||
Reference in New Issue
Block a user