On arch linux, if the partitions are partitioned by GPT Partition type UUID [1] correctly, systemd-boot automatically discovers and mounts the partitions correctly [2].
This even works with luks-encrypted root partitions.
I never had to generate an /etc/fstab nor did I ever have to fiddle with /dev/disk/by-uuid/
I used truly the same system, could clone it to a new ssd’s root partition and plug and play. [3]
However, on nixos I have not found such an option. The hardware-configuration.nix embeds hardware-specific disk uuids, which is entirely unnecessary.
Is GPT partition automounting possible on nixOS?
[1]
[2]
https://wiki.archlinux.org/title/Systemd#GPT_partition_automounting
[3]
BOOT_PART_NAME='Boot Partition'
ROOT_PART_NAME='Root Partition'
BOOT_PART_TYPE_GUID='c12a7328-f81f-11d2-ba4b-00a0c93ec93b'
ROOT_PART_TYPE_GUID='4f68bce3-e8cd-4db1-96e7-fbcaf984b709'
create_boot_partition() {
sudo sgdisk \
--new='0:0:+1GiB' \
--change-name="0:${BOOT_PART_NAME}" \
--typecode="0:${BOOT_PART_TYPE_GUID}" \
"${DISK}"
}
create_root_partition() {
sudo sgdisk \
--new='0:0:' \
--change-name="0:${ROOT_PART_NAME}" \
--typecode="0:${ROOT_PART_TYPE_GUID}" \
"${DISK}"
}