Import all nix files in a directory tree. http://import-tree.denful.dev/
  • Nix 98.5%
  • Just 1.5%
Find a file
Jean-Baptiste G. eb1b52eaec
Fix filtering of import-tree and explicit files in path (#42)
Root files (file explicitely listed in roots) where
filtered based on their full path, so they could
easily be filtered out if located in a 'hidden'
directory.
Fix this by always including a file if its listed in roots.

For import-tree in path, use the foreign import-tree api for filtering
as this is the only way to handle relative path sanely.

Globally simplified the filtering pass, probably improving performance.
2026-09-03 14:25:10 -06:00
.github refactor: Add docs use same just ci as other projects (#34) 2026-05-14 12:06:09 -06:00
.tangled/workflows fmt 2025-11-21 16:07:00 -06:00
docs feat: improve scopedImport with _file attribute and scoped in builtins (#39) 2026-09-01 09:13:34 -06:00
tree feat: improve scopedImport with _file attribute and scoped in builtins (#39) 2026-09-01 09:13:34 -06:00
default.nix Fix filtering of import-tree and explicit files in path (#42) 2026-09-03 14:25:10 -06:00
flake.nix updating checkmate 2025-04-02 03:41:34 -06:00
Justfile refactor: Add docs use same just ci as other projects (#34) 2026-05-14 12:06:09 -06:00
LICENSE Initial commit 2025-03-13 13:48:59 +00:00
README.md refactor: Add docs use same just ci as other projects (#34) 2026-05-14 12:06:09 -06:00
shell.nix refactor: Add docs use same just ci as other projects (#34) 2026-05-14 12:06:09 -06:00
tests.nix Fix filtering of import-tree and explicit files in path (#42) 2026-09-03 14:25:10 -06:00
treefmt.toml refactor: Add docs use same just ci as other projects (#34) 2026-05-14 12:06:09 -06:00

Sponsor Vic Dendritic Nix License CI Status

import-tree and denful's dendritic libs made for you with Love++ and AI--. If you like my work, consider sponsoring

🌲🌴 import-tree 🎄🌳

Recursively import Nix modules from a directory, with a simple, extensible API.

Features

🌳 Works with NixOS, nix-darwin, home-manager, flake-parts, NixVim, etc.
🌲 Callable as a deps-free Flake or nix lib.
🌴 Sensible defaults and configurable behaviour.
🌵 Chain .filter, .match, .map for precise file selection.
🎄 Extensible: .addAPI to create domain-specific instances.
🌿 Built to enable the Dendritic Pattern on both stable/unstable Nix.
🌱 Growing community adoption

Quick Start

The following examples show how to import all module files. By default, paths having /_ are ignored. See API documentation for advanced usage.

Related projects: denful/flake-file, denful/with-inputs

Dendritic flake-parts

# flake.nix
{
  inputs.import-tree.url = "github:denful/import-tree";
  inputs.flake-parts.url = "github:hercules-ci/flake-parts";

  outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; }
   (inputs.import-tree ./modules);
}

Dendritic flake without flake-parts

# flake.nix
{
  inputs.import-tree.url = "github:denful/import-tree";
  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

  outputs = inputs:
   (inputs.nixpkgs.lib.evalModules {
      specialArgs.inputs = inputs;
      modules = [ (inputs.import-tree ./modules)  ];
   }).config;
}

Dendritic Nix (non-flakes, stable Nix)

This example uses with-inputs to provide flake-file inputs from npins sources.

# default.nix
let
  sources = import ./npins;
  with-inputs = import sources.with-inputs sources {};
  outputs = inputs:
   (inputs.nixpkgs.lib.evalModules {
      specialArgs.inputs = inputs;
      modules = [ (inputs.import-tree ./modules)  ];
   }).config;
in
with-inputs outputs

Documentation

📖 Full documentation — guides, API reference, and examples.

Testing

nix-shell ./shell.nix --run 'just ci'