mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
nix flake check
: Add apps check; Check if formatter is a derivation
This commit is contained in:
parent
a5f6ee8550
commit
adabca6e4f
1 changed files with 33 additions and 8 deletions
|
@ -437,14 +437,39 @@ struct CmdFlakeCheck : FlakeCommand
|
|||
|
||||
auto checkApp = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
|
||||
try {
|
||||
#if 0
|
||||
// FIXME
|
||||
auto app = App(*state, v);
|
||||
for (auto & i : app.context) {
|
||||
auto [drvPathS, outputName] = NixStringContextElem::parse(i);
|
||||
store->parseStorePath(drvPathS);
|
||||
Activity act(*logger, lvlInfo, actUnknown, fmt("checking app '%s'", attrPath));
|
||||
state->forceAttrs(v, pos, "");
|
||||
if (auto attr = v.attrs()->get(state->symbols.create("type")))
|
||||
state->forceStringNoCtx(*attr->value, attr->pos, "");
|
||||
else
|
||||
throw Error("app '%s' lacks attribute 'type'", attrPath);
|
||||
|
||||
if (auto attr = v.attrs()->get(state->symbols.create("program"))) {
|
||||
if (attr->name == state->symbols.create("program")) {
|
||||
NixStringContext context;
|
||||
state->forceString(*attr->value, context, attr->pos, "");
|
||||
}
|
||||
} else
|
||||
throw Error("app '%s' lacks attribute 'program'", attrPath);
|
||||
|
||||
if (auto attr = v.attrs()->get(state->symbols.create("meta"))) {
|
||||
state->forceAttrs(*attr->value, attr->pos, "");
|
||||
if (auto dAttr = attr->value->attrs()->get(state->symbols.create("description")))
|
||||
state->forceStringNoCtx(*dAttr->value, dAttr->pos, "");
|
||||
else
|
||||
logWarning({
|
||||
.msg = HintFmt("app '%s' lacks attribute 'meta.description'", attrPath),
|
||||
});
|
||||
} else
|
||||
logWarning({
|
||||
.msg = HintFmt("app '%s' lacks attribute 'meta'", attrPath),
|
||||
});
|
||||
|
||||
for (auto & attr : *v.attrs()) {
|
||||
std::string_view name(state->symbols[attr.name]);
|
||||
if (name != "type" && name != "program" && name != "meta")
|
||||
throw Error("app '%s' has unsupported attribute '%s'", attrPath, name);
|
||||
}
|
||||
#endif
|
||||
} catch (Error & e) {
|
||||
e.addTrace(resolve(pos), HintFmt("while checking the app definition '%s'", attrPath));
|
||||
reportError(e);
|
||||
|
@ -629,7 +654,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||
const auto & attr_name = state->symbols[attr.name];
|
||||
checkSystemName(attr_name, attr.pos);
|
||||
if (checkSystemType(attr_name, attr.pos)) {
|
||||
checkApp(
|
||||
checkDerivation(
|
||||
fmt("%s.%s", name, attr_name),
|
||||
*attr.value, attr.pos);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue