The NixOS manual says in Section 2.3 that the UEFI partition should be mounted at /mnt/boot, which probably means that in the final system it will be mounted at /boot. However, to my knowledge, the usual thing is to mount it at /boot/efi. This is what GRUB should expect by default, and it has the advantage that the UEFI partition isn’t spoiled with GRUB-specific stuff.
Why does the manual advise to mount the UEFI partition at /boot, and is it a problem to mount in at /boot/efi instead?
When installing from another Linux distribution, /mnt is what will become /. As a result, the installer will write the things that are supposed to go into /boot to the UEFI partition, since it is mounted at /mnt/boot. However, only the things supposed to go into /boot/efi should be written to the UEFI partition.
The code snippets you posted suggest to me that the installer will create an efi directory within the UEFI partition, which is not what is typically done, according to my knowledge.
Just to share my experience, coming from arch. When I setup NixOS for the first time I tried to set up an ESP as per EFI system partition - ArchWiki. When I found that I couldn’t setup such a partition, I felt NixOS was somewhat inflexible in this regard.
I think a key difference from other distros is that NixOS sets up your old configurations as boot options so you can very easily boot into an old generation if you need to rollback, and you can do so even if your kernel or initrd is broken. Really really powerful tie-in to the generation concept which has saved me many times, but probably makes the boot process a bit inflexible to achieve this setup.
Is it vital to put Linux-specific stuff into the UEFI partition for that to work? I don’t suppose it is, as the ability to roll back also exists for BIOS-based installations.
Generally you install NixOS with nixos-install --root=/mnt, so the configuration doesn’t have to be concerned about it.
This should be able to be achieved with boot.loader.efi.efiSysMountPoint = "/". But I haven’t tested it. Also it would mean that the entries would be mounted to /loader/entries which may not be desired behavior.
Maybe it’s time to update the boot conventions, but I’m not familiar enough with UEFI to do the work.
The arch wiki does say this though:
mount ESP to /boot. This is the preferred method when directly booting an EFISTUB kernel from UEFI or booting it via a boot manager like systemd-boot.
For nixos, generally we do grub or efi+systemd-boot. So the current /boot convention seems to make sense. But this is also outside my comfort zone, so I may be wrong.