Merge pull request #19379 from nixy/master
grub bootloader: add forceInstall option
This commit is contained in:
commit
cb8af0ca51
|
@ -53,7 +53,7 @@ let
|
||||||
inherit (args) devices;
|
inherit (args) devices;
|
||||||
inherit (efi) canTouchEfiVariables;
|
inherit (efi) canTouchEfiVariables;
|
||||||
inherit (cfg)
|
inherit (cfg)
|
||||||
version extraConfig extraPerEntryConfig extraEntries
|
version extraConfig extraPerEntryConfig extraEntries forceInstall
|
||||||
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels
|
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels
|
||||||
default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
|
default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
|
||||||
path = (makeBinPath ([
|
path = (makeBinPath ([
|
||||||
|
@ -403,6 +403,16 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
forceInstall = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to try and forcibly install GRUB even if problems are
|
||||||
|
detected. It is not recommended to enable this unless you know what
|
||||||
|
you are doing.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
trustedBoot = {
|
trustedBoot = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
|
|
@ -65,6 +65,7 @@ my $efiSysMountPoint = get("efiSysMountPoint");
|
||||||
my $gfxmodeEfi = get("gfxmodeEfi");
|
my $gfxmodeEfi = get("gfxmodeEfi");
|
||||||
my $gfxmodeBios = get("gfxmodeBios");
|
my $gfxmodeBios = get("gfxmodeBios");
|
||||||
my $bootloaderId = get("bootloaderId");
|
my $bootloaderId = get("bootloaderId");
|
||||||
|
my $forceInstall = get("forceInstall");
|
||||||
$ENV{'PATH'} = get("path");
|
$ENV{'PATH'} = get("path");
|
||||||
|
|
||||||
die "unsupported GRUB version\n" if $grubVersion != 1 && $grubVersion != 2;
|
die "unsupported GRUB version\n" if $grubVersion != 1 && $grubVersion != 2;
|
||||||
|
@ -531,13 +532,14 @@ if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
|
||||||
foreach my $dev (@deviceTargets) {
|
foreach my $dev (@deviceTargets) {
|
||||||
next if $dev eq "nodev";
|
next if $dev eq "nodev";
|
||||||
print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
|
print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
|
||||||
if ($grubTarget eq "") {
|
my @command = ("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev));
|
||||||
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev)) == 0
|
if ($forceInstall eq "true") {
|
||||||
or die "$0: installation of GRUB on $dev failed\n";
|
push @command, "--force";
|
||||||
} else {
|
|
||||||
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
|
|
||||||
or die "$0: installation of GRUB on $dev failed\n";
|
|
||||||
}
|
}
|
||||||
|
if ($grubTarget ne "") {
|
||||||
|
push @command, "--target=$grubTarget";
|
||||||
|
}
|
||||||
|
(system @command) == 0 or die "$0: installation of GRUB on $dev failed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,6 +548,9 @@ if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
|
||||||
if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both")) {
|
if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both")) {
|
||||||
print STDERR "installing the GRUB $grubVersion EFI boot loader into $efiSysMountPoint...\n";
|
print STDERR "installing the GRUB $grubVersion EFI boot loader into $efiSysMountPoint...\n";
|
||||||
my @command = ("$grubEfi/sbin/grub-install", "--recheck", "--target=$grubTargetEfi", "--boot-directory=$bootPath", "--efi-directory=$efiSysMountPoint");
|
my @command = ("$grubEfi/sbin/grub-install", "--recheck", "--target=$grubTargetEfi", "--boot-directory=$bootPath", "--efi-directory=$efiSysMountPoint");
|
||||||
|
if ($forceInstall eq "true") {
|
||||||
|
push @command, "--force";
|
||||||
|
}
|
||||||
if ($canTouchEfiVariables eq "true") {
|
if ($canTouchEfiVariables eq "true") {
|
||||||
push @command, "--bootloader-id=$bootloaderId";
|
push @command, "--bootloader-id=$bootloaderId";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user