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
fat32
boot
partition (labelledboot-new
) and aroot
partition (labelledroot-new
) with a filesystem of your choice. - Ensure the
boot
flag is set on theboot
partition (without it, in my experience,nixos-install
wasn’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-config
and 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/$USER
where$USER
is your username. chown -R $USER /nix/var/nix/{profiles,gcroots}/per-user/$USER
nixos-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.