about summary refs log tree commit diff
path: root/nixos/modules/system/boot
diff options
context:
space:
mode:
authorSamuel Dionne-Riel <samuel@dionne-riel.com>2023-03-08 02:18:37 -0500
committerSamuel Dionne-Riel <samuel@dionne-riel.com>2023-08-01 18:54:27 -0400
commit894d47f9896096587aed6028099a90430355199d (patch)
treef323f05eca18f1a94b0f12adab86b9c5bf3f86b0 /nixos/modules/system/boot
parent9e1960bc196baf6881340d53dccb203a951745a2 (diff)
nixos/grub: Always install with bootloader id
The intent was to not pass the flag when installing as removable. In
reality there is a third case, where you may not want to touch EFI
variables, and not want to install as removable.

In that case, it would install to the generic \EFI\grub\grubx64.efi,
which is not a good choice in any cases. The operating system should
"own" their path under \EFI\ to be a good citizen [citation needed].

With this change, there can be only two paths GRUB can be installed to:

 - \EFI\NixOS-boot\grubx64.efi
 - \EFI\BOOT\bootx64.efi

This removes the surprising behaviour where GRUB may be installed to a
different location only because we configured NixOS not to touch EFI
variables.

It may be necessary under some configurations to install GRUB without
touching EFI variables, but to the NixOS-owned location.
Diffstat (limited to 'nixos/modules/system/boot')
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl5
1 files changed, 2 insertions, 3 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index 27f03f2fb58c8..f301d838f663f 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -725,9 +725,8 @@ if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both"))
     if ($forceInstall eq "true") {
         push @command, "--force";
     }
-    if ($canTouchEfiVariables eq "true") {
-        push @command, "--bootloader-id=$bootloaderId";
-    } else {
+    push @command, "--bootloader-id=$bootloaderId";
+    if ($canTouchEfiVariables ne "true") {
         push @command, "--no-nvram";
         push @command, "--removable" if $efiInstallAsRemovable eq "true";
     }