aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-07-30 11:45:47 -0500
committerMatthew Bauer <mjbauer95@gmail.com>2020-07-30 11:45:47 -0500
commit5d04a4db9b3d8cbfbaacbc48a587d21d90844871 (patch)
tree9aa6a8a05525a88e93e39e61cc37b7fbec0492e7 /src/nix
parent2f4250a4167f2b1c10e5fa9c6163f84bb9bbd740 (diff)
Handle exporters checking correctly
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/flake.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index db3ebdc2a..cf7e4b7f5 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -374,9 +374,8 @@ struct CmdFlakeCheck : FlakeCommand
if (v.type != tLambda)
throw Error("exporter must be a function");
if (!v.lambda.fun->formals ||
- v.lambda.fun->formals->argNames.find(state->symbols.create("program")) == v.lambda.fun->formals->argNames.end() ||
- v.lambda.fun->formals->argNames.find(state->symbols.create("args")) == v.lambda.fun->formals->argNames.end())
- throw Error("exporter must take formal arguments 'program' and 'args'");
+ v.lambda.fun->formals->argNames.find(state->symbols.create("program")) == v.lambda.fun->formals->argNames.end())
+ throw Error("exporter must take formal argument 'program'");
} catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
throw;
@@ -506,13 +505,21 @@ struct CmdFlakeCheck : FlakeCommand
}
else if (name == "defaultExporter")
- checkExporter(name, vOutput, pos);
+ for (auto & attr : *vOutput.attrs) {
+ checkSystemName(attr.name, *attr.pos);
+ checkExporter(fmt("%s.%s", name, attr.name), *attr.value, *attr.pos);
+ }
else if (name == "exporters") {
state->forceAttrs(vOutput, pos);
- for (auto & attr : *vOutput.attrs)
- checkExporter(fmt("%s.%s", name, attr.name),
- *attr.value, *attr.pos);
+ for (auto & attr : *vOutput.attrs) {
+ checkSystemName(attr.name, *attr.pos);
+ state->forceAttrs(*attr.value, *attr.pos);
+ for (auto & attr2 : *attr.value->attrs)
+ checkExporter(
+ fmt("%s.%s.%s", name, attr.name, attr2.name),
+ *attr2.value, *attr2.pos);
+ }
}
else