NixOs minimal install in dual boot

I need to resize my EFI partition to 512MB. I found this answer to resize EFI for dual boot: linux - How to resize the EFI System Partition? - Super User. But do I run the commands while booting from USB NixOs install or in my current linux distro? Also, I want to know if its possible to move all partitions so that the resized EFI partition becomes the first partition in my disk.

Few thoughts:

  1. Resizing the UEFI partition is one thing, but often Windows partitions are sitting right behind it. That complicates things, because shrinking a partition and moving the beginning requires relocating all of the data in that partition.

  2. If you’re not keeping the Windows partitions, you might as well destroy the UEFI and start from scratch.

  3. We now have XBOOTLDR support in NixOS, so you don’t even need to resize the UEFI partition.

If you’re wanting to do a dual boot, and keep Windows, I recommend this approach:

  • shrink the windows partition in place (this does not require moving the data of those partitions and will be safer and faster, and you can shrink that part from inside Windows)
  • make sure to shrink it enough for a 1GB xbootldr partition, and whatever partitions/size you want for NixOS
  • add a new 1GB partition, with the right UUID for xbootldr
  • add whatever Linux partitions you want
  • configure xbootldr support, install

This lets you leave the default UEFI partition the same size, not move the Windows partition. Generally I consider it a safer approach, if your goal is to keep a dual boot and existing Windows install.