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,8 +230,15 @@ rec {
substSubModules = m: submodule m;
};
enum = values: mkOptionType {
name = "one of ${concatStringsSep ", " values}";
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;
};