mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2025-10-14 01:14:35 +00:00
67 lines
2.7 KiB
Scheme
67 lines
2.7 KiB
Scheme
;;; Copyright © 2024 Lilah Tascheter <lilah@lunabee.space>
|
||
;;; Copyright © 2024, 2025 Hilton Chain <hako@ultrarare.space>
|
||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
||
(define-module (rosenthal bootloader uki)
|
||
#:use-module (srfi srfi-1)
|
||
#:use-module (guix gexp)
|
||
#:use-module (guix modules)
|
||
#:use-module (guix utils)
|
||
#:use-module (gnu bootloader)
|
||
#:use-module (rosenthal packages bootloaders)
|
||
#:export (uefi-uki-removable-bootloader))
|
||
|
||
(define script-path "/boot/install-uki.scm")
|
||
|
||
(define (uefi-uki-configuration-file config entries . rest)
|
||
|
||
(define (menu-entry->ukify-args entry)
|
||
(let* ((label (menu-entry-label entry))
|
||
(linux (menu-entry-linux entry))
|
||
(initrd (menu-entry-initrd entry))
|
||
(arguments (menu-entry-linux-arguments entry))
|
||
(boot (bootloader-configuration-bootloader config))
|
||
(stub (bootloader-package boot)))
|
||
#~(list "--os-release" #$label
|
||
"--linux" #$linux
|
||
"--initrd" #$initrd
|
||
"--cmdline" (string-join (list #$@arguments))
|
||
"--stub" #$(file-append stub "/libexec/" (systemd-stub-name)))))
|
||
|
||
(program-file "install-uki"
|
||
(with-imported-modules (source-module-closure '((guix build utils)))
|
||
#~(begin
|
||
(use-modules (srfi srfi-1)
|
||
(guix build utils))
|
||
(let* ((ukify #$(file-append ukify "/bin/ukify"))
|
||
(installation-path
|
||
(format #f "~a/EFI/BOOT/BOOT~a.EFI"
|
||
(second (command-line))
|
||
#$(cond
|
||
((target-x86-32?) "IA32")
|
||
((target-x86-64?) "X64")
|
||
((target-arm32?) "ARM")
|
||
((target-aarch64?) "AA64")
|
||
((target-riscv64?) "RISCV64")))))
|
||
(mkdir-p (dirname installation-path))
|
||
(apply invoke ukify "build" "--output" installation-path
|
||
#$(menu-entry->ukify-args (first entries))))))))
|
||
|
||
(define install-uefi-uki
|
||
#~(lambda (bootloader target mount-point)
|
||
(invoke (string-append mount-point #$script-path)
|
||
(string-append mount-point target))))
|
||
|
||
;; ‘configuration-file’ here is actually an activation script to be invoked by
|
||
;; ‘installer’.
|
||
;; FIXME: Not expected by ‘reinstall-bootloader’ in (guix scripts system).
|
||
;; NOTE: Faking name here to support rolling-back with '--no-bootloader' option.
|
||
(define uefi-uki-removable-bootloader
|
||
(bootloader
|
||
(name 'grub-efi-removable-bootloader)
|
||
(package systemd-stub)
|
||
(installer install-uefi-uki)
|
||
(disk-image-installer #f)
|
||
(configuration-file script-path)
|
||
(configuration-file-generator uefi-uki-configuration-file)))
|