So, in the end, this turned out to be slightly nontrivial.
I had to also generate the directory as indicated here and then chown it as my user.
Things worked flawlessly afterward.
Steps:
- Install new drive into the system.
- Create a GPT partition table, with at least two partitions. A
fat32bootpartition (labelledboot-new) and arootpartition (labelledroot-new) with a filesystem of your choice. - Ensure the
bootflag is set on thebootpartition (without it, in my experience,nixos-installwasn’t installing the bootloader). - Create a new directory for the installation, say
/mnt/new. - Mount partitions:
mount /dev/disk/by-label/root-new /mnt/new && \
mkdir /mnt/new/boot && \
mount /dev/disk/by-label/boot-new /mnt/new/boot
mkdir /mnt/new/etc && cp -r /etc/nixos /mnt/new/etc/cd /mnt/new-
nixos-generate-configand adjust values infilesystems nixos-install --root /mnt/new
This should install NixOS on the new drive. Once done, reboot and select the new drive from the boot order in BIOS.
Once booted as su, do,
-
mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USERwhere$USERis your username. chown -R $USER /nix/var/nix/{profiles,gcroots}/per-user/$USERnixos-rebuild switch
As usual, with some software, reproducibility goes out of the window. I needed to re-instantiate nextcloud-client and gnome-keyring. Trivial, but doesn’t work out of the box.