Allow enum of integers (and any other type)

Closes #9826.
This commit is contained in:
Igor Pashev 2015-12-04 07:15:14 +03:00
parent 12de4d5cb3
commit 363e6978ce

View File

@ -230,11 +230,18 @@ rec {
substSubModules = m: submodule m;
};
enum = values: mkOptionType {
name = "one of ${concatStringsSep ", " values}";
check = flip elem values;
merge = mergeOneOption;
};
enum = values:
let
show = v:
if builtins.isString v then ''"${v}"''
else if builtins.isInt v then builtins.toString v
else ''<${builtins.typeOf v}>'';
in
mkOptionType {
name = "one of ${concatMapStringsSep ", " show values}";
check = flip elem values;
merge = mergeOneOption;
};
either = t1: t2: mkOptionType {
name = "${t1.name} or ${t2.name}";