diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-23 18:21:15 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-23 20:08:22 +0200 |
commit | b5d5afd99a7ff24de036885364f7a7bbe90dd405 (patch) | |
tree | 9473715b915163711092bd30252f55d0cc647c80 /nixos/modules/misc/assertions.nix | |
parent | 6de7886fb80fde29437d8b519d6bbe743794deeb (diff) | |
download | nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar.gz nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar.bz2 nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar.lz nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar.xz nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.tar.zst nixpkgs-b5d5afd99a7ff24de036885364f7a7bbe90dd405.zip |
Allow modules to define warnings to be shown during evaluation
Diffstat (limited to 'nixos/modules/misc/assertions.nix')
-rw-r--r-- | nixos/modules/misc/assertions.nix | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/nixos/modules/misc/assertions.nix b/nixos/modules/misc/assertions.nix index 7ded9785bc1..229f8f27860 100644 --- a/nixos/modules/misc/assertions.nix +++ b/nixos/modules/misc/assertions.nix @@ -6,6 +6,8 @@ let failed = map (x: x.message) (filter (x: !x.assertion) config.assertions); + showWarnings = res: fold (w: x: builtins.trace "[1;31mwarning: ${w}[0m" x) res config.warnings; + in { @@ -24,14 +26,26 @@ in ''; }; + warnings = mkOption { + internal = true; + default = []; + type = types.listOf types.string; + example = [ "The `foo' service is deprecated and will go away soon!" ]; + description = '' + This option allows modules to show warnings to users during + the evaluation of the system configuration. + ''; + }; + }; config = { - # This option is evaluated always. Thus the assertions are checked as well. hacky! - environment.systemPackages = + # This option is evaluated always. Thus the assertions are checked + # as well. Hacky! + environment.systemPackages = showWarnings ( if [] == failed then [] - else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}"; + else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}"); }; |