Add mergeStringOption and factor mergeSomethingOption by introducing mergeTypedOption.
svn path=/nixpkgs/trunk/; revision=13310
This commit is contained in:
parent
b196bab378
commit
34f916700d
|
@ -391,14 +391,19 @@ rec {
|
||||||
else if all __isAttrs list then mergeAttrs list
|
else if all __isAttrs list then mergeAttrs list
|
||||||
else abort "${name}: Cannot merge values.";
|
else abort "${name}: Cannot merge values.";
|
||||||
|
|
||||||
mergeEnableOption = name: list:
|
mergeTypedOption = typeName: predicate: merge: name: list:
|
||||||
if all (x: true == x || false == x) list
|
if all predicate list then merge list
|
||||||
then fold logicalOR false list
|
else abort "${name}: Expect a ${typeName}.";
|
||||||
else abort "${name}: Expect a boolean value.";
|
|
||||||
|
|
||||||
mergeListOption = name: list:
|
mergeEnableOption = mergeTypedOption "boolean"
|
||||||
if all __isList list then concatLists list
|
(x: true == x || false == x) (fold logicalOR false);
|
||||||
else abort "${name}: Expect a list.";
|
|
||||||
|
mergeListOption = mergeTypedOption "list"
|
||||||
|
__isList concatLists;
|
||||||
|
|
||||||
|
mergeStringOption = mergeTypedOption "string"
|
||||||
|
(x: if builtins ? isString then builtins.isString x else x + "")
|
||||||
|
concatStrings;
|
||||||
|
|
||||||
# Merge sets of options and bindings.
|
# Merge sets of options and bindings.
|
||||||
# noOption: function to call if no option is declared.
|
# noOption: function to call if no option is declared.
|
||||||
|
|
Loading…
Reference in New Issue