EFI boot is configured by writing configuration to the NVRAM, which is done as expected.
The issue is that some firmware implementations, on upgrade, will clear the NVRAM to reset everything to defaults. This affects any setting you could have configured in the firmware interface, and more annoyingly, the boot options.
If you’re using grub
you could use boot.loader.grub.efiInstallAsRemovable
to install it at the default fallback location, meaning that selecting the disk will boot that program.
What I personally do, for bad UEFI implementations (mostly those that reset themselves unexpectedly) is to not rely on the bootloader for boot order, but instead rely on another bootloader that has been built to chainload other EFI programs. This bootloader is rEFInd, and I have some notes on its wiki page.
I basically copy that bootloader on the default fallback location, and that bootloader saves its configuration to the ESP, meaning that even when resetting the NVRAM, it will know which option was last booted. It would also have the advantage of keeping track of the last booted option if you did dual boot.
From rEFInd, you would select the Boot EFI\NixOS-boot\grubx64.efi from ESP
option (or equivalent for systemd-boot). It will remember the last selected boot option.
A drawback is that it adds one level of indirection to the boot time, in addition to a long timeout. Its default would add, IIRC, 10 seconds to the unattended boot time. It is possible to configure it to a lower timeout if wanted.
Neither of the option is technically better, but the option to install GRUB “as removable” is probably the better one to reduce complexity in the boot chain.