Skip to content

import-tree

import-tree recursively discovers and imports all Nix files in a directory. In Dendritic setups, where every file is Nix module (for instance flake-parts module) with the same semantic meaning, this eliminates manual import lists entirely.

{
inputs.import-tree.url = "github:vic/import-tree";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; }
(inputs.import-tree ./modules);
}

By default, paths containing /_ are ignored, giving you a convention for private/helper files.

  • Works with NixOS, nix-darwin, home-manager, flake-parts, NixVim, and more
  • Callable as a zero-dependency flake or as a Nix library
  • Sensible defaults with configurable behavior
  • API for listing custom file types with filters and transformations
  • Extensible: add your own API methods to tailor import-tree objects
  • Useful for selecting subsets of repositories — import only the parts you need

import-tree is the mechanism that makes dendrix possible: community repositories expose import-trees that users can selectively consume. Combined with flake-file, imported modules can even declare their own flake inputs.

Source Code Documentation Support this project
Hire Vic Consultancy Sponsor