Merge pull request #20467 from ericsagnes/feat/module-enums-2

modules: use enum when relevant
This commit is contained in:
Joachim F 2016-11-17 22:48:26 +01:00 committed by GitHub
commit 2bb30e5d66
7 changed files with 16 additions and 45 deletions

View File

@ -301,9 +301,7 @@ in
}; };
style = mkOption { style = mkOption {
type = types.str // { type = types.enum ["none" "slight" "medium" "full"];
check = flip elem ["none" "slight" "medium" "full"];
};
default = "full"; default = "full";
description = '' description = ''
TrueType hinting style, one of <literal>none</literal>, TrueType hinting style, one of <literal>none</literal>,
@ -329,9 +327,7 @@ in
default = "rgb"; default = "rgb";
type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"]; type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
description = '' description = ''
Subpixel order, one of <literal>none</literal>, Subpixel order.
<literal>rgb</literal>, <literal>bgr</literal>,
<literal>vrgb</literal>, or <literal>vbgr</literal>.
''; '';
}; };
@ -339,9 +335,7 @@ in
default = "default"; default = "default";
type = types.enum ["none" "default" "light" "legacy"]; type = types.enum ["none" "default" "light" "legacy"];
description = '' description = ''
FreeType LCD filter, one of <literal>none</literal>, FreeType LCD filter.
<literal>default</literal>, <literal>light</literal>, or
<literal>legacy</literal>.
''; '';
}; };

View File

@ -73,7 +73,7 @@ in
}; };
failmode = mkOption { failmode = mkOption {
type = types.str; type = types.enum [ "safe" "enum" ];
default = "safe"; default = "safe";
description = '' description = ''
On service or configuration errors that prevent Duo On service or configuration errors that prevent Duo
@ -115,7 +115,7 @@ in
}; };
prompts = mkOption { prompts = mkOption {
type = types.int; type = types.enum [ 1 2 3 ];
default = 3; default = 3;
description = '' description = ''
If a user fails to authenticate with a second factor, Duo If a user fails to authenticate with a second factor, Duo
@ -181,13 +181,7 @@ in
config = mkIf (cfg.ssh.enable || cfg.pam.enable) { config = mkIf (cfg.ssh.enable || cfg.pam.enable) {
assertions = assertions =
[ { assertion = cfg.failmode == "safe" || cfg.failmode == "secure"; [ { assertion = !cfg.pam.enable;
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;
message = "PAM support is currently not implemented."; message = "PAM support is currently not implemented.";
} }
]; ];

View File

@ -86,7 +86,7 @@ in
hwMode = mkOption { hwMode = mkOption {
default = "g"; default = "g";
type = types.string; type = types.enum [ "a" "b" "g" ];
description = '' description = ''
Operation mode. Operation mode.
(a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g). (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g).
@ -152,9 +152,6 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ 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); { assertion = (cfg.channel >= 1 && cfg.channel <= 13);
message = "channel must be between 1 and 13"; message = "channel must be between 1 and 13";
}]; }];

View File

@ -148,11 +148,11 @@ in
}; };
verbosity = mkOption { verbosity = mkOption {
type = types.str; type = types.enum [ "error" "warning" "notice" "info" "debug" ];
default = "info"; default = "info";
example = "error"; example = "error";
description = '' description = ''
Verbosity level (error, warning, notice, info, debug) Verbosity level
''; '';
}; };

View File

@ -345,12 +345,10 @@ let
}; };
rrlWhitelist = mkOption { rrlWhitelist = mkOption {
type = types.listOf types.str; type = with types; listOf (enum [ "nxdomain" "error" "referral" "any" "rrsig" "wildcard" "nodata" "dnskey" "positive" "all" ]);
default = []; default = [];
description = '' description = ''
Whitelists the given rrl-types. Whitelists the given rrl-types.
The RRL classification types are: nxdomain, error, referral, any,
rrsig, wildcard, nodata, dnskey, positive, all
''; '';
}; };

View File

@ -33,7 +33,7 @@ in
boot.loader.raspberryPi.version = mkOption { boot.loader.raspberryPi.version = mkOption {
default = 2; default = 2;
type = types.int; type = types.enum [ 1 2 ];
description = '' description = ''
''; '';
}; };
@ -44,10 +44,5 @@ in
system.build.installBootLoader = builder; system.build.installBootLoader = builder;
system.boot.loader.id = "raspberrypi"; system.boot.loader.id = "raspberrypi";
system.boot.loader.kernelFile = platform.kernelTarget; system.boot.loader.kernelFile = platform.kernelTarget;
assertions = [
{ assertion = (cfg.version == 1 || cfg.version == 2);
message = "loader.raspberryPi.version should be 1 or 2";
}
];
}; };
} }

View File

@ -782,13 +782,12 @@ in
}; };
type = mkOption { type = mkOption {
type = types.string; type = types.enum [ "managed" "ibss" "monitor" "mesh" "wds" ];
default = "managed"; default = "managed";
example = "ibss"; example = "ibss";
description = '' description = ''
The type of the WLAN interface. The type has to be either <literal>managed</literal>, The type of the WLAN interface.
<literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>. The type has to be supported by the underlying hardware of the device.
Also, the type has to be supported by the underlying hardware of the device.
''; '';
}; };
@ -799,17 +798,11 @@ in
}; };
flags = mkOption { flags = mkOption {
type = types.nullOr types.string; type = with types; nullOr (enum [ "none" "fcsfail" "control" "otherbss" "cook" "active" ]);
default = null; default = null;
example = "control"; example = "control";
description = '' description = ''
Flags for interface of type <literal>monitor</literal>. The valid flags are: Flags for interface of type <literal>monitor</literal>.
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)
''; '';
}; };