1{2 lib,3 config,4 ...5}:6let7 inherit (lib.options) mkOption;8 inherit (lib.types) listOf unspecified str;9 inherit (lib.lists) map filter;1011 errors = mkOption {12 type = listOf str;13 internal = true;14 description = ''15 Similar to warnings, however build will fail if any error exists.16 '';17 };18in19{20 options = {21 assertions = mkOption {22 type = listOf unspecified;23 internal = true;24 default = [ ];25 example = [26 {27 assertion = false;28 message = "you can't enable this for that reason";29 }30 ];31 description = ''32 This option allows modules to express conditions that must33 hold for the evaluation of the system configuration to34 succeed, along with associated error messages for the user.35 '';36 };3738 warnings = mkOption {39 internal = true;40 default = [ ];41 type = listOf str;42 example = [ "The `foo' service is deprecated and will go away soon!" ];43 description = ''44 This option allows modules to show warnings to users during45 the evaluation of the system configuration.46 '';47 };4849 inherit errors;50 };51 config = {52 errors = map (v: v.message) (filter (v: !v.assertion) config.assertions);5354 nixos =55 { config, ... }:56 {57 _file = ./assertions.nix;58 options = {59 inherit errors;60 };61 config.errors = map (v: v.message) (filter (v: !v.assertion) config.assertions);62 };63 };64}