I triple boot Arch Linux, Gentoo Linux and NixOS. The problem is that these operating systems, specifically their version of the GRUB2 bootloader, do not play nice with one another. If I set up the bootloader with NixOS then the Gentoo and NixOS entries boot fine but the Arch Linux entries in the GRUB2 config actually boot NixOS not Arch Linux. If I set up GRUB2 from Arch Linux NixOS isn't recognized, but Gentoo is (os-prober is installed). My partitions are like this:
/dev/sda - /dev/sda1 - my EFI partition - /dev/sda2 - my Gentoo partition - /dev/sda3 - my Arch Linux partition - /dev/sda4 - my NixOS partition - /dev/sda5 - my swap partition /dev/sdb - /dev/sdb1 - my data partition on which I store config files, documents, etc.
/dev/sda has a GPT partition table with a protective MBR, if relevant.
So my question is, is there is a way to get Arch Linux's GRUB2 bootloader to recognize and create appropriate boot entries for NixOS? Or if not, is there a way to get NixOS' bootloader to create appropriate entries for Arch Linux? Here is my configuration.nix file and here is my hardware-configuration.nix file.
To be clear when I set up GRUB2 on one of these systems to manager bootloading I make sure that only that distribution's bootloader is managing it. The other distro's bootloader files I delete from the EFI partition. For example, when I used NixOS to manage bootloading I deleted the /boot/EFI/arch folder (where EFI is mounted on /boot) and moved the Arch Linux kernel images from the EFI partition onto the Arch Linux root partition in its /boot folder.
EDIT: I've managed to get NixOS to almost set up GRUB2 properly to run Arch. I noticed that in /etc/fstab for Arch it was still mounting /dev/sda1 on /boot when it wasn't meant to anymore as I had changed the bootloader from being from Arch to being from NixOS.
The only problem with its config file now is that it has:
initrd /boot/intel-ucode.img /boot/initramfs-linux.img
initrd /boot/intel-ucode.img /boot/initramfs-linux-fallback.img
depending on the precise entry. So the result is that if I boot Arch it goes into kernel panic. So how do I add the appropriate /boot/initramfs-linux*.img line without manually editing this file everytime?