ehllie / ez-configs

A flake-parts module for simple nixos, darwin and home-manager configurations using project directory structure
Mozilla Public License 2.0
59 stars 13 forks source link

`readModules`: recurse into subdirectories #4

Closed dwagenk closed 9 months ago

dwagenk commented 9 months ago

Hey. I was wondering if readModules should recurse into subdirectories and produce a nested attrSet of modules?

I migrated from a much more convoluted and deprecated framework for organizing the nixos configs to ez-configs and noticed the difference in behavior.

I got used to structuring the modules this way and was wondering if it was a deliberate decision for ez-configs readModules to produce a flat set of modules.

For a directory structure

├── A
│   └── default.nix
├── B.nix
└── C
    ├── D.nix
    ├── non-nix-file-ignored.txt
    └── E
        ├── default.nix
        ├── some-helper-file-ignored.nix
        └── F
            └── another-helper-file-ignored.nix

the current implementation produces an attrSet like this

{
  A = "/path/to/A/default.nix";
  B = "/path/to/B.nix";
}

while the recursive implementation proposed in this PR would produce an attrSet like this

{
  A = "/path/to/A/default.nix";
  B = "/path/to/B.nix";
  C = {
    D = "/path/to/C/D.nix";
    E = "/path/to/C/E/default.nix";
  };
}
ehllie commented 9 months ago

I intentionally decided not to recursively descend into the directories. The flake outputs are conventionally flat, and I have not seen anyone create things like nixosConfigurations.attrName.systemName