How strict are you in not editing `hardware-configuration.nix`?

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:

  1. 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.)

  2. 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 edited hardware-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 how nixos-generate-config works.

3 Likes