[Nix-dev] Nix clobbered my Ubuntu grub.cfg

Florent Becker florent.becker at ens-lyon.org
Fri Nov 21 09:50:12 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Ubuntu and NixOS seem to have completely incompatible grub update 
> procedures. I'm interested in ideas on how to make them play well
together.
> I would even be interested in contributing code to facilitate that 
> behavior, if the forces-that-be agree on a design.
> 
I think you should have only one of nixos or ubuntu in charge of
keeping grub up to date, whichever you're going to update the most
often. You then need to configure that system to have grub include the
others' boot menu. On my machine, I have ubuntu do the grub installation.

It works thus:

in /etc/nixos/configuration.nix, tell nixos not to bother with grub
beyond generating a menu:

  # Use the GRUB 2 boot loader.
  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  # Define on which hard drive you want to install Grub.
  # in our case, none:
  boot.loader.grub.device = "nodev";

in ubuntu, tell grub to create an entry for nixos (add the following
into file /etc/grub.d/40_custom):

menuentry 'Nixos' {
    insmod lvm                 # <- If needed for lvm
    set root=(lvm/lvm-nixroot) # <- whatever your nix root volume is
    configfile /boot/grub/grub.cfg # <- grub's config file within nixos'
                                   #    root file system
}

As it is, it makes ubuntu the default entry (you can change that by
lowering the 40 in 40_custom). Selecting nixos is a two step process
(nixos -> default nixos). That can probably be fixed somehow (i don't
mind enough).

The long term solution is probably getting that into the nixos
installation manual rather than coding a sophisticated solution.

Hope this helps,

Florent
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlRu/L8ACgkQTCPcDztjGo6+2ACfeRrt/bjcHNU0iVCaRExU1uq8
JTUAnRyEbwTlI06nU65oWkhcIBqeX24v
=rHNI
-----END PGP SIGNATURE-----



More information about the nix-dev mailing list