diff options
author | Shea Levy <shea@shealevy.com> | 2014-05-01 17:58:16 -0400 |
---|---|---|
committer | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-03-12 23:42:57 +0100 |
commit | e4bc2592f3c5fa2f05484e7258f99ebb0507d304 (patch) | |
tree | e0203e342a71962e07a82c18d7119487198707a3 /lib/types.nix | |
parent | 9255c48a06913a064da4e103e6b7c1d94fb4fb90 (diff) | |
download | nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar.gz nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar.bz2 nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar.lz nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar.xz nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.tar.zst nixpkgs-e4bc2592f3c5fa2f05484e7258f99ebb0507d304.zip |
types.listOf: Use mergeDefinitions to handle each element
This simplifies typechecking and allows properties to be used inside the lists
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/types.nix b/lib/types.nix index 1e7abf36535..58fb05b9f0e 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -7,7 +7,9 @@ with import ./options.nix; with import ./trivial.nix; with import ./strings.nix; -rec { +let + inherit (import ./modules.nix) mergeDefinitions; +in rec { isType = type: x: (x._type or "") == type; @@ -109,11 +111,14 @@ rec { listOf = elemType: mkOptionType { name = "list of ${elemType.name}s"; - check = value: isList value && all elemType.check value; + check = isList; merge = loc: defs: - concatLists (imap (n: def: imap (m: def': - elemType.merge (loc ++ ["[${toString n}-${toString m}]"]) - [{ inherit (def) file; value = def'; }]) def.value) defs); + map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: imap (m: def': + let + inherit (mergeDefinitions (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) + elemType [{ inherit (def) file; value = def'; }] + ) defsFinal mergedValue; + in if defsFinal == [] then {} else { value = mergedValue; }) def.value) defs))); getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["*"]); getSubModules = elemType.getSubModules; substSubModules = m: listOf (elemType.substSubModules m); |