Wrong swap partition detected by nixos-generate-config on fresh install?

I’m in Ubuntu and I tried the method of installation that uses curl to download nix to my local user as detailed in Installing from another Linux distribution:

curl https://nixos.org/nix/install | sh
# now open fresh shell

Then I created the partitions on the target disk /dev/sdb and mounted them in /mnt, and finally when I ran

sudo `which nixos-generate-config` --root /mnt

I checked in /mnt/etc/nixos/hardware-configuration.nix and I saw that the root and boot partitions had UUIDs pointing to partitions on sdb as expected, but the UUID for swap is pointing to a partition that is not on sdb (/dev/dm-1). This part:

  swapDevices =
    [ {
       # This was not the swap partition I created while following the manual:
      device = "/dev/disk/by-uuid/2b123903-086e-43e8-2ebe-46c5cedb53e3"; }

Am I correct that /mnt/etc/nixos/hardware-configuration.nix has the wrong UUID for the boot partition?

I updated the file to have the UUID of the expected swap partition that I created on sdb.

i tried the installation steps over from scratch. This time, I tried running the suggested swapon /dev/sdb2 command before generating the nix config.

Now when I opened /mnt/etc/nixos/hardware-configuration.nix, I saw that it listed two swap partitions:

  swapDevices =
    [ { device = "/dev/disk/by-uuid/2db954eb-749d-4e90-a715-cdecd23daba5"; }
      { device = "/dev/disk/by-uuid/d66cc807-7301-4ac3-8d4c-3d06b9232d86"; }

I’ll delete the one I don’t want.

I’m guessing that the swapon command added my new swap partition to my current Ubuntu’s swap devices, and that then the nix hardware configurator detected both the original Ubuntu swap and the new one, and listed them both.

I think we should update this part of the manual because if I had not checked inside the hardware config file, I would not have noticed any problem and would have continued while thinking everything was all good.

I’m not sure what would be the correct way to handle this part in the manual, but it definitely needs something so that people will have the swap partition as expected while following all steps in the manual.

Looks like I configured my system correctly, deleting the partition I didn’t need (from my other Ubuntu Linux where I ran the installation from).

I’ve opened an issue about this at https://github.com/NixOS/nix/issues/3310.