diff options
author | Joachim F <joachifm@users.noreply.github.com> | 2016-11-17 22:48:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-17 22:48:26 +0100 |
commit | 2bb30e5d665a75e2adadd88dc214bcad3403799b (patch) | |
tree | eafbb58d88f095edd642b7fb291bdb96da594fb4 /nixos/modules | |
parent | ec6e4689ea0014e381abc573d3f64766a54fa0b7 (diff) | |
parent | 0ebc5ec7cb2172063c2e9274327a9a7051641c13 (diff) | |
download | nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar.gz nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar.bz2 nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar.lz nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar.xz nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.tar.zst nixlib-2bb30e5d665a75e2adadd88dc214bcad3403799b.zip |
Merge pull request #20467 from ericsagnes/feat/module-enums-2
modules: use enum when relevant
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/config/fonts/fontconfig.nix | 12 | ||||
-rw-r--r-- | nixos/modules/security/duosec.nix | 12 | ||||
-rw-r--r-- | nixos/modules/services/networking/hostapd.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/networking/nntp-proxy.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/networking/nsd.nix | 4 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix | 7 | ||||
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 17 |
7 files changed, 16 insertions, 45 deletions
diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 770c3a03f9d8..52ad1e714fb9 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -301,9 +301,7 @@ in }; style = mkOption { - type = types.str // { - check = flip elem ["none" "slight" "medium" "full"]; - }; + type = types.enum ["none" "slight" "medium" "full"]; default = "full"; description = '' TrueType hinting style, one of <literal>none</literal>, @@ -329,9 +327,7 @@ in default = "rgb"; type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"]; description = '' - Subpixel order, one of <literal>none</literal>, - <literal>rgb</literal>, <literal>bgr</literal>, - <literal>vrgb</literal>, or <literal>vbgr</literal>. + Subpixel order. ''; }; @@ -339,9 +335,7 @@ in default = "default"; type = types.enum ["none" "default" "light" "legacy"]; description = '' - FreeType LCD filter, one of <literal>none</literal>, - <literal>default</literal>, <literal>light</literal>, or - <literal>legacy</literal>. + FreeType LCD filter. ''; }; diff --git a/nixos/modules/security/duosec.nix b/nixos/modules/security/duosec.nix index 0e3a54325cad..97e2d39dc076 100644 --- a/nixos/modules/security/duosec.nix +++ b/nixos/modules/security/duosec.nix @@ -73,7 +73,7 @@ in }; failmode = mkOption { - type = types.str; + type = types.enum [ "safe" "enum" ]; default = "safe"; description = '' On service or configuration errors that prevent Duo @@ -115,7 +115,7 @@ in }; prompts = mkOption { - type = types.int; + type = types.enum [ 1 2 3 ]; default = 3; description = '' If a user fails to authenticate with a second factor, Duo @@ -181,13 +181,7 @@ in config = mkIf (cfg.ssh.enable || cfg.pam.enable) { assertions = - [ { assertion = cfg.failmode == "safe" || cfg.failmode == "secure"; - message = "Invalid value for failmode (must be safe or secure)."; - } - { assertion = cfg.prompts == 1 || cfg.prompts == 2 || cfg.prompts == 3; - message = "Invalid value for prompts (must be 1, 2, or 3)."; - } - { assertion = !cfg.pam.enable; + [ { assertion = !cfg.pam.enable; message = "PAM support is currently not implemented."; } ]; diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix index 51f95af48029..fd4545e88e2d 100644 --- a/nixos/modules/services/networking/hostapd.nix +++ b/nixos/modules/services/networking/hostapd.nix @@ -86,7 +86,7 @@ in hwMode = mkOption { default = "g"; - type = types.string; + type = types.enum [ "a" "b" "g" ]; description = '' Operation mode. (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g). @@ -152,9 +152,6 @@ in config = mkIf cfg.enable { assertions = [ - { assertion = (cfg.hwMode == "a" || cfg.hwMode == "b" || cfg.hwMode == "g"); - message = "hwMode must be a/b/g"; - } { assertion = (cfg.channel >= 1 && cfg.channel <= 13); message = "channel must be between 1 and 13"; }]; diff --git a/nixos/modules/services/networking/nntp-proxy.nix b/nixos/modules/services/networking/nntp-proxy.nix index dca8ccac7627..7eebecb23b00 100644 --- a/nixos/modules/services/networking/nntp-proxy.nix +++ b/nixos/modules/services/networking/nntp-proxy.nix @@ -148,11 +148,11 @@ in }; verbosity = mkOption { - type = types.str; + type = types.enum [ "error" "warning" "notice" "info" "debug" ]; default = "info"; example = "error"; description = '' - Verbosity level (error, warning, notice, info, debug) + Verbosity level ''; }; diff --git a/nixos/modules/services/networking/nsd.nix b/nixos/modules/services/networking/nsd.nix index ccfd219620cf..481e267f6c38 100644 --- a/nixos/modules/services/networking/nsd.nix +++ b/nixos/modules/services/networking/nsd.nix @@ -345,12 +345,10 @@ let }; rrlWhitelist = mkOption { - type = types.listOf types.str; + type = with types; listOf (enum [ "nxdomain" "error" "referral" "any" "rrsig" "wildcard" "nodata" "dnskey" "positive" "all" ]); default = []; description = '' Whitelists the given rrl-types. - The RRL classification types are: nxdomain, error, referral, any, - rrsig, wildcard, nodata, dnskey, positive, all ''; }; diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix index b7400e333e21..eb8ea6130972 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix @@ -33,7 +33,7 @@ in boot.loader.raspberryPi.version = mkOption { default = 2; - type = types.int; + type = types.enum [ 1 2 ]; description = '' ''; }; @@ -44,10 +44,5 @@ in system.build.installBootLoader = builder; system.boot.loader.id = "raspberrypi"; system.boot.loader.kernelFile = platform.kernelTarget; - assertions = [ - { assertion = (cfg.version == 1 || cfg.version == 2); - message = "loader.raspberryPi.version should be 1 or 2"; - } - ]; }; } diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 1faa8abd5f7f..aaa78daeb3a3 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -782,13 +782,12 @@ in }; type = mkOption { - type = types.string; + type = types.enum [ "managed" "ibss" "monitor" "mesh" "wds" ]; default = "managed"; example = "ibss"; description = '' - The type of the WLAN interface. The type has to be either <literal>managed</literal>, - <literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>. - Also, the type has to be supported by the underlying hardware of the device. + The type of the WLAN interface. + The type has to be supported by the underlying hardware of the device. ''; }; @@ -799,17 +798,11 @@ in }; flags = mkOption { - type = types.nullOr types.string; + type = with types; nullOr (enum [ "none" "fcsfail" "control" "otherbss" "cook" "active" ]); default = null; example = "control"; description = '' - Flags for interface of type <literal>monitor</literal>. The valid flags are: - none: no special flags - fcsfail: show frames with FCS errors - control: show control frames - otherbss: show frames from other BSSes - cook: use cooked mode - active: use active mode (ACK incoming unicast packets) + Flags for interface of type <literal>monitor</literal>. ''; }; |