Skip to content

Commit eff501e

Browse files
bors[bot]Pacman99
andauthored
Merge #38
38: importers: filter out empty attrsets r=blaggacao a=Pacman99 Allows you to have arbitrary folders that only get picked up if .nix files are in there. This could be useful for a folder dedicated to contains patches. And generally improves safety of the now fully recursive importers. I decided to put this in rakeLeaves, since it makes no sense to rake pointless folders and the change propagates to all importers. Co-authored-by: Pacman99 <pachum99@myrdd.info>
2 parents e869e60 + cb928ec commit eff501e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/importers.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let
4848
# builtins.trace "${toString path} is something else"
4949
sum
5050
;
51-
51+
5252
recurse = sum: path: val:
5353
builtins.foldl'
5454
(sum: key: op sum (path ++ [ key ]) val.${key})
@@ -108,8 +108,10 @@ let
108108
# recurse on directories that don't contain a `default.nix`
109109
else rakeLeaves path;
110110
};
111+
112+
files = lib.filterAttrs seive (builtins.readDir dirPath);
111113
in
112-
lib.mapAttrs' collect (lib.filterAttrs seive (builtins.readDir dirPath));
114+
lib.filterAttrs (n: v: v != { }) (lib.mapAttrs' collect files);
113115

114116
# DEPRECATED, prefer rakeLeaves
115117
mkProfileAttrs =

tests/lib/profiles/a/b/c.foo

Whitespace-only changes.

0 commit comments

Comments
 (0)