I recently pushed a new version of my nixos configuration to my Forgejo, and I want to talk about that.
It all started when I saw someone talking about flake-parts over on Reddit. Lost the post, unfortunately. They were talking about the benefits of the dendritic pattern.
To be honest, I’m still not sure I understand it entirely; however, when I took a look at what exactly they were doing, I realized that well, it was exactly what I had been doing, just way better and less fragile. I had been creating long default.nix files with lists of options that imported subfiles that accepted those options. It was a LOT of boilerplate, hard to maintain, and honestly, not that great for modifying, and honestly very brittle. I couldn’t move a file without potentially breaking 12 different things.
With flake parts and import-tree, all of that is solved. As a bonus, it also gives me an opportunity to declutter my configuration, which honestly was LONG overdue. Significantly too much cruft was left over. As a fun side effect of that, my laptop went from taking almost 10 minutes to evaluate my configuration to under 3, (Please Nix, Parallel Evaluation Soon!) which is really saying something when you consider that this configuration technically leads to likely more evaluation overall, as every file is always imported, not just the ones I explicitly list.
It took me a couple of days to do this - My configuration is huge, and spread across 4 systems, with legacy stuff from another 2 systems (A Core Duo (not Core2Duo) MacBook Pro, and an HP Pavilion DV7 6197ca).
The end result, though, I love it. It’s fantastic. It’s faster, leaner, I was able to fix mistakes that I made YEARS ago that I couldn’t have fixed without this major refactor… The list goes on.
Now the question is, should you, reader, do the same? I’d say… Consider it.
I found it quite valuable, and it makes my future maintenance burden less - made an almost 400 line refactor touching about 10 files today, which would have been a task prior. I would have had to add all kinds of guards to prevent the code running on the wrong machines and such, but now it’s just… Clean. It works.
But yeah. That’s just me. I am mostly just excited to write about it haha.
Feel free to poke me over on Mastodon if you wanna talk about this post or spot anything that needs a correction!