Hardware upgrade

Hi. Stupid question, but I would like to know if Nixos will rewrite its HW configuration.nix upon boot on new motherboard or if it will break something at first start upon new hardware.

Not stupid at all! No, hardware-configuration.nix is not automatically updated. It is written by nixos-generate-config as a convenience. You can manually regenerate it later using nixos-generate-config yourself, either while running on install media, or after booting into the system. I think in the vast majority of cases, hardware changes will not make the machine unbootable, so you can usually just update it after booting in.

The majority of things will not change. The most important things are the filesystems and the initrd modules. The filesystem configs will not change from a motherboard swap. It is technically possible that the ideal set of modules to put into the initrd will change if you swap motherboards, but I think for the vast majority of machines what you already have in there is likely good enough to boot on any random other motherboard; mostly, it just needs to contain the right modules to be able to mount the root filesystem and continue the boot process. (That said, I recommend still having NixOS install media ready before doing so just in case it doesn’t boot.)

2 Likes

Thank you. So I should expect to have to check that SSDs and HDDs are correctly linked in the nix files (actually something I had totally blocked out off my mind). But in a worse case scenario, I still have my .nix files on a server to rebuild the system just in case.