summaryrefslogtreecommitdiff
path: root/gnu/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/bootloader')
-rw-r--r--gnu/bootloader/grub.scm83
1 files changed, 28 insertions, 55 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index ef516b1e13d..c2462d5d036 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -10,6 +10,7 @@
10;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com> 10;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com>
11;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> 11;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
12;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> 12;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz>
13;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
13;;; 14;;;
14;;; This file is part of GNU Guix. 15;;; This file is part of GNU Guix.
15;;; 16;;;
@@ -28,6 +29,7 @@
28 29
29(define-module (gnu bootloader grub) 30(define-module (gnu bootloader grub)
30 #:use-module (guix build union) 31 #:use-module (guix build union)
32 #:use-module (guix deprecation)
31 #:use-module (guix records) 33 #:use-module (guix records)
32 #:use-module (guix store) 34 #:use-module (guix store)
33 #:use-module (guix utils) 35 #:use-module (guix utils)
@@ -56,6 +58,7 @@
56 grub-theme-gfxmode 58 grub-theme-gfxmode
57 59
58 install-grub-efi-removable 60 install-grub-efi-removable
61 make-grub-efi-installer
59 make-grub-efi-netboot-installer 62 make-grub-efi-netboot-installer
60 63
61 grub-bootloader 64 grub-bootloader
@@ -628,7 +631,16 @@ fi~%"))))
628 "-d" "." 631 "-d" "."
629 image)))) 632 image))))
630 633
631(define install-grub-efi 634(define* (make-grub-efi-installer #:key efi32? removable?)
635 "Return a G-expression of a procedure for installing GRUB on a UEFI
636system. If EFI32? is #t, then a 32-bit target will be used. If
637REMOVABLE? is #t, GRUB will be installed for Removable Media Boot."
638 (define extra-args
639 (list (and efi32?
640 #~(cond ((target-x86?) "--target=i386-efi")
641 ((target-arm?) "--target=arm-efi")))
642 ;; This does not update UEFI boot entries, like --no-nvram.
643 (and removable? "--removable")))
632 #~(lambda (bootloader efi-dir mount-point) 644 #~(lambda (bootloader efi-dir mount-point)
633 ;; There is nothing useful to do when called in the context of a disk 645 ;; There is nothing useful to do when called in the context of a disk
634 ;; image generation. 646 ;; image generation.
@@ -645,57 +657,10 @@ fi~%"))))
645 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or 657 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
646 ;; root partition. 658 ;; root partition.
647 (setenv "GRUB_ENABLE_CRYPTODISK" "y") 659 (setenv "GRUB_ENABLE_CRYPTODISK" "y")
648 (invoke/quiet grub-install "--boot-directory" install-dir 660 (invoke/quiet grub-install "--bootloader-id=Guix"
649 "--bootloader-id=Guix" 661 "--boot-directory" install-dir
650 "--efi-directory" target-esp))))) 662 "--efi-directory" target-esp
651 663 #$@(filter identity extra-args))))))
652(define install-grub-efi-removable
653 #~(lambda (bootloader efi-dir mount-point)
654 ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point
655 ;; NOTE: efi-dir comes from target list of booloader configuration
656 ;; There is nothing useful to do when called in the context of a disk
657 ;; image generation.
658 (when efi-dir
659 ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
660 ;; system whose root is mounted at MOUNT-POINT.
661 (let ((grub-install (string-append bootloader "/sbin/grub-install"))
662 (install-dir (string-append mount-point "/boot"))
663 ;; When installing Guix, it's common to mount EFI-DIR below
664 ;; MOUNT-POINT rather than /boot/efi on the live image.
665 (target-esp (if (file-exists? (string-append mount-point efi-dir))
666 (string-append mount-point efi-dir)
667 efi-dir)))
668 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
669 ;; root partition.
670 (setenv "GRUB_ENABLE_CRYPTODISK" "y")
671 (invoke/quiet grub-install "--boot-directory" install-dir
672 "--removable"
673 ;; "--no-nvram"
674 "--bootloader-id=Guix"
675 "--efi-directory" target-esp)))))
676
677(define install-grub-efi32
678 #~(lambda (bootloader efi-dir mount-point)
679 ;; There is nothing useful to do when called in the context of a disk
680 ;; image generation.
681 (when efi-dir
682 ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
683 ;; system whose root is mounted at MOUNT-POINT.
684 (let ((grub-install (string-append bootloader "/sbin/grub-install"))
685 (install-dir (string-append mount-point "/boot"))
686 ;; When installing Guix, it's common to mount EFI-DIR below
687 ;; MOUNT-POINT rather than /boot/efi on the live image.
688 (target-esp (if (file-exists? (string-append mount-point efi-dir))
689 (string-append mount-point efi-dir)
690 efi-dir)))
691 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
692 ;; root partition.
693 (setenv "GRUB_ENABLE_CRYPTODISK" "y")
694 (invoke/quiet grub-install "--boot-directory" install-dir
695 "--bootloader-id=Guix"
696 (cond ((target-x86?) "--target=i386-efi")
697 ((target-arm?) "--target=arm-efi"))
698 "--efi-directory" target-esp)))))
699 664
700(define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir) 665(define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir)
701 "Make a bootloader-installer for a grub-efi-netboot bootloader, which expects 666 "Make a bootloader-installer for a grub-efi-netboot bootloader, which expects
@@ -856,7 +821,7 @@ symlink to the store is not needed in this case."
856 (bootloader 821 (bootloader
857 (name 'grub-efi) 822 (name 'grub-efi)
858 (package grub-efi) 823 (package grub-efi)
859 (installer install-grub-efi) 824 (installer (make-grub-efi-installer))
860 (disk-image-installer #f) 825 (disk-image-installer #f)
861 (configuration-file grub-cfg) 826 (configuration-file grub-cfg)
862 (configuration-file-generator grub-configuration-file))) 827 (configuration-file-generator grub-configuration-file)))
@@ -865,12 +830,12 @@ symlink to the store is not needed in this case."
865 (bootloader 830 (bootloader
866 (inherit grub-efi-bootloader) 831 (inherit grub-efi-bootloader)
867 (name 'grub-efi-removable-bootloader) 832 (name 'grub-efi-removable-bootloader)
868 (installer install-grub-efi-removable))) 833 (installer (make-grub-efi-installer #:removable? #t))))
869 834
870(define grub-efi32-bootloader 835(define grub-efi32-bootloader
871 (bootloader 836 (bootloader
872 (inherit grub-efi-bootloader) 837 (inherit grub-efi-bootloader)
873 (installer install-grub-efi32) 838 (installer (make-grub-efi-installer #:efi32? #t))
874 (name 'grub-efi32) 839 (name 'grub-efi32)
875 (package grub-efi32))) 840 (package grub-efi32)))
876 841
@@ -916,4 +881,12 @@ symlink to the store is not needed in this case."
916 (bootloader grub-bootloader) 881 (bootloader grub-bootloader)
917 fields ...)))) 882 fields ...))))
918 883
884
885;;;
886;;; Deprecated bootloader and installer variables.
887;;;
888
889(define-deprecated/alias install-grub-efi-removable
890 (make-grub-efi-installer #:removable? #t))
891
919;;; grub.scm ends here 892;;; grub.scm ends here