diff options
author | Jörg Thalheim <joerg@higgsboson.tk> | 2016-11-21 15:15:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-21 15:15:45 +0100 |
commit | cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e (patch) | |
tree | dddd9377dd4035abdece4affde245e71307337ad /nixos/modules/system | |
parent | 9e4ba738acbe15697139404d9d69dcf6d50ee67b (diff) | |
parent | a31bf8961a3f0b2cfe28e0240698cd19258c24f5 (diff) | |
download | nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar.gz nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar.bz2 nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar.lz nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar.xz nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.tar.zst nixpkgs-cb8af0ca51979a524a0fcce15c2e21f1e9e4c53e.zip |
Merge pull request #19379 from nixy/master
grub bootloader: add forceInstall option
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/loader/grub/grub.nix | 12 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 17 |
2 files changed, 22 insertions, 7 deletions
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 17c842ddc53..294fc1988e9 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -53,7 +53,7 @@ let inherit (args) devices; inherit (efi) canTouchEfiVariables; inherit (cfg) - version extraConfig extraPerEntryConfig extraEntries + version extraConfig extraPerEntryConfig extraEntries forceInstall extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios; 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 = { enable = mkOption { diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index b93395300b7..24442ca12a3 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -65,6 +65,7 @@ my $efiSysMountPoint = get("efiSysMountPoint"); my $gfxmodeEfi = get("gfxmodeEfi"); my $gfxmodeBios = get("gfxmodeBios"); my $bootloaderId = get("bootloaderId"); +my $forceInstall = get("forceInstall"); $ENV{'PATH'} = get("path"); 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) { next if $dev eq "nodev"; print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n"; - if ($grubTarget eq "") { - system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev)) == 0 - or die "$0: installation of GRUB on $dev failed\n"; - } 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"; + my @command = ("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev)); + if ($forceInstall eq "true") { + push @command, "--force"; + } + 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")) { 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"); + if ($forceInstall eq "true") { + push @command, "--force"; + } if ($canTouchEfiVariables eq "true") { push @command, "--bootloader-id=$bootloaderId"; } else { |