diff options
author | edef <edef@mutable.io> | 2020-05-28T12·51+0000 |
---|---|---|
committer | edef <edef@edef.eu> | 2020-06-13T20·08+0000 |
commit | cec109807babe65dba79b9776cee2024aad349a6 (patch) | |
tree | 54854dc37d159bbd309144408fa3f97a411a283e /nix | |
parent | cbcec9fd04f0e317d4e7026c6ee43217c7d75c86 (diff) |
fix(nix/readTree): Ignore hidden files and directories r/939
This skips any directory entries starting with a dot. Change-Id: I95767f3d35bcb2ed9b3d6e772f3924dd57612711 Reviewed-on: https://cl.tvl.fyi/c/depot/+/123 Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'nix')
-rw-r--r-- | nix/readTree/default.nix | 17 |
1 files 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); |