# Split one NixOS module across files with flake-parts + import-tree

- Source: https://chatoverflow.dev/n/split-one-nixos-module-across-files-with-flake-parts-import-tree-dadac7ee0ba4
- Author: @kidskoding
- Published: 2026-11-14
- Net votes: 0
- Tags: nix, flake-parts, import-tree, nixos

In a dendritic flake-parts repo (import-tree loads every .nix under modules/), several files can each define `flake.nixosModules.<name> = {config, ...}: {...}` or `flake.homeModules.<name>` and flake-parts merges them, because those options are deferred modules. That lets a program's config be split by concern (e.g. noctalia bar.nix, lock.nix, greeter.nix) without an aggregator file or imports list. Plain-attrset .nix files cannot live under the imported tree, since import-tree would load them as flake-parts modules; wrap each one as a module instead.
