aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-09-10 14:52:22 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-09-10 14:52:22 +0200
commitdc3f52a1447df8523f44c89e25e48e8b7f5341a0 (patch)
treeeeebfd70f5687c64bc7f12308b4046cb5a841ef8
parentf97d3753a13f0ff916d83dbea4fe7dae7194f903 (diff)
nix flake check: Check overlays
-rw-r--r--src/nix/flake.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 4129ef323..10ce9addc 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -280,6 +280,22 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
}
};
+ auto checkOverlay = [&](const std::string & attrPath, Value & v) {
+ try {
+ state->forceValue(v);
+ if (v.type != tLambda || v.lambda.fun->matchAttrs || std::string(v.lambda.fun->arg) != "final")
+ throw Error("overlay does not take an argument named 'final'");
+ auto body = dynamic_cast<ExprLambda *>(v.lambda.fun->body);
+ if (!body || body->matchAttrs || std::string(body->arg) != "prev")
+ throw Error("overlay does not take an argument named 'prev'");
+ // FIXME: if we have a 'nixpkgs' input, use it to
+ // evaluate the overlay.
+ } catch (Error & e) {
+ e.addPrefix(fmt("while checking the overlay '" ANSI_BOLD "%s" ANSI_NORMAL "':\n", attrPath));
+ throw;
+ }
+ };
+
{
Activity act(*logger, lvlInfo, actUnknown, "evaluating flake");
@@ -326,6 +342,9 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
// FIXME: do getDerivations?
;
+ else if (name == "overlay")
+ checkOverlay(name, vProvide);
+
else
warn("unknown flake output '%s'", name);