From 53135cc8c7e8fa6d562bea8fc68dc5b553a7e76a Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Sun, 25 Jun 2023 17:46:12 +0000 Subject: [PATCH] nixos/grub: don't die on EFI-only systems if devices != ["nodev"] Without this change, GRUB installation on non-PC systems (such as aarch64-linux) only works if boot.loader.grub.devices is set to exactly `["nodev"]`. If boot.loader.grub.devices was any other value (including the default `[]`), users got the error: Died at /nix/store/an9ngv2vg95bdcy0ifsxlbkasprm4dcw-install-grub.pl line 586. install-grub.pl verifies that if both $grub and $grubEfi are set, then $grubTarget (e.g. i386-pc) and $grubTargetEfi (e.g. x86_64-efi) must both be set, or the script will `die`. On non-PC systems, $grubTarget is "". When boot.loader.grub.devices is ["nodev"], $grub is set to null, disabling non-EFI installation. But if a user has devices set for an x86_64 config, or is using only mirroredBoots without setting devices, they will hit this `die`. This change sets $grub to "" if $grubTarget is "". --- nixos/modules/system/boot/loader/grub/grub.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 9f80b40d116c..8088d3038670 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -40,7 +40,10 @@ let backgroundColor = f cfg.backgroundColor; entryOptions = f cfg.entryOptions; subEntryOptions = f cfg.subEntryOptions; - grub = f grub; + # PC platforms (like x86_64-linux) have a non-EFI target (`grubTarget`), but other platforms + # (like aarch64-linux) have an undefined `grubTarget`. Avoid providing the path to a non-EFI + # GRUB on those platforms. + grub = f (if (grub.grubTarget or "") != "" then grub else ""); grubTarget = f (grub.grubTarget or ""); shell = "${pkgs.runtimeShell}"; fullName = lib.getName realGrub;