diff options
author | zimbatm <zimbatm@zimbatm.com> | 2017-07-04 23:29:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-04 23:29:23 +0100 |
commit | 4d545297d85c8f32f7ab496d0759f40d881bd61d (patch) | |
tree | c3309bda805bce2028f2fe53b6662bd4a3352936 /lib/types.nix | |
parent | a0fa61788b930b05afc475b61a9963655e969ef9 (diff) | |
download | nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar.gz nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar.bz2 nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar.lz nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar.xz nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.tar.zst nixlib-4d545297d85c8f32f7ab496d0759f40d881bd61d.zip |
lib: introduce imap0, imap1 (#25543)
* lib: introduce imap0, imap1 For historical reasons, imap starts counting at 1 and it's not consistent with the rest of the lib. So for now we split imap into imap0 that starts counting at zero and imap1 that starts counting at 1. And imap is marked as deprecated. See https://github.com/NixOS/nixpkgs/commit/c71e2d42359f9900ea2c290d141c0d606471da16#commitcomment-21873221 * replace uses of lib.imap * lib: move imap to deprecated.nix
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/types.nix b/lib/types.nix index 50aa6d770852..a7dcd3f1e1c7 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -179,9 +179,9 @@ rec { description = "list of ${elemType.description}s"; check = isList; merge = loc: defs: - map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: + map (x: x.value) (filter (x: x ? value) (concatLists (imap1 (n: def: if isList def.value then - imap (m: def': + imap1 (m: def': (mergeDefinitions (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) elemType @@ -220,7 +220,7 @@ rec { if isList def.value then { inherit (def) file; value = listToAttrs ( - imap (elemIdx: elem: + imap1 (elemIdx: elem: { name = elem.name or "unnamed-${toString defIdx}.${toString elemIdx}"; value = elem; }) def.value); @@ -233,7 +233,7 @@ rec { name = "loaOf"; description = "list or attribute set of ${elemType.description}s"; check = x: isList x || isAttrs x; - merge = loc: defs: attrOnly.merge loc (imap convertIfList defs); + merge = loc: defs: attrOnly.merge loc (imap1 convertIfList defs); getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["<name?>"]); getSubModules = elemType.getSubModules; substSubModules = m: loaOf (elemType.substSubModules m); |