@@ -23,7 +23,7 @@
(define-module (gnu bootloader grub)
#:use-module (guix records)
- #:use-module ((guix utils) #:select (%current-system))
+ #:use-module ((guix utils) #:select (%current-system %current-target-system))
#:use-module (guix gexp)
#:use-module (gnu artwork)
#:use-module (gnu bootloader)
@@ -53,6 +53,8 @@
grub-bootloader
grub-efi-bootloader
+ make-grub-efi-net-bootloader
+ grub-efi-net-bootloader
grub-mkrescue-bootloader
grub-minimal-bootloader
@@ -93,7 +95,7 @@ denoting a file name."
(default '((fg . cyan) (bg . blue))))
(color-highlight grub-theme-color-highlight
(default '((fg . white) (bg . blue))))
- (gfxmode grub-gfxmode
+ (gfxmode grub-theme-gfxmode
(default '("auto")))) ;list of string
(define %background-image
@@ -143,40 +145,24 @@ WIDTH/HEIGHT, or #f if none was found."
#:width width #:height height))))
(define* (eye-candy config store-device store-mount-point
- #:key system port)
+ #:key port)
"Return a gexp that writes to PORT (a port-valued gexp) the
'grub.cfg' part concerned with graphics mode, background images, colors, and
all that. STORE-DEVICE designates the device holding the store, and
STORE-MOUNT-POINT is its mount point; these are used to determine where the
-background image and fonts must be searched for. SYSTEM must be the target
-system string---e.g., \"x86_64-linux\"."
- (define setup-gfxterm-body
- (let ((gfxmode
- (or (and-let* ((theme (bootloader-configuration-theme config))
- (gfxmode (grub-gfxmode theme)))
- (string-join gfxmode ";"))
- "auto")))
-
- ;; Intel and EFI systems need to be switched into graphics mode, whereas
- ;; most other modern architectures have no other mode and therefore
- ;; don't need to be switched.
-
- ;; XXX: Do we really need to restrict to x86 systems? We could imitate
- ;; what the GRUB default configuration does and decide based on whether
- ;; a user provided 'gfxterm' in the terminal-outputs field of their
- ;; bootloader-configuration record.
- (if (string-match "^(x86_64|i[3-6]86)-" system)
- (format #f "
- set gfxmode=~a
- insmod all_video
- insmod gfxterm~%" gfxmode)
- "")))
-
+background image and fonts must be searched for."
(define (setup-gfxterm config font-file)
(if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
- #~(format #f "if loadfont ~a; then
- setup_gfxterm
-fi~%" #$font-file)
+ #~(format #f "
+if loadfont ~a; then
+ set gfxmode=~a
+ insmod all_video
+ insmod gfxterm
+fi~%"
+ #$font-file
+ #$(string-join
+ (grub-theme-gfxmode (bootloader-theme config))
+ ";"))
""))
(define (theme-colors type)
@@ -194,8 +180,6 @@ fi~%" #$font-file)
(and image
#~(format #$port "
-function setup_gfxterm {~a}
-
# Set 'root' to the partition that contains /gnu/store.
~a
@@ -210,7 +194,6 @@ else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi~%"
- #$setup-gfxterm-body
#$(grub-root-search store-device font-file)
#$(setup-gfxterm config font-file)
#$(grub-setup-io config)
@@ -317,6 +300,9 @@ code."
((? file-system-label? label)
(format #f "search --label --set ~a"
(file-system-label->string label)))
+ ((? (lambda (device)
+ (and (string? device) (string-contains device ":/"))) nfs-uri)
+ "set root=(tftp)")
((or #f (? string?))
#~(format #f "search --file --set ~a" #$file)))))
@@ -356,7 +342,6 @@ entries corresponding to old generations of the system."
(eye-candy config
(menu-entry-device (first all-entries))
(menu-entry-device-mount-point (first all-entries))
- #:system system
#:port #~port))
(define keyboard-layout-config
@@ -444,6 +429,68 @@ fi~%"))))
"--bootloader-id=Guix"
"--efi-directory" target-esp))))
+(define (install-grub-efi-net efi-subdir)
+ "Define a grub-efi bootloader installer for installation in EFI-SUBDIR,
+which is usually \"efi/guix\" or \"efi/boot\"."
+ (let* ((arch (car (string-split (or (%current-target-system)
+ (%current-system))
+ #\-)))
+ (efi-bootloader-link (string-append "boot"
+ (match arch
+ ("i686" "ia32")
+ ("x86_64" "x64")
+ ("arm" "arm")
+ ("armhf" "arm")
+ ("aarch64" "aa64")
+ ("riscv" "riscv32")
+ ("riscv64" "riscv64"))
+ ".efi"))
+ (efi-bootloader (string-append (match arch
+ ("i686" "i386")
+ ("x86_64" "x86_64")
+ ("arm" "arm")
+ ("armhf" "arm")
+ ("aarch64" "arm64")
+ ("riscv" "riscv32")
+ ("riscv64" "riscv64"))
+ "-efi/core.efi")))
+ #~(lambda (bootloader target mount-point)
+ "Install GRUB as e.g. \"bootx64.efi\" or \"bootarm64.efi\" \"into
+EFI-SUBDIR, which is usually \"efi/guix\" or \"efi/boot\" below the directory
+TARGET for the system whose root is mounted at MOUNT-POINT."
+ (let* ((mount-point-list (delete "" (string-split mount-point #\/)))
+ (target-list (delete "" (string-split target #\/)))
+ (net-dir
+ (string-append "/" (string-join (append
+ mount-point-list
+ target-list)
+ "/")))
+ (subdir #$efi-subdir)
+ (efi-bootloader-link
+ (string-append net-dir "/" subdir "/" #$efi-bootloader-link))
+ (store-name (car (delete "" (string-split bootloader #\/))))
+ (store
+ ;; Use target-list to construct a "../gnu" link with a correct
+ ;; number of "../" to the store.
+ (string-join (append (make-list (length target-list) "..")
+ (list store-name))
+ "/"))
+ (store-link (string-append net-dir "/" store-name)))
+ ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
+ ;; root partition.
+ (setenv "GRUB_ENABLE_CRYPTODISK" "y")
+ (invoke/quiet (string-append bootloader "/bin/grub-mknetdir")
+ (string-append "--net-directory=" net-dir)
+ (string-append "--subdir=" subdir))
+ (false-if-exception
+ (delete-file efi-bootloader-link))
+ (symlink #$efi-bootloader
+ efi-bootloader-link)
+ (false-if-exception
+ (delete-file store-link))
+ (symlink store
+ store-link)))))
+
^L
;;;
@@ -473,7 +520,18 @@ fi~%"))))
(name 'grub-efi)
(package grub-efi)))
-(define* grub-mkrescue-bootloader
+(define-syntax-rule (make-grub-efi-net-bootloader bootloader-name target efi-subdir)
+ (define bootloader-name
+ (bootloader
+ (inherit grub-bootloader)
+ (name (quote bootloader-name))
+ (package grub-efi)
+ (installer (install-grub-efi-net efi-subdir))
+ (configuration-file (string-append target "/" efi-subdir "/grub.cfg")))))
+
+(make-grub-efi-net-bootloader grub-efi-net-bootloader "boot" "efi/boot")
+
+(define grub-mkrescue-bootloader
(bootloader
(inherit grub-efi-bootloader)
(package grub-hybrid)))
@@ -300,7 +300,8 @@ file system labels."
((? string? device)
;; It used to be that we would not distinguish between labels and
;; device names. Try to infer the right thing here.
- (if (string-prefix? "/dev/" device)
+ (if (or (string-prefix? "/dev/" device)
+ (string-contains device ":/")) ; nfs
device
(file-system-label device)))))