summaryrefslogtreecommitdiff
path: root/gnu/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/bootloader')
-rw-r--r--gnu/bootloader/grub.scm34
1 files changed, 34 insertions, 0 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 120cd55012..65d7171432 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -7,6 +7,7 @@
;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -50,10 +51,12 @@
grub-theme-color-highlight
grub-theme-gfxmode
+ install-grub-efi-removable
install-grub-efi-netboot
grub-bootloader
grub-efi-bootloader
+ grub-efi-removable-bootloader
grub-efi-netboot-bootloader
grub-mkrescue-bootloader
grub-minimal-bootloader
@@ -608,6 +611,31 @@ fi~%"))))
"--bootloader-id=Guix"
"--efi-directory" target-esp)))))
+(define install-grub-efi-removable
+ #~(lambda (bootloader efi-dir mount-point)
+ ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point
+ ;; NOTE: efi-dir comes from target list of booloader configuration
+ ;; 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
+ "--removable"
+ ;; "--no-nvram"
+ "--bootloader-id=Guix"
+ "--efi-directory" target-esp)))))
+
(define (install-grub-efi-netboot subdir)
"Define a grub-efi-netboot bootloader installer for installation in SUBDIR,
which is usually efi/Guix or efi/boot."
@@ -734,6 +762,12 @@ considered for security aspects."
(name 'grub-efi)
(package grub-efi)))
+(define grub-efi-removable-bootloader
+ (bootloader
+ (inherit grub-efi-bootloader)
+ (name 'grub-efi-removable-bootloader)
+ (installer install-grub-efi-removable)))
+
(define grub-efi-netboot-bootloader
(bootloader
(inherit grub-efi-bootloader)