summaryrefslogtreecommitdiffstats
path: root/lib/types.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-05-01 11:30:20 -0400
committerShea Levy <shea@shealevy.com>2014-05-01 11:30:20 -0400
commitab2cd34076cceef0288a05b40afee1160c44d40b (patch)
tree87ba8beee472e7c193f1b508caca1732dff49f11 /lib/types.nix
parente4630c1d41d513eb709bddb39043da84442235a7 (diff)
Add enum option type
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index baf8aa5e5743..6ce54bfae4e4 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -194,6 +194,12 @@ rec {
args = { name = ""; }; }).options;
};
+ enum = values: mkOptionType {
+ name = "one of ${concatStringsSep ", " values}.";
+ check = flip elem values;
+ merge = mergeOneOption;
+ };
+
# Obsolete alternative to configOf. It takes its option
# declarations from the ‘options’ attribute of containing option
# declaration.