NixOS fails to boot after Windows install

Fixed it.

  1. Boot with a NixOS live USB
  2. Enter Terminal
  3. First, check if the NVMe drive has any partitions:
    sudo fdisk -l /dev/nvme0n1
  4. Try to recover the partition table using testdisk:
    sudo nix-shell -p testdisk
    sudo testdisk /dev/nvme0n1
  5. If you can see the partitions but can’t mount them, try checking the filesystems:
    # For ext4 partitions
    sudo fsck -f /dev/nvme0n1px # Replace x with partition number
  6. If you still can’t access the partition, try repairing the GPT table first:
    sudo gdisk /dev/nvme0n1
    Type r for recovery/transformation menu
    Type b to rebuild the GPT table from backup
    Type w to write changes and exit
  7. After fixing the GPT table, try mounting again:
    sudo mkdir -p /mnt
    sudo mount /dev/nvme0n1x /mnt