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

Add `configurationEntryPoint` option #10

Open koiuo opened 4 months ago

koiuo commented 4 months ago

First of all, thanks for this amazing library. Having an opinionated framework for modules organization helped me tame my configuration as it grew.

Still, I had one tooling/usability issue: while refactoring my configuration I often got lost in the multitude of default.nix files. Before I migrated to this library I used to have hosts configured in configuration.nix, users — in home.nix, which gave me a very helpful optical clue. Also, I frankly missed my old directory structure, where all hosts, both darwin and nixos, resided in a single ./hosts directory.

I made a small change to this lib, which improved usability for me significantly!

My configuration isn't public, but let me illustrate, what kind of configurations are possible with this change:

ezConfigs configuration

      ezConfigs = {
        root = ./.;
        globalArgs = { inherit inputs; };
        home = {
          configurationsDirectory = ./users;
          configurationEntryPoint = "home.nix";
          modulesDirectory = ./modules/home-manager;
        };
        nixos = {
          configurationsDirectory = ./hosts;
          configurationEntryPoint = "configuration.nix";
          modulesDirectory = ./modules/nixos;
        };
        darwin = {
          configurationsDirectory = ./hosts;
          configurationEntryPoint = "darwin.nix";
          modulesDirectory = ./modules/darwin;
        };
      };

Directory structure of my flake (with some nodes omitted for brevity)

├── flake.nix
├── hosts
│   ├── iota
│   │   ├── configuration.nix
│   │   └── hardware-configuration.nix
│   └── UA748910
│       └── darwin.nix
├── modules
│   ├── darwin
│   ├── home-manager
│   │   ├── default.nix
│   │   ├── gopass.nix
│   │   ├── home-manager.nix
│   │   ├── mpv.nix
│   │   ├── rofi.nix
│   │   ├── shell-generic.nix
│   │   └── starship.nix
│   └── nixos
│       ├── default.nix
│       └── globaprotect
│           ├── default.nix
│           └── csd.sh
├── overlays
│   └── ansel.nix
└── users
    └── koiuo
        ├── home.nix
        ├── i3.conf
        └── icc
            ├── B133HAN05.A D6500 2.2 M-S XYZLUT+MTX.icc
            └── LG HDR 4K D6500 2.2 M-S XYZLUT+MTX.icc

I believe this feature may be useful to others, and I'd love to see it accepted upstream.