From d41a72e832355226a2f156d9ec35af493c7c9cf0 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Fri, 1 Dec 2023 15:00:51 -0700 Subject: [PATCH] Add target flag to bootloader --- system/base-system.scm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/system/base-system.scm b/system/base-system.scm index 217463f..fc47107 100644 --- a/system/base-system.scm +++ b/system/base-system.scm @@ -317,6 +317,33 @@ (modify-services %base-services (nscd-service-type config => %metznet-nscd-configuration)))) +(define install-grub-efi-fix + #~(lambda (bootloader efi-dir mount-point) + ;; There is nothing useful to do when called in the context of a disk + ;; image generation. + (when efi-dir + ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the + ;; system whose root is mounted at MOUNT-POINT. + (let ((grub-install (string-append bootloader "/sbin/grub-install")) + (install-dir (string-append mount-point "/boot")) + ;; When installing Guix, it's common to mount EFI-DIR below + ;; MOUNT-POINT rather than /boot/efi on the live image. + (target-esp (if (file-exists? (string-append mount-point efi-dir)) + (string-append mount-point efi-dir) + efi-dir))) + ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or + ;; root partition. + (setenv "GRUB_ENABLE_CRYPTODISK" "y") + (invoke/quiet grub-install "--boot-directory" install-dir + "--target=x86_64-efi" + "--bootloader-id=Guix" + "--efi-directory" target-esp))))) + +(define grub-efi-bootloader-fix + (bootloader + (inherit grub-efi-bootloader) + (installer install-grub-efi-fix))) + (define %metznet-base-operating-system (operating-system ;; Hostname and localization information @@ -332,7 +359,7 @@ (initrd microcode-initrd) ;; Grub UEFI Bootloader installed to /boot/efi (bootloader (bootloader-configuration - (bootloader grub-efi-bootloader) + (bootloader grub-efi-bootloader-fix) (targets '("/boot/efi")) (keyboard-layout keyboard-layout))) (file-systems (cons* (file-system