From 48ed487bddb7429e6d79db1151e82b7316c31b37 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 25 Nov 2019 15:10:31 +0000 Subject: [PATCH] refactor(read-tree): Idiomatic 'attrsToList' instead of weird hack --- read-tree.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/read-tree.nix b/read-tree.nix index d883d12c8..2c53ee1d9 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";