All NixOS SystemD Entries cant boot, How do I Recover?

Was messing around with my system configuration, adding some kernel params, and created some unbootable configurations. Not sure the cause but the boot would lock up with the screen showing loading amdgpu. At this point, Id just force power off my pc and choose the last working stystem config. I didnt think ahead and kept trying to make a working config, and then the 5 boot options quickly all became unbootable configs. Now I cant get into my machine and make a working config. Do I just need to reinstall NixOS?

Here’s what I do when I need to recover:

  1. Boot custom ISO with my SSH key pre-baked, and a startup script to show tailscale QR login.
  2. I boot the custom ISO, scan the QR, get the installer on my tailscale network.
  3. Remote into the machine.
  4. Mount the existing partitions.
  5. “Re-install” NixOS - often this is done by pushing my built system to cachix, and then running nixos-install with extra flags to pull from my cachix mirror, but you can do this however you normally like to install NixOS.

(Of course, you can skip the first 3 tailscale-related steps by just booting the normal ISO and working with the machine interactively)

When you “re-install” NixOS there, you’ll only have to copy a few store paths and update the system profile. So it will be very fast, compared to a normal full re-partition, re-install from scratch.

Ok, some of that went over my head. Im familiar with tailscale, not sure what cachix is.

I should mention, Im using Nix Flakes with my install.
So what Im understanding is I can boot up with a minimal NixOS installation image, follow the guide on the wiki, just skip partitioning, and I can just rebuild my current system config? Im not totally sure how the whole install process works, would /mnt be my previous root directory?

Sorry, ignore the cachix bit. It’s just a Nix store cache, like cache.nixos.org. So you could pre-build the installation system and the install would just be downloading the pre-built closure.

tl;dr: Do a normal install, but just skip partitioning+formatting. You will want to mount the partitions the same way you normally would.

Normally the installer would need to download+copy the entire system closure, but in your case, your store will already contain almost all of those paths, so the install will be very fast.