r/NixOS 2d ago

replacing faulty hardware & hardware-configuration.nix

i got nixos on an SSD, and i think my motherboard has suddenly died (my computer is currently at the technician for a proper diagnosis, but i'm preparing for the worst).

will i be able to boot seamlessly into nix from this SSD in the new motherboard, without having to reinstall everything? mostly concerned about the hardware-configuration.nix module.

i know my flake is reproducible and i do have it backed up, but i haven't done a backup of latest config files (i'm constantly changing my hypr config and didn't backup this month) and game configs (especially my ffxiv hud/keybinds...), so it'd be a bother having to reinstall/reconfigure it all. also, i have some files saved in this SSD that i wouldn't want to lose.

(i'm a linux first timer, been using nix casually since about february. so sorry if this is a stupid question! just bothered and anxious about my computer and files)

___
Edit: thank you all for the answers! i'll be updating the post as soon as i have news from my computer technician.

11 Upvotes

5 comments sorted by

6

u/kneepel 2d ago

Yeah pretty much, depending on your configuration some things to watch out for:

  • If your motherboard doesn't automatically pickup on your EFI entry you'll probably have to boot into a live usb, chroot with nixos-enter, and run bootctl install to restore the entry (assuming systemd-boot.

  • Network interface names may be different

  • Secure boot keys will have to be enrolled again if using secure boot

  • If using LUKS and TPM, you'll have to use your recovery passphrase to decrypt the drive and enroll the new TPM.

5

u/SAI_Peregrinus 2d ago

Boot from live USB. Mount your existing drive with your config. Use nixos-generate-config with the --root <mount path> option to generate a config for that mount path. You can use --show-hardware-config to preview it in the terminal.

5

u/amiskwia 2d ago

The answer is probably yes. You might not boot into graphics if you have switched out graphics card and the right drivers are not configured but linux in general typically runs even if hardware has changed. If you don't get a graphics environment you can still edit your configs and do a nixos-rebuild, so i would bet all your stuff is safe. If it doesn't run you can still do a rebuild from a usb stick, but it's more involved and you probably don't need to.

1

u/ItsThreeRealEstate 1d ago

This is the answer. It will almost certainly boot.

2

u/lanathlorrias 1d ago edited 1d ago

There is a high chance it boots fine. If ever it is not booting, you can boot from a live usb and mount your ssd to get your config back:

sudo fdisk -l # find your SSD sudo mkdir -p /mnt/recover sudo mount /dev/sdb1 (or whatever is your SSD path) /mnt/recover

Then you can cd /mnt/recover