Don't check NixOS modules

NixOS modules can be paths. Rather than dig further down into the layer
violation, don't check anything specific to NixOS modules.
This commit is contained in:
Naïm Favier 2023-01-05 18:23:30 +01:00
parent d02c5a41da
commit f1ee4ece80
No known key found for this signature in database
GPG key ID: 95AFCE8211908325
2 changed files with 2 additions and 31 deletions

View file

@ -381,23 +381,6 @@ struct CmdFlakeCheck : FlakeCommand
auto checkModule = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
state->forceValue(v, pos);
if (v.isLambda()) {
if (!v.lambda.fun->hasFormals() || !v.lambda.fun->formals->ellipsis)
throw Error("module must match an open attribute set ('{ config, ... }')");
} else if (v.type() == nAttrs) {
for (auto & attr : *v.attrs)
try {
state->forceValue(*attr.value, attr.pos);
} catch (Error & e) {
e.addTrace(
state->positions[attr.pos],
hintfmt("while evaluating the option '%s'", state->symbols[attr.name]));
throw;
}
} else
throw Error("module must be a function or an attribute set");
// FIXME: if we have a 'nixpkgs' input, use it to
// check the module.
} catch (Error & e) {
e.addTrace(resolve(pos), hintfmt("while checking the NixOS module '%s'", attrPath));
reportError(e);

View file

@ -41,9 +41,9 @@ nix flake check $flakeDir
cat > $flakeDir/flake.nix <<EOF
{
outputs = { self }: {
nixosModules.foo = {
nixosModules.foo = assert false; {
a.b.c = 123;
foo = assert false; true;
foo = true;
};
};
}
@ -63,18 +63,6 @@ EOF
nix flake check $flakeDir
cat > $flakeDir/flake.nix <<EOF
{
outputs = { self }: {
nixosModule = { config, pkgs }: {
a.b.c = 123;
};
};
}
EOF
(! nix flake check $flakeDir)
cat > $flakeDir/flake.nix <<EOF
{
outputs = { self }: {