Merge pull request #97023 from Infinisil/module-assertions

Module-builtin assertions, disabling assertions and submodule assertions
This commit is contained in:
Silvan Mosberger
2020-12-18 14:17:52 +01:00
committed by GitHub
16 changed files with 442 additions and 96 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
{ lib, ... }:
{ lib, config, ... }:
with lib;
@@ -30,5 +30,18 @@ with lib;
};
};
config._module.checks = lib.listToAttrs (lib.imap1 (n: value:
let
name = "_${toString n}";
isWarning = lib.isString value;
result = {
check = if isWarning then false else value.assertion;
type = if isWarning then "warning" else "error";
message = if isWarning then value else value.message;
};
in nameValuePair name result
) (config.assertions ++ config.warnings));
# impl of assertions is in <nixpkgs/nixos/modules/system/activation/top-level.nix>
}