diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-12-18 14:17:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 14:17:52 +0100 |
commit | 7698aa9776244ae69aa6b3714f05d676dd33b100 (patch) | |
tree | ea309cb20a06127342d2b04a2ba87c82157381af /nixos/modules/misc | |
parent | c23db78bbd474c4d0c5c3c551877523b4a50db06 (diff) | |
parent | a6a70d14a9f7b885e65a51c5e6bd02145884ee50 (diff) | |
download | nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar.gz nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar.bz2 nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar.lz nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar.xz nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.tar.zst nixpkgs-7698aa9776244ae69aa6b3714f05d676dd33b100.zip |
Merge pull request #97023 from Infinisil/module-assertions
Module-builtin assertions, disabling assertions and submodule assertions
Diffstat (limited to 'nixos/modules/misc')
-rw-r--r-- | nixos/modules/misc/assertions.nix | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nixos/modules/misc/assertions.nix b/nixos/modules/misc/assertions.nix index 550b3ac97f6..d7cdb32491d 100644 --- a/nixos/modules/misc/assertions.nix +++ b/nixos/modules/misc/assertions.nix @@ -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> } |