about summary refs log tree commit diff
path: root/read-tree.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-11-25T15·10+0000
committerVincent Ambo <tazjin@google.com>2019-11-25T15·10+0000
commit48ed487bddb7429e6d79db1151e82b7316c31b37 (patch)
tree4d7e57e485fda47f11fe865ef2e23bf17bec1739 /read-tree.nix
parentf1655c5cbb480b1555137c77c8b4366b6714a2b3 (diff)
refactor(read-tree): Idiomatic 'attrsToList' instead of weird hack
Diffstat (limited to 'read-tree.nix')
-rw-r--r--read-tree.nix15
1 files changed, 4 insertions, 11 deletions
diff --git a/read-tree.nix b/read-tree.nix
index d883d12c81..2c53ee1d9b 100644
--- a/read-tree.nix
+++ b/read-tree.nix
@@ -3,7 +3,6 @@ path: { pkgs, ... } @ args:
 let
   inherit (builtins)
     attrNames
-    attrValues
     filter
     head
     isString
@@ -11,19 +10,13 @@ let
     map
     match
     readDir
-    tail
     toPath
     toString;
 
-  zipAttrs = names: values:
-    if (names == []) || (values == [])
-    then []
-    else [{
-      name = head names;
-      value = head values;
-    }] ++ zipAttrs (tail names) (tail values);
-
-  attrsToList = attrs: zipAttrs (attrNames attrs) (attrValues attrs);
+  attrsToList = attrs: map (name: {
+    inherit name;
+    value = attrs."${name}";
+  }) (attrNames attrs);
 
   isFile = s: s == "regular";
   isDir = s: s == "directory";