diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-03-07 19:33:52 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-03-07 19:33:52 +0100 |
commit | 674c51af3c0f3f1c65e1975893fdf6438bc57f28 (patch) | |
tree | 3020861cf515bc567e191361357d42e11ac817ee /pkgs/lib/attrsets.nix | |
parent | da437144fa4f446e91b5f7f78b55faa4d12de58a (diff) | |
parent | d742d26b0d8c7125fb29417fcb40e2665e10100d (diff) | |
download | nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar.gz nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar.bz2 nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar.lz nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar.xz nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.tar.zst nixlib-674c51af3c0f3f1c65e1975893fdf6438bc57f28.zip |
Merge remote-tracking branch 'origin/master' into stdenv-updates
Diffstat (limited to 'pkgs/lib/attrsets.nix')
-rw-r--r-- | pkgs/lib/attrsets.nix | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix index fcdc3c31f290..f562a2f7df40 100644 --- a/pkgs/lib/attrsets.nix +++ b/pkgs/lib/attrsets.nix @@ -194,7 +194,7 @@ rec { (as: !(as ? "type" && as.type == "derivation")) (x: ... do something ...) attrs - */ + */ mapAttrsRecursiveCond = cond: f: set: let recurse = path: set: @@ -208,6 +208,17 @@ rec { in recurse [] set; + /* Generate an attribute set by mapping a function over a list of + attribute names. + + Example: + genAttrs [ "foo" "bar" ] (name: "x_" + name) + => { foo = "x_foo"; bar = "x_bar"; } + */ + genAttrs = names: f: + listToAttrs (map (n: nameValuePair n (f n)) names); + + /* Check whether the argument is a derivation. */ isDerivation = x: isAttrs x && x ? type && x.type == "derivation"; |