From 61efe92e689d0feb1033ef049de5516711cfc881 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:35:46 +0900 Subject: [PATCH 1/7] fontconfig module: use enum --- nixos/modules/config/fonts/fontconfig.nix | 12 +++--------- 1 file changed, 3 insertions(+), 9 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 none, @@ -329,9 +327,7 @@ in default = "rgb"; type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"]; description = '' - Subpixel order, one of none, - rgb, bgr, - vrgb, or vbgr. + Subpixel order. ''; }; @@ -339,9 +335,7 @@ in default = "default"; type = types.enum ["none" "default" "light" "legacy"]; description = '' - FreeType LCD filter, one of none, - default, light, or - legacy. + FreeType LCD filter. ''; }; From 9513ab45aa6fb06423df1968150bbee9eb821214 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:36:05 +0900 Subject: [PATCH 2/7] duosec module: use enum --- nixos/modules/security/duosec.nix | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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."; } ]; From fb26d561ed47be24d1288599f4579a4f5c0f360d Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:36:26 +0900 Subject: [PATCH 3/7] hostapd module: use enum --- nixos/modules/services/networking/hostapd.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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"; }]; From 5259fb218103cd3111e2534e941362b80d48043f Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:36:53 +0900 Subject: [PATCH 4/7] nntp-proxy module: use enum --- nixos/modules/services/networking/nntp-proxy.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ''; }; From 15d25df6987bdc781f3fd67a00995d6cca86936d Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:37:14 +0900 Subject: [PATCH 5/7] nsd module: use enum --- nixos/modules/services/networking/nsd.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 ''; }; From 4a600b0437ab3933d189fdc99208cd1b88db9575 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:37:36 +0900 Subject: [PATCH 6/7] raspberrypi module: use enum --- .../modules/system/boot/loader/raspberrypi/raspberrypi.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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"; - } - ]; }; } From 0ebc5ec7cb2172063c2e9274327a9a7051641c13 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 16 Nov 2016 22:37:57 +0900 Subject: [PATCH 7/7] network-interfaces: use enum --- nixos/modules/tasks/network-interfaces.nix | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 managed, - ibss, monitor, mesh or wds. - 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 monitor. 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 monitor. ''; };