From cec109807babe65dba79b9776cee2024aad349a6 Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 28 May 2020 12:51:36 +0000 Subject: fix(nix/readTree): Ignore hidden files and directories This skips any directory entries starting with a dot. Change-Id: I95767f3d35bcb2ed9b3d6e772f3924dd57612711 Reviewed-on: https://cl.tvl.fyi/c/depot/+/123 Reviewed-by: tazjin --- nix/readTree/default.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix index c48928ee19e4..4faf20d9e5c0 100644 --- a/nix/readTree/default.nix +++ b/nix/readTree/default.nix @@ -9,17 +9,28 @@ let filter hasAttr head + isAttrs length listToAttrs map match - isAttrs - readDir; + readDir + substring; argsWithPath = parts: args // { locatedAt = parts; }; + readDirVisible = path: + let + children = readDir path; + isVisible = f: f == ".skip-subtree" || (substring 0 1 f) != "."; + names = filter isVisible (attrNames children); + in listToAttrs (map (name: { + inherit name; + value = children.${name}; + }) names); + # The marker is added to every set that was imported directly by # readTree. importWithMark = path: parts: @@ -34,7 +45,7 @@ let readTree = path: parts: let - dir = readDir path; + dir = readDirVisible path; self = importWithMark path parts; joinChild = c: path + ("/" + c); -- cgit 1.4.1