jakehamilton / config

One Nix flake to rule them all.
Other
378 stars 22 forks source link

Question about design choices #4

Closed chz101 closed 1 year ago

chz101 commented 1 year ago

Hello!

I was just wondering what influenced your decision to turn individual apps into modules that you can enable and disable as opposed to doing something like Misterio77 where adding a file to the imports list decides if it's used or not.

I've been following his configuration style but ran into a few pain points, notably:

I was hoping to fix this by using some kind of global attribute set with conditional imports, but heard that importing all modules and enabling them is better practice (No infinite recursions), and eventually stumbled across your config through a reddit post.

I'm still a little hesitant to do such a large refactor and just wanted to ask for your opinion about the benefits/drawbacks compared to Misterio77's style and what your experience has been like dealing with the issues listed above, as well as any suggestions you may have.

Sorry if this is the wrong place to post this. You seem really experienced and approachable so I thought I'd ask.

Thanks also for sharing you configuration! It's nice seeing how others set things up and I've learned alot.

Cheers!

jakehamilton commented 1 year ago

Hey there! Gosh did I forget about this issue. Sorry!

NixOS module imports have to be static otherwise the module system explodes. So conditional imports aren't really possible. I think plain static imports like Misterio77 does can work for people up to a certain point. However, when you start managing multiple systems or need to abstract that configuration you'll need to reach for options. You could decide to apply all of your module configuration by default, but that also means you wouldn't be able to disable any functionality on certain machines. Instead, it's best to add an enable option to each module. That way you can easily toggle specific functionality on or off.

I personally think that creating modules like this one are the way to go. That makes it easy to quickly enable/disable specific features of your config. It also makes it possible to abstract your configuration and customize existing modules like this one does.

chz101 commented 1 year ago

Thanks for getting back to me!

I ended up doing something very similar for the exact reasons you laid out. I'm finding it a little tedious to enable things all the way up the hierarchy, but I can see it paying off already in terms of organizing between my two machines.

Thanks again for all your inspiration! Hopefully things are smooth going forward.