Hi there,
I tried to install NixOS beside archlinux and the installation failed when it comes to grub.
So basically, here is what I did (I created my partitions before with gparted) :
- mounting /root :
mount /dev/sda3 /mnt
- mounting /home :
mkdir -p /mnt/home
and mount /dev/sda4 /mnt/home
- mounting /boot :
mkdir -p /mnt/boot/efi
and mount /dev/sda1 /mnt/boot/efi
where /dev/sda1
is the initial boot partition of my arch.
- generate the config file :
nixos-generate-config --root /mnt
- edit the config file
In the latter I changed :
# Use the systemd-boot EFI boot loader.
# boot.loader.systemd-boot.enable = true;
boot.loader.grub.device = "nodev";
boot.loader.grub.efiSupport = true;
boot.loader.grub.useOSProber = true;
[After a 1st nixos-install
I also had an issue with boot.loader.grub.devices = /dev/sda
so I had to remove it. It was redundant with boot.loader.grub.device = "nodev";
thanks to the output error.]
I also uncommented time.timeZone
and i18n.defaultLocale
.
And then nixos-install
and it failed at/or after grub install. As it was blocked on an ERROR
message, I ended up the process.
Concerning grub, is there something to do with the hardware-configuration.nix
file like here for the Keeping kernels/initrd on the main partition case ?
In my generated hardware-configuration.nix
, the fileSystems."/boot/efi"
has the right UUID, and point to /dev/sda1
.
Other idea : should I add boot.loader.efi.canTouchEfiVariables = true;
in the nix config file ?
Hi,
I don’t know how to solve your specific problem, however I have Fedora, Kali and Nixos installed on the same SSD and may have some useful info for you.
Fedora was installed first, it set up its UEFI stuff in a separate /boot partition. Kali was next and it managed to use the same boot partition as Fedora without me doing anything. It did replace the Fedora GRUB on the MBR, but I used UEFI boot to boot into Fedora and re-installed its GRUB, which then picked up the Kali install and added boot entries for it.
When it came to Nixos, I didn’t change it from the default systemd boot and this mandated that I had to give it its own /boot partition. The Fedora GRUB didn’t pick up Nixos, but I manually added an entry to chainload the Nixos systemd bootloader.
If you don’t mind giving Nixos its own /boot partition (it’s only 1GB) then this would probably work for you too.
Cheers,
Rich
1 Like
Hi Rich,
thank you for your answer/solution !
Nevertheless I would like to have a clean full-GRUB install. I did it once with windows and it worked. But I don’t remember how exactly I did…
Just few questions on your solution :
-
I guess you used the graphic installer of Kali and made an install alongside. To re-install your GRUB with fedora you just did grub2-mkconfig -o /boot/grub2/grub.cfg
in fedora ?
-
How do you manage to add an entry of the NixOS systemd-boot entry to the GRUB of fedora ? I did try to install NixOS with the graphic installer and it does not let you the choice and use systemd-boot. I tried to changed it to GRUB but I broke everything… I don’t know which one is best but I am more used to GRUB.
Hi,
Re-installing the Fedora GRUB on the MBR was a bit of a hassle. When I tried to use the command, it complained about a missing UEFI file. I eventually found out what I had to install and so how it went was:
$ dnf install grub2-efi-x64-modules-1:2.06-100.fc39.noarch
$ grub2-install --force /dev/nvme1n1
$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
!!! Adjust the device in the second line !!!
For the GRUB entry to chain Nixos, I created a file /etc/grub.d/25_nixos:
[root@nixos:/mnt/fedora/etc/grub.d]# cat 25_nixos
#!/usr/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
# The Nixos boot loader
menuentry "Nixos" {
insmod chain
insmod fat
insmod part_gpt
search --no-floppy --set=root --fs-uuid 3897-22B3
chainloader (${root})/EFI/systemd/systemd-bootx64.efi
}
You will need to find the UUID of your Nixos boot partition, /dev/disk/by-* are your friends, as are blkid and lsblk.
HTH 
EDIT: I’m also much more used to GRUB, this is my first time using a systemd bootloader. But if Nixos makes it difficult to use GRUB, I can put up with it. Everything else is booted from the Fedora GRUB, including Windows on the other SSD so 
I can’t quite remember what sort of Kali install it was, but it might well have been install alongside. I just gave it a 100GB btrfs partition to do what it wanted with and it happily used the /boot partition created by Fedora without breaking anything.
Thanks again for your answer. But it seems a bit too sinuous for me…
But if Nixos makes it difficult to use GRUB, I can put up with it.
I don’t think it makes it difficult. It is just a matter of choice. Using GRUB is totally possible. Just need to find how.
Thanks again for your answer. But it seems a bit too sinuous for me…
But if Nixos makes it difficult to use GRUB, I can put up with it.
I don’t think it makes it difficult. It is just a matter of choice. Using GRUB is totally possible. Just need to find how.
I just have other fish to fry. Like face login
Good luck.
So I tried again the install with the following config file :
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the systemd-boot EFI boot loader.
# boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub.device = "nodev";
boot.loader.grub.efiSupport = true;
boot.loader.grub.useOSProber = true;
# networking.hostName = "nixos"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
time.timeZone = "Europe/Paris";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "fr_FR.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
# };
# Enable the X11 windowing system.
# services.xserver.enable = true;
# Configure keymap in X11
# services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.toto = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
packages = with pkgs; [
firefox
git
];
};
# List packages installed in system profile. To search, run:
# $ nix search wget
# environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
# ];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "23.11"; # Did you read the comment?
}
The difference for boot options is that I add boot.loader.efi.canTouchEfiVariables = true;
And I still have the same error after GRUB : ERROR : mkdir /var/lock/dmraid
.
Any idea ?
I also tried with boot.loader.grub.device = "/dev/sda";
with no more success. Same error.
I also tried with boot.loader.grub.enable = true;
with no more success. Same error.
To be completely precise : I try to install NixOS beside Arch on an external SSD. I have already Win11 on the nvme main pc drive. Dualboot Arch/Win11 with GRUB.
The problem comes from GRUB apparently.
What if I do not use a boot loader ? Will my arch GRUB could still detect Nix ?
This thing is driving me crazy.
According to the documentation, it does not seem to be possible with GRUB :
With GRUB, set boot.loader.grub.useOSProber
to true
, but this will only detect windows partitions, not other Linux distributions. If you dual boot another Linux distribution, use systemd-boot instead.