Adding NixOS to existing grub bootloader

I am dualbooting with CachyOS (https://cachyos.org/) and NixOS. The idea is to use Nix for development and CachyOS for gaming. I installed CachyOS first, onto a grub bootloader. Now, I have Nix installed, but it is using systemd as its bootloader. I would like to have these all on the same grub menu, if possible. I looked into some solutions, but couldn’t find anything.

The simplest thing is to let each distro manage its own boot loader have one of them chainload the other. Assuming they’re on the same ESP:

boot.loader.systemd-boot.extraEntries.cachyos = ''
  title CachyOS
  efi /path/to/cachyos/grubx64.efi
'';

(note that’s the path under the ESP)

1 Like

Thanks for the solution, but is it possible to add Nix to the Cachy grub bootloader instead of adding Cachy to systemd?

Nixos must manage its own bootloader. That bootloader can be chainloaded from another bootloader or something, but it has to be under the control of nixos or you won’t be able to boot into new generations. The bootloader entry actually specifies the nix store path of the generation to boot, so every nixos-rebuild needs to change the menu.

Yea, that’s what I meant by “have one of them chainload the other.” I showed the easy way to have NixOS’s boot loader chainload CachyOS’s boot loader, but you could configure CachyOS’s boot loader to chainload NixOS’s instead. That’s just not something I can show you how to do with a NixOS config, for obvious reasons :stuck_out_tongue: It’s probably using grub, which means you just need to look into making a new menu entry in its grub.cfg that uses the chainload command to load NixOS’s /EFI/systemd/systemd-bootx64.efi boot loader.

Okay, thanks for the help! So I just have to manually edit grub.cfg?

I don’t know enough about cachyos to say whether or not you should edit its grub.cfg file manually or if they have some tool they expect you to use.