Sorry if the title is not very clear. I was not sure how to summarize my doubt in a single sentence that made sense.
I’m looking for an explanation on the philosophy behind having your system configurations as a flake stored in a git repository so you can track your changes and do your “configuration as code” and start “treating your machines as cattle” thingy.
So far, I have only used Nix for defining my macOS configurations, and to be honest, I never used my two Mac machines as daily drivers at once. I always stick to one of them and keep iterating my configuration on that single machine.
The idea was to expand my flake into a kind of all-my-systems store, including some VMs of my home lab, so I don’t have to take notes on how to get some VMs back to the intended state.
The idea is that I can have everything in my repository, and all that they need when I get a new laptop or a new whatever is just to use my flake to set everything up. That is the goal, and that is what attracted me to Nix.
However, every time I check how to set a new NixOS machine to use your flake (which I haven’t done yet) I am greeted it with some steps that, in my opinion, go against this philosophy. You are supposed to:
- Set a new NixOS machine.
- Copy that specific machine’s hardware configuration into your flake.
- Store that hardware configuration into your flake.
How is that reproducible? What if I spin up another VM that I want to be exactly the same configuration, but I prefer to use a different network card, or I wanted to have two network cards? Then my Nix configuration, which is only focused on user-land things, will need a new hardware definition added to my flake? This part is what confuses me and makes me think that this is not the right way to “treat your hosts as cattle”. It feels more like “have a spreadsheet with all your pets” to me.
This gets even more confusing if you decide to use an actual physical machine, where the hardware will be very specific to that machine. If you then decide to change it because, let’s say, your actual physical machine broke, you will have to modify the hardware section of your flake to accommodate your new machine?
Can someone clarify me if people use nix and then keep a curated set of pets? Or how does people do this?