NixOS new generations in Grub apear only after updating on Arch

Hello!
I use GRUB from arch and to update Grub configuration i should use:
grub-mkconfig -o /boot/grub/grub.cfg. (GRUB - ArchWiki)
If i didn’t do this on my Arch setup i can’t see now generations from nixos-rebuild.

So every time when i use nixos-rebuild i shoul load my arch system and regenerate config for Grub. Is there any way to automate it?

Use nixos’ bootloader, not arch’s. Most likely the only reason you’re seeing nixos’ entries at all is because arch is replicating them.

Fundamentally, nixos really needs to be in control of its bootloader. These kinds of problems always exist if it isn’t. You can chainload between multiple bootloaders to manage multiple OSes, or you can let nixos’ bootloader take over for booting the other OSes.

Then I think allowing NixOS to control the bootloader is a good idea, but how can I do this without risk? How can I simply change who controls the bootloader?

Messing with bootloaders is never entirely without risk. And I don’t have enough information about your circumstances to give you specific instructions. However I do have one tip: there’s a good chance both bootloaders are installed and working. If so, you can likely load nixos’ bootloader from your motherboard firmware without actually changing anything, as well as change the preference order for the bootloaders that are tried.

1 Like

About information.


My main OS is arch and nix installed on additional drive, Grub is on drive where arch is installed.
Also, i remember that Grub can launch other boot loader (Read somewhere about it, but can’t find), so probably better idea will be launch NixOS boot loader from my main boot loader.

Found, it’s named Chainloading.

I see you made no EFI System Partition on the drive you installed nixos on… and nothing is apparently mounted on /boot in your nixos system. So your bootloader configuration in nixos is likely more broken than I thought.

Better will be if i reinstall NixOS?
How should look my partition for NixOS?

Just to double-check, you are using EFI firmware, right? This isn’t somehow still a BIOS system?

(I’m assuming that 1G partition you’ve said is your arch boot partition is an EFI System Partition, but it could just be a small partition used by a BIOS-style grub installation…)

My BIOS system is from 2012.
Fortunately, I have UEFI support and Grub works on it, as far as I understand.

But when i trying to launch installer for NixOS in UEFI mode it just didn’t work and send me error “Failed to install bootloader”, so i launch in normal mode and it works.

Also my boot folder has EFI directory.

Ok, so your nixos installation, at least, is BIOS mode… I wasn’t expecting that.

In that case, chainloading between an EFI bootloader and a BIOS bootloader is likely impossible. You can probably still use your firmware itself to choose which bootloader you start, however.

Which boot folder? On what OS? Where is it mounted from? I believe arch typically mounts the EFI System Partition on /boot/EFI. (whereas nixos usually mounts it directly on /boot)

My arch OS. It’s mounted on my main drive in /boot.

So, can i just reinstall NixOS in UEFI mode?
Looks like i just need to do right partition for it.
For now, I am considering the option with Chainloader, and as I understand from your words, both systems must be installed in UEFI mode. How should look partion for NixOS on UEFI mode with it own boot loader?

Oh no…

Now my partition looks like this:

So, now my NixOS installed on /dev/sdb3 and i can run it through Boot menu. Last i need it’s add NixOS boot loader (Also grub) into my main Grub through chainloader.
I’am trying like this (but it didn’t work, error: can’t found /mnt/nix/.../core.efi):


Here is my actual partition:

Also, this my bootloader setup in configuration.nix:

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

The chainloader entry needs to reference the file by a reference grub can understand. Remember that when it’s following this directive, arch linux and its mount points do not exist. Grub is all there is. You’ve done the search command, setting what device absolute paths are interpreted from… but it looks like you’re looking for the wrong filesystem. Then the chainloader command isn’t specifying the path relative to the device you’ve chosen, but rather relative to arch’s root when it’s mounted on arch.

Try:

search --no-floppy --set=root --fs-uuid BC21-7037
chainloader /grub/x86_64-efi/core.efi

P.S. For future reference, please post actual text where possible, not pictures of text. I can’t copy and paste out of a picture, and copying a uuid out of a picture is rather annoying, even if it is a short one. Also, pictures can be hard to work with when viewing from a device with a different screen form factor, too.

1 Like

Thank you a lot. you are a lifesaver.Everything works like clock right now.

Ok, i will do.

So, if someone got something simillar, here is how i fix this.

  1. I do right partition for disk, it looks like this:


    I use cfdisk, but i think you can use something simillar.

  2. I rebuild my Flash Drive with ventoy to use GPT Partition and add NixOS iso on that.

  3. After that i launch to Flash Drive via boot menu in UEFI mode and before installation, i mount /dev/sdc1 to /boot, after that i start installation.

  4. After installation, I start NixOS via the boot menu and configure configuration.nix to use grub as the bootloader, like this:

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

And use nixos-rebuild.

  1. And after all i add this into my arch grub config (/etc/grub.d/40_custom):
menuentry "NixOS" {
    search --no-floppy --set=root --fs-uuid BC21-7037
    chainloader /grub/x86_64-efi/core.efi
}

And rebuild config with: grub-mkconfig -o /boot/grub/grub.cfg.

And now I can access the NixOS bootloader through my main bootloader, which is on Arch.