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 {
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.
'';
};

View File

@ -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.";
}
];

View File

@ -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";
}];

View File

@ -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
'';
};

View File

@ -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
'';
};

View File

@ -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";
}
];
};
}

View File

@ -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>.
'';
};