[Nix-dev] Please explain grub installer

Eelco Dolstra eelco.dolstra at logicblox.com
Tue Feb 4 13:12:22 CET 2014


Hi,

On 04/02/14 12:04, Sergey Mironov wrote:

> Hi! I've got a troubles while trying to understand how does
> install-grub.pl works (maybe that is because I'm not skilled in perl).
> 
> Here is what I am trying to figure out: grub.nix calls
> ./install-grub.pl with XML parameter list as an argument.
> 
> https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/loader/grub/grub.nix#L242
> 
>>From the perl side, ./install-grub.pl reads ARGV[0] and ARGV[1].
> ARGV[0] turns out to contain the path to XML. OK. And ARVG[1] contains
> a mysterious config. AFAIK it should point to the folder with kernel,
> initrd and others. But where does it come from?

It's passed from switch-to-configuration.pl:

  # Install or update the bootloader.
  if ($action eq "switch" || $action eq "boot") {
      system("@installBootLoader@ $out") == 0 or exit 1;
  }

Note that switch-to-configuration.pl is called in turn by nixos-rebuild.

The string '@installBootLoader@' comes from the option
system.build.installBootLoader, which is set by grub.nix to (approximately)
"${pkgs.perl}/bin/perl ${./install-grub.pl} ${grubConfig}", where ${grubConfig}
is the XML file.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list