1{2 lib,3 config,4 ...5}: let6 inherit (lib.options) mkOption;7 inherit (lib.types) listOf unspecified str;8 inherit (lib.lists) map filter;910 errors = mkOption {11 type = listOf str;12 internal = true;13 description = ''14 Similar to warnings, however build will fail if any error exists.15 '';16 };17in {18 options = {19 assertions = mkOption {20 type = listOf unspecified;21 internal = true;22 default = [];23 example = [24 {25 assertion = false;26 message = "you can't enable this for that reason";27 }28 ];29 description = ''30 This option allows modules to express conditions that must31 hold for the evaluation of the system configuration to32 succeed, along with associated error messages for the user.33 '';34 };3536 warnings = mkOption {37 internal = true;38 default = [];39 type = listOf str;40 example = ["The `foo' service is deprecated and will go away soon!"];41 description = ''42 This option allows modules to show warnings to users during43 the evaluation of the system configuration.44 '';45 };4647 inherit errors;48 };49 config = {50 errors =51 map (v: v.message)52 (filter (v: !v.assertion) config.assertions);5354 nixos = {config, ...}: {55 _file = ./assertions.nix;56 options = {57 inherit errors;58 };59 config.errors =60 map (v: v.message)61 (filter (v: !v.assertion) config.assertions);62 };63 };64}