···22222323๐ณ Works with NixOS, nix-darwin, home-manager, flake-parts, NixVim, etc.\
2424๐ฒ Callable as a deps-free Flake or nix lib.\
2525-๐ด API for listing custom file types with filters and transformations.\
2626-๐ต Extensible: add your own API methods to tailor import-tree objects.\
2727-๐ No dependencies outside flakes: just `import ./default.nix`.\
2525+๐ด Sensible defaults and configurable behaviour.\
2626+๐ต API for listing custom file types with filters and transformations.\
2727+๐ Extensible: add your own API methods to tailor import-tree objects.\
2828๐ฟ Useful on [Dendritic Pattern](https://github.com/mightyiam/dendritic) setups.\
2929๐ฑ [Growing](https://github.com/search?q=language%3ANix+import-tree&type=code) [community](https://vic.github.io/dendrix/Dendrix-Trees.html) [adoption](https://github.com/vic/flake-file)
3030···126126((import-tree.map lib.traceVal).filter (lib.hasInfix ".mod.")) ./modules
127127```
128128129129-##### `import-tree.filter` and `import-tree.filterNot`
129129+##### ๐ฒ `import-tree.filter` and `import-tree.filterNot`
130130131131`filter` takes a predicate function `path -> bool`. Only files with suffix `.nix` are candidates.
132132···136136137137Multiple filters can be combined, results must match all of them.
138138139139-##### `import-tree.match` and `import-tree.matchNot`
139139+##### ๐ณ `import-tree.match` and `import-tree.matchNot`
140140141141`match` takes a regular expression. The regex should match the full path for the path to be selected. Matching is done with `builtins.match`.
142142···146146147147Multiple match filters can be added, results must match all of them.
148148149149-##### `import-tree.map`
149149+##### ๐ด `import-tree.map`
150150151151`map` can be used to transform each path by providing a function.
152152···166166# => list of contents of all files.
167167```
168168169169-##### `import-tree.addPath`
169169+##### ๐ต `import-tree.addPath`
170170171171`addPath` can be used to prepend paths to be filtered as a setup for import-tree.
172172···175175import-tree [./vendor ./modules]
176176```
177177178178-##### `import-tree.addAPI`
178178+##### ๐ `import-tree.addAPI`
179179180180`addAPI` extends the current import-tree object with new methods.
181181···187187}
188188```
189189190190-##### `import-tree.withLib`
190190+##### ๐ฟ `import-tree.withLib`
191191192192`withLib` is required prior to invocation of any of `.leafs` or `.pipeTo` when not used as part of a nix modules evaluation.
193193···195195import-tree.withLib pkgs.lib
196196```
197197198198-##### `import-tree.pipeTo`
198198+##### ๐ฑ `import-tree.pipeTo`
199199200200`pipeTo` takes a function that will receive the list of paths.
201201···203203import-tree.pipeTo lib.id # equivalent to `.leafs`
204204```
205205206206-##### `import-tree.leafs`
206206+##### ๐ `import-tree.leafs`
207207208208`leafs` takes no arguments, it is equivalent to calling `import-tree.pipeTo lib.id`.
209209···211211import-tree.leafs
212212```
213213214214-##### `import-tree.new`
214214+##### ๐ฒ `import-tree.new`
215215216216Returns a fresh import-tree with empty state.
217217218218-##### `import-tree.initFilter`
218218+##### ๐ณ `import-tree.initFilter`
219219220220*Replaces* the initial filter which defaults to: Include files with `.nix` suffix and not having `/_` infix.
221221···224224import-tree.initFilter (lib.hasSuffix ".md")
225225```
226226227227-##### `import-tree.files`
227227+##### ๐ด `import-tree.files`
228228229229A shorthand for `import-tree.leafs.result`. Returns a list of matching files.
230230···237237]
238238```
239239240240-##### `import-tree.result`
240240+##### ๐ต `import-tree.result`
241241242242Exactly the same as calling the import-tree object with an empty list `[ ]`.
243243···262262263263### Sharing pre-configured subtrees of modules
264264265265-<details>
266266-<summary>
267267-268265Since the import-tree API is _extensible_ and lets you add paths or
269266filters at configuration time, configuration-library authors can
270267provide custom import-tree instances with an API suited for their
271268particular idioms.
272269273270@vic is using this on [Dendrix](https://github.com/vic/dendrix) for [community conventions](https://github.com/vic/dendrix/blob/main/dev/modules/community/_pipeline.nix) on tagging files.
274274-275275-</summary>
276271277272This would allow us to have community-driven *sets* of configurations,
278273much like those popular for editors: spacemacs/lazy-vim distributions.