aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nix/flake.cc6
-rw-r--r--tests/flakes/check.sh12
2 files changed, 16 insertions, 2 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 8d39de389..b5f5d0cac 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -386,8 +386,10 @@ struct CmdFlakeCheck : FlakeCommand
auto checkOverlay = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
state->forceValue(v, pos);
- if (!v.isLambda()
- || v.lambda.fun->hasFormals()
+ 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);
diff --git a/tests/flakes/check.sh b/tests/flakes/check.sh
index 34b82c61c..0433e5335 100644
--- a/tests/flakes/check.sh
+++ b/tests/flakes/check.sh
@@ -27,6 +27,18 @@ EOF
cat > $flakeDir/flake.nix <<EOF
{
+ outputs = { self, ... }: {
+ overlays.x86_64-linux.foo = final: prev: {
+ };
+ };
+}
+EOF
+
+checkRes=$(nix flake check $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
+echo "$checkRes" | grepQuiet "error: overlay is not a function, but a set instead"
+
+cat > $flakeDir/flake.nix <<EOF
+{
outputs = { self }: {
nixosModules.foo = {
a.b.c = 123;