mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2026-03-25 19:24:22 +00:00
Compare commits
5 Commits
f58f1b0583
...
11d821da23
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d821da23 | ||
|
|
ef75c33357 | ||
|
|
38a475c72b | ||
|
|
a1a442ce84 | ||
|
|
d241a5bea3 |
@ -17,6 +17,7 @@
|
||||
(gnu system privilege)
|
||||
(rosenthal bootloader grub)
|
||||
(rosenthal bootloader uki)
|
||||
(rosenthal bootloader limine)
|
||||
|
||||
(gnu services desktop)
|
||||
(gnu services guix)
|
||||
|
||||
127
modules/rosenthal/bootloader/limine.scm
Normal file
127
modules/rosenthal/bootloader/limine.scm
Normal file
@ -0,0 +1,127 @@
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2026 Hilton Chain <hako@ultrarare.space>
|
||||
|
||||
(define-module (rosenthal bootloader limine)
|
||||
;; Guile builtins
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (srfi srfi-1)
|
||||
;; Utilities
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix modules)
|
||||
#:use-module (guix utils)
|
||||
;; Guix System - bootloaders
|
||||
#:use-module (gnu bootloader)
|
||||
#:use-module (gnu bootloader grub)
|
||||
#:use-module (rosenthal bootloader uki)
|
||||
;; Guix packages
|
||||
#:use-module (rosenthal packages bootloaders)
|
||||
#:export (limine-efi-removable-bootloader))
|
||||
|
||||
(define script-path "/boot/install-limine.scm")
|
||||
|
||||
(define* (limine-configuration-file config entries
|
||||
#:key (old-entries '()) #:allow-other-keys)
|
||||
(define limine
|
||||
(file-append
|
||||
(bootloader-package (bootloader-configuration-bootloader config))
|
||||
(format #f "/share/limine/BOOT~a.EFI"
|
||||
(cond
|
||||
((target-x86-32?) "IA32")
|
||||
((target-x86-64?) "X64")
|
||||
((target-aarch64?) "AA64")
|
||||
((target-riscv64?) "RISCV64")))))
|
||||
|
||||
(define menu-entries
|
||||
(cons (first entries)
|
||||
old-entries))
|
||||
|
||||
(define labels
|
||||
(map-in-order menu-entry-label menu-entries))
|
||||
|
||||
(define ukify-args
|
||||
(map-in-order menu-entry->ukify-args menu-entries))
|
||||
|
||||
(program-file "install-limine"
|
||||
(with-imported-modules
|
||||
(source-module-closure
|
||||
'((guix build syscalls)
|
||||
(guix build utils)))
|
||||
#~(begin
|
||||
(use-modules (ice-9 match)
|
||||
(srfi srfi-1)
|
||||
(guix build syscalls)
|
||||
(guix build utils))
|
||||
(let* ((args (command-line))
|
||||
(directory (second args))
|
||||
(limine-directory (in-vicinity directory "EFI/BOOT"))
|
||||
(guix-directory (in-vicinity directory "EFI/Guix")))
|
||||
(for-each mkdir-p (list limine-directory guix-directory))
|
||||
(install-file #$limine limine-directory)
|
||||
(call-with-output-file (in-vicinity limine-directory "limine.conf.tmp")
|
||||
(lambda (port)
|
||||
(let* ((ukify #$(file-append ukify "/bin/ukify"))
|
||||
(script-path (first args))
|
||||
(minbytes (* 2 (stat:size (stat script-path))))
|
||||
(current-label (first '#$labels))
|
||||
(current-args (first (list #$@ukify-args)))
|
||||
(old-labels (cdr '#$labels))
|
||||
(old-args (cdr (list #$@ukify-args))))
|
||||
(format port "timeout: 5~%")
|
||||
(with-directory-excursion guix-directory
|
||||
(for-each delete-file (find-files "." "^OLD-[0-9]+\\.EFI$"))
|
||||
(apply invoke ukify "build" "--output" "CURRENT.EFI"
|
||||
current-args)
|
||||
(format port "
|
||||
/~a
|
||||
protocol: efi
|
||||
path: boot():/EFI/Guix/CURRENT.EFI~%"
|
||||
current-label)
|
||||
(unless (null? old-labels)
|
||||
(format port "~%/GNU system, old configurations...~%"))
|
||||
(let loop ((count 1)
|
||||
(labels old-labels)
|
||||
(args old-args))
|
||||
(let* ((image-name (format #f "OLD-~a.EFI" count)))
|
||||
(unless (null? labels)
|
||||
(with-exception-handler
|
||||
(lambda _
|
||||
(false-if-exception (delete-file image-name))
|
||||
(exit))
|
||||
(lambda ()
|
||||
(when (< (free-disk-space ".") minbytes)
|
||||
(raise-exception 'insuffcient-disk-space))
|
||||
(apply invoke/quiet
|
||||
ukify "build" "--output" image-name
|
||||
(first args))
|
||||
(format port "~
|
||||
//~a
|
||||
protocol: efi
|
||||
path: boot():/EFI/Guix/OLD-~a.EFI~%"
|
||||
(first labels)
|
||||
count)))
|
||||
(loop (1+ count)
|
||||
(cdr labels)
|
||||
(cdr args)))))))))
|
||||
(rename-file (in-vicinity limine-directory "limine.conf.tmp")
|
||||
(in-vicinity limine-directory "limine.conf")))))))
|
||||
|
||||
(define install-limine-efi
|
||||
#~(lambda (bootloader target mount-point)
|
||||
(invoke (string-append mount-point #$script-path)
|
||||
(string-append mount-point target))))
|
||||
|
||||
;; Limine + UKI
|
||||
;; NOTE: ‘configuration-file’ here is actually an activation script to be invoked by
|
||||
;; ‘installer’.
|
||||
;; XXX: Not expected by ‘reinstall-bootloader’ so rolling-back and switching
|
||||
;; generation won't work.
|
||||
(define limine-efi-removable-bootloader
|
||||
(bootloader
|
||||
;; NOTE: Don't change the name. Generation switching code only knows
|
||||
;; bootloaders defined in (gnu bootloader grub).
|
||||
(name 'grub-efi-removable-bootloader)
|
||||
(package limine)
|
||||
(installer install-limine-efi)
|
||||
(disk-image-installer #f)
|
||||
(configuration-file script-path)
|
||||
(configuration-file-generator limine-configuration-file)))
|
||||
@ -13,42 +13,43 @@
|
||||
#:use-module (gnu bootloader)
|
||||
;; Guix packages
|
||||
#:use-module (rosenthal packages bootloaders)
|
||||
#:export (uefi-uki-removable-bootloader))
|
||||
#:export (menu-entry->ukify-args
|
||||
uefi-uki-removable-bootloader))
|
||||
|
||||
(define script-path "/boot/install-uki.scm")
|
||||
|
||||
(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)))
|
||||
#~(list "--os-release" #$label
|
||||
"--linux" #$linux
|
||||
"--initrd" #$initrd
|
||||
"--cmdline" (string-join (list #$@arguments))
|
||||
"--stub"
|
||||
#$(file-append systemd-stub "/libexec/" (systemd-stub-name)))))
|
||||
|
||||
(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)
|
||||
(use-modules (ice-9 match)
|
||||
(guix build utils))
|
||||
(let* ((ukify #$(file-append ukify "/bin/ukify"))
|
||||
(let* ((directory (second (command-line)))
|
||||
(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")))))
|
||||
(in-vicinity
|
||||
directory
|
||||
#$(format #f "/EFI/BOOT/BOOT~a.EFI"
|
||||
(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
|
||||
(apply invoke #$(file-append ukify "/bin/ukify")
|
||||
"build" "--output" installation-path
|
||||
#$(menu-entry->ukify-args (first entries))))))))
|
||||
|
||||
(define install-uefi-uki
|
||||
|
||||
@ -142,7 +142,7 @@ host Matrix for your family, friends or company.")
|
||||
(define-public tuwunel-bin
|
||||
(package
|
||||
(name "tuwunel-bin")
|
||||
(version "1.4.9.1")
|
||||
(version "1.5.0")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (string-append
|
||||
@ -152,7 +152,7 @@ host Matrix for your family, friends or company.")
|
||||
(file-name (string-append name "-" version ".zst"))
|
||||
(sha256
|
||||
(base32
|
||||
"078d978xy84fw42y7wkl97gmfqyfn2j3vhh8k7ywkgh9lhi30mbn"))))
|
||||
"0d2fmpsisnzqgrx0sq6zrn31jvdisnm6jb2q6qcc39z4jdllwhrb"))))
|
||||
(build-system copy-build-system)
|
||||
(arguments
|
||||
(list #:install-plan
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
;;; Copyright © 2024 Lilah Tascheter <lilah@lunabee.space>
|
||||
|
||||
(define-module (rosenthal packages bootloaders)
|
||||
#:use-module (srfi srfi-26)
|
||||
;; Utilities
|
||||
#:use-module (guix gexp)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
@ -12,6 +13,7 @@
|
||||
#:use-module (guix download)
|
||||
#:use-module (guix git-download)
|
||||
;; Guix build systems
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix build-system meson)
|
||||
#:use-module (guix build-system pyproject)
|
||||
;; Guix packages
|
||||
@ -19,6 +21,8 @@
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages bootloaders)
|
||||
#:use-module (gnu packages crypto)
|
||||
#:use-module (gnu packages assembly)
|
||||
#:use-module (gnu packages mtools)
|
||||
#:use-module (gnu packages efi)
|
||||
#:use-module (gnu packages gperf)
|
||||
#:use-module (gnu packages linux)
|
||||
@ -70,6 +74,56 @@
|
||||
`(,@(package-properties base)
|
||||
(disable-updater? . #t))))))
|
||||
|
||||
(define-public limine
|
||||
(package
|
||||
(name "limine")
|
||||
(version "10.8.2")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (string-append
|
||||
"https://codeberg.org/Limine/Limine/releases/download/v"
|
||||
version "/limine-" version ".tar.xz"))
|
||||
(sha256
|
||||
(base32
|
||||
"1y7qi39ryy8gwv25n0wv68dy1q1gzh0syn4z3psfrl7px98m5ikd"))))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
(list #:tests? #f
|
||||
#:configure-flags
|
||||
#~(list (string-append
|
||||
"TOOLCHAIN_FOR_TARGET="
|
||||
#$(or (and=> (%current-target-system)
|
||||
(cut string-append <> "-"))
|
||||
""))
|
||||
(string-append "--prefix=" #$output)
|
||||
#$@(if (target-x86?)
|
||||
'("--enable-bios-cd"
|
||||
"--enable-bios-pxe"
|
||||
"--enable-bios"
|
||||
"--enable-uefi-ia32")
|
||||
'())
|
||||
#$@(if (target-x86-64?)
|
||||
'("--enable-uefi-x86-64")
|
||||
'())
|
||||
#$@(if (target-aarch64?)
|
||||
'("--enable-uefi-aarch64")
|
||||
'())
|
||||
#$@(if (target-riscv64?)
|
||||
'("--enable-uefi-riscv64")
|
||||
'())
|
||||
#$@(if (target-loongarch64?)
|
||||
'("--enable-uefi-loongarch64")
|
||||
'()))
|
||||
#:make-flags
|
||||
#~(list "SHELL=sh")))
|
||||
(native-inputs (list mtools nasm))
|
||||
(home-page "https://codeberg.org/Limine/Limine")
|
||||
(synopsis "Multiprotocol bootloader and boot manager")
|
||||
(description
|
||||
"Limine is a multiprotocol bootloader and boot manager. It's also used as
|
||||
the reference implementation for the Limine boot protocol.")
|
||||
(license license:bsd-2)))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Unified Kernel Image support.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user