Insert picture of Xzibit here.
Last year, some clever people came up with an interesting approach on organizing your Nix (and in most cases, NixOS) modules. I’m not going into the finer details here as there are excellent resources like this site which discusses the approach at length. In short, you get rid of stuff like file-based importing of modules. Module arguments become attributes stored as part of your config.
However, where most posts fall short is to show and explain how the concept can be meaningfully applied. There is the excellent infrastructure repository by the original inventor, however that one isn’t documented in such a depth that the inner workings immediately become clear with regards to how a NixOS configuration is actually built from such a setup. In this (series of) blog post(s), I’ll build not only one, but two repositories using this approach – one that holds a very simple package, a NixOS module that goes along with it plus a devshell that makes use of the program in that package, and another one that holds NixOS configurations that make use of that module.
Currently in the process of writing this, but I felt like the current progress already has some stuff worth sharing. I’d be happy for some feedback and possible improvements!
I recently changed my nixos configs to this approach. Takes a bit to remember where I put everything and what modules things are in but in the long term it makes things easier to manage. Also makes things easier if I need to turn modules on or off for whatever reason.
That being said does take a bit of work to get everything set up but in the long run it’s worth it.
It’s certainly very helpful with that, I can say I learned quite a bit about nix, but also about flake-parts during the migration and I’d say the latter is criminally underrated in the community.
the thing with NixOS is there’s really no right or wrong way to configure your system. I know a guy that just straight up has a single configuration file and then just uses comma for everything. like practically nothing is installed. when he uses firefox its “, firefox” in a terminal. he likes it.
I recently changed my nixos configs to this approach. Takes a bit to remember where I put everything and what modules things are in but in the long term it makes things easier to manage. Also makes things easier if I need to turn modules on or off for whatever reason.
That being said does take a bit of work to get everything set up but in the long run it’s worth it.
What do you mean? Dendritic approach or having modules in a separate flake? Or both?
going the Dendtritic Approach.
It’s certainly very helpful with that, I can say I learned quite a bit about nix, but also about flake-parts during the migration and I’d say the latter is criminally underrated in the community.
the thing with NixOS is there’s really no right or wrong way to configure your system. I know a guy that just straight up has a single configuration file and then just uses comma for everything. like practically nothing is installed. when he uses firefox its “, firefox” in a terminal. he likes it.