Assumptions

  1. you have all secrets configured using agenix (sops should work too, but I am not using it ;))
  2. you want to keep your past configuration
  3. you already have an existing nixos installation

How-To

  1. follow the steps from the NixOS Manual stop just before the nixos-install command
    • NOTE: for the following steps it is assumed that the partitions are mounted on /mnt and /mnt/boot respectively
  2. copy your agenix identityPaths to the new drive: for me (default agenix configuration) this could be achieved by: cp /etc/ssh/ssh_host_* /mnt/etc/ssh
  3. move your generated hardware-configuration.nix to your previous hardware-configuration path - the rest should stay the same
  4. (untested) to avoid unneccesary readownloads you might be able to copy over /nix/store
  5. now run nixos-install
  6. change the boot order in your BIOS / UEFI settings