I am attempting to install and dualboot two nixos systems, but I am having trouble understanding how to configure GRUB properly to make it work.

It might seem strange that I want to dual boot two nixos systems, but the reason is that I want one of the systems with the kernel set to CONFIG_PREEMPT_RT https://github.com/musnix/musnix. And the other system I just want as normal kernel.

I've created a partition setup with an EFI partition (nvme0n1p1) and an encrypted LVM partition (nvme0n1p2):

NAME                              MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme0n1                           259:0    0 953.9G  0 disk  
├─nvme0n1p1                       259:1    0   512M  0 part  
└─nvme0n1p2                       259:2    0 953.4G  0 part  
  └─root                          254:0    0 953.4G  0 crypt 
    ├─virtual--group-swap         254:1    0    16G  0 lvm   [SWAP]
    ├─virtual--group-normal--root 254:2    0   172G  0 lvm   
    ├─virtual--group-rt--root     254:3    0   172G  0 lvm   /
    └─virtual--group-shared--home 254:4    0 593.4G  0 lvm   /home

I've successfully installed nixos on both normal-root and on rt-root each with their own configuration.nix and hardware-configuration.nix. shared-home is just mounted as home for both systems.

In both systems hardware-configuration.nix files I am pointing fileSystems."/boot" to the EFI partition. And in both systems configuration.nix files I have made following grub configuration:

  boot.loader = {
    grub = {
      enable = true;
      efiSupport = true;
      enableCryptodisk = true;
      device = "nodev";
      useOSProber = true;
    efi.canTouchEfiVariables = true;

The problem now is that the grub menu only shows the last installed system and not both systems.

Everything works perfectly fine for the given system shown in the grub menu and I can boot into it just fine. However, I don't understand how to configure grub such that it shows both system?. I guess that I will also have a challenge on how to display the generations for both systems and still be able to distinguish between which one is which....

  • It sounds like the last installed system is replacing the GRUB EFI executable of the other system. Have you tried changing boot.loader.grub.configurationName to something different in each system? I belive the default value is an empty string. Apr 26, 2019 at 11:05
  • @EmmanuelRosa Setting boot.loader.grub.configurationName didn't seem to change anything at all. But you are right that the latest installed system overwrites /boot/grub/grub.cfg. I guess that I can make it work if I can somehow make the rt-system have its own grub.cfg in another location than the EFI partition, and then make boot.loader.grub.extraEntries in the normal-system configuration point to that other grub.cfg. I just can't seem to figure out how to do that.
    – user114791
    Apr 28, 2019 at 22:50
  • I don't see a way either. The Perl script which installs GRUB has a variable named bootPath. The script picks up the value from the environment. This variable determines the location of grub.cfg. But, I don't see how it's value can be set. I must have overlooked something. Apr 29, 2019 at 10:04
  • I've just tried running os-prober which doesn't seem to detect the Nixos install I have - maybe this might be the issue? Unless it's doing something to hide the OS it's running from? May 3, 2019 at 17:15

1 Answer 1


You can add a custom menu entry to grub in your system configuration file /etc/nixos/configuration.nix:

boot.loader.grub.extraEntries = ''
  menuentry "Nix-OS custom configuration" {
    search --set=myroot --fs-uuid <UUID-HERE>
    configfile "($myroot)/boot/grub/grub.cfg"

use blkid to set the UUID of the old-nixos root partition, then update your system with the new configuration.

# nixos-rebuild switch
  • I decided to make 2 EFI boot partitions one for the normal system and one for the rt-system. The first of the EFI partitions contains grub config and boot information for the normal system and the second contains the same for the rt-system. After each nixos-rebuild switch on the rt-system, I manually copy the new entries from the grub.cfg into boot.loader.grub.extraEntries as you proposed (obv. I need to rebuild the normal system each time after that) Everything shows up correctly in the grub menu. I'm very satisfied with this method because I'm in control and understand what's going on.
    – user114791
    May 25, 2019 at 20:24

You must log in to answer this question.