git.iko.soy/typeable/nixpkgs
on master help sign in
grub: add grub.useOSProber option (#22558)
commit0b87efacb14425f65e75c489e26b21952ece805c authorsymphorien <symphorien@users.noreply.github.com> dateMon 13 Feb 2017, 14:53 (10 years ago) parent5d00edc
2 files changed+20−3
nixos/modules/system/boot/loader/grub/grub.nix+12−2 nixos/modules/system/boot/loader/grub/install-grub.pl+8−1
nixos/modules/system/boot/loader/grub/grub.nix+12−2
@@ -53,12 +53,14 @@ let
5353 inherit (args) devices;
5454 inherit (efi) canTouchEfiVariables;
5555 inherit (cfg)
56− version extraConfig extraPerEntryConfig extraEntries forceInstall
56+ version extraConfig extraPerEntryConfig extraEntries forceInstall useOSProber
5757 extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels
5858 default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
5959 path = (makeBinPath ([
6060 pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfs-progs
61− pkgs.utillinux ] ++ (if cfg.efiSupport && (cfg.version == 2) then [pkgs.efibootmgr ] else [])
61+ pkgs.utillinux ]
62+ ++ (optional (cfg.efiSupport && (cfg.version == 2)) pkgs.efibootmgr)
63+ ++ (optionals cfg.useOSProber [pkgs.busybox pkgs.os-prober])
6264 )) + ":" + (makeSearchPathOutput "bin" "sbin" [
6365 pkgs.mdadm pkgs.utillinux
6466 ]);
@@ -265,6 +267,14 @@ in
265267 '';
266268 };
267269
270+ useOSProber = mkOption {
271+ default = false;
272+ type = types.bool;
273+ description = ''
274+ If set to true, append entries for other OSs detected by os-prober.
275+ '';
276+ };
277+
268278 splashImage = mkOption {
269279 type = types.nullOr types.path;
270280 example = literalExample "./my-background.png";
nixos/modules/system/boot/loader/grub/install-grub.pl+8−1
@@ -424,10 +424,17 @@ if ($extraPrepareConfig ne "") {
424424 system((get("shell"), "-c", $extraPrepareConfig));
425425}
426426
427−# Atomically update the GRUB config.
427+# write the GRUB config.
428428my $confFile = $grubVersion == 1 ? "$bootPath/grub/menu.lst" : "$bootPath/grub/grub.cfg";
429429my $tmpFile = $confFile . ".tmp";
430430writeFile($tmpFile, $conf);
431+
432+# Append entries detected by os-prober
433+if (get("useOsprober") eq "true") {
434+ system(get("shell"), "-c", "pkgdatadir=$grub/share/grub $grub/etc/grub.d/30_os-prober >> $tmpFile");
435+}
436+
437+# Atomically switch to the new config
431438rename $tmpFile, $confFile or die "cannot rename $tmpFile to $confFile\n";
432439
433440