diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2008-11-16 19:23:00 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2008-11-16 19:23:00 +0000 |
commit | 34f916700d407054e9da97efb2d8b5c4d99ee5af (patch) | |
tree | 775b2cbc2e5267a1802d59a7cb7427417b4eae0c /pkgs/lib/default.nix | |
parent | b196bab378adc84f84a6d690cad5961af330f570 (diff) | |
download | nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar.gz nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar.bz2 nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar.lz nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar.xz nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.tar.zst nixlib-34f916700d407054e9da97efb2d8b5c4d99ee5af.zip |
Add mergeStringOption and factor mergeSomethingOption by introducing mergeTypedOption.
svn path=/nixpkgs/trunk/; revision=13310
Diffstat (limited to 'pkgs/lib/default.nix')
-rw-r--r-- | pkgs/lib/default.nix | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index fa71e02c01ce..e5247c57267b 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -391,14 +391,19 @@ rec { else if all __isAttrs list then mergeAttrs list else abort "${name}: Cannot merge values."; - mergeEnableOption = name: list: - if all (x: true == x || false == x) list - then fold logicalOR false list - else abort "${name}: Expect a boolean value."; - - mergeListOption = name: list: - if all __isList list then concatLists list - else abort "${name}: Expect a list."; + mergeTypedOption = typeName: predicate: merge: name: list: + if all predicate list then merge list + else abort "${name}: Expect a ${typeName}."; + + mergeEnableOption = mergeTypedOption "boolean" + (x: true == x || false == x) (fold logicalOR false); + + 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. # noOption: function to call if no option is declared. |