One thing I didn’t see mentioned so far is that one benefit of not editing hardware-configuration.nix
is that you can in theory re-run nixos-generate-config
and get the same output (or at least something relatively similar).
This can be helpful in the following situations:
-
You’ve made some changes to
hardware-configuration.nix
but they are causing problems, so you want to go back to the “default”. (Although in this situation it might be better to just version control your NixOS configuration.) -
You’ve upgraded to a later version of NixOS, and you want to see if there have been any changes to
nixos-generate-config
that give you a configuration more appropriate for your hardware (or a recent kernel). If you’ve editedhardware-configuration.nix
by hand, it can be a little difficult to make out what changes are necessary and need to be copied over, and which things are just strict improvements by people in hownixos-generate-config
works.