2017-05-15 16:24:18 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
|
;;; Copyright © 2017 David Craven <david@craven.ch>
|
2022-08-29 16:24:24 -04:00
|
|
|
|
;;; Copyright © 2017, 2020, 2022 Mathieu Othacehe <othacehe@gnu.org>
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
|
profiles: Hooks honor the #:system parameter of ‘profile-derivation’.
Fixes <https://issues.guix.gnu.org/65225>.
* guix/profiles.scm (info-dir-file, package-cache-file)
(info-dir-file, ghc-package-cache-file, ca-certificate-bundle)
(emacs-subdirs, gdk-pixbuf-loaders-cache-file, glib-schemas)
(gtk-icon-themes, gtk-im-modules, linux-module-database)
(xdg-desktop-database, xdg-mime-database, fonts-dir-file)
(manual-database, manual-database/optional): Add optional #:system
parameter and pass it to ‘gexp->derivation’.
(profile-derivation): Pass HOOK a second parameter, SYSTEM.
* gnu/bootloader.scm (efi-bootloader-profile)[efi-bootloader-profile-hook]:
Add optional #:system parameter and pass it to ‘gexp->derivation’.
* guix/channels.scm (package-cache-file): Likewise.
* tests/profiles.scm ("profile-derivation, #:system, and hooks"): New
test.
Reported-by: Tobias Geerinckx-Rice <me@tobias.gr>
2023-10-19 10:39:06 -04:00
|
|
|
|
;;; Copyright © 2019, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
|
2020-05-26 10:54:18 -04:00
|
|
|
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2022-08-21 04:41:15 -04:00
|
|
|
|
;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
|
2022-08-28 04:04:46 -04:00
|
|
|
|
;;; Copyright © 2022 Reza Alizadeh Majd <r.majd@pantherx.org>
|
2024-01-11 12:35:40 -05:00
|
|
|
|
;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz>
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
;;; Copyright © 2024 Lilah Tascheter <lilah@lunabee.space>
|
2024-09-15 13:16:24 -04:00
|
|
|
|
;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (gnu bootloader)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:autoload (gnu build file-systems)
|
|
|
|
|
(read-partition-label read-partition-uuid
|
|
|
|
|
find-partition-by-label find-partition-by-uuid)
|
2024-10-01 07:57:57 -04:00
|
|
|
|
#:use-module (gnu services configuration)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
#:use-module (gnu system file-systems)
|
|
|
|
|
#:use-module (gnu system uuid)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:autoload (guix build syscalls)
|
|
|
|
|
(mounts mount-source mount-point mount-type)
|
2021-08-30 08:22:35 -04:00
|
|
|
|
#:use-module (guix deprecation)
|
|
|
|
|
#:use-module (guix diagnostics)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:use-module (guix gexp)
|
2021-08-30 08:22:35 -04:00
|
|
|
|
#:use-module (guix i18n)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:use-module (guix modules)
|
|
|
|
|
#:use-module (guix profiles)
|
|
|
|
|
#:use-module (guix records)
|
|
|
|
|
#:use-module (guix utils)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (ice-9 receive)
|
gnu: bootloader: Update bootloader-configuration targets field.
* gnu/bootloader.scm (warn-update-targets): New procedure.
(bootloader-configuration)[targets]: Use warn-update-targets sanitizer.
* gnu/installer/parted.scm (bootloader-configuration): Use new target
field format.
* gnu/system/images/hurd.scm (hurd-barebones-os)[bootloader],
gnu/system/images/novena.scm (novena-barebones-os)[bootloader],
gnu/system/images/orangepi-r1-plus-lts-rk3328.scm
(orangepi-r1-plus-lts-rk3328-barebones-os)[bootloader],
gnu/system/images/pine64.scm (pine64-barebones-os)[bootloader],
gnu/system/images/pinebook-pro.scm
(pinebook-pro-barebones-os)[bootloader],
gnu/system/images/rock64.scm (rock64-barebones-os)[bootloader],
gnu/system/images/unmatched.scm (unmatched-barebones-os)[bootloader],
gnu/system/images/visionfive2.scm
(visionfive2-barebones-os)[bootloader]: Use new target format.
* gnu/system/install.scm (installation-os)[bootloader]: Use new format.
(embedded-installation-os): Use new format and adjust description.
(beaglebone-black-installation-os, a20-olinuxino-lime-installation-os,
a20-olinuxino-lime2-emmc-installation-os,
a20-olinuxino-micro-installation-os, bananapi-m2-ultra-installation-os,
firefly-rk3399-installation-os, mx6cuboxi-installation-os,
novena-installation-os, nintendo-nes-classic-edition-installation-os,
orangepi-r1-plus-lts-rk3328-installation-os, pine64-plus-installation-os,
pinebook-installation-os, rock64-installation-os,
rockpro64-installation-os, rk3399-puma-installation-os,
wandboard-installation-os): Don't guess block device.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
#:use-module (ice-9 regex)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:use-module (rnrs bytevectors)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
#:use-module (srfi srfi-26)
|
2022-09-04 13:25:42 -04:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-35)
|
2017-05-29 08:24:20 -04:00
|
|
|
|
#:export (menu-entry
|
|
|
|
|
menu-entry?
|
|
|
|
|
menu-entry-label
|
|
|
|
|
menu-entry-device
|
2024-08-06 20:11:17 -04:00
|
|
|
|
menu-entry-device-mount-point
|
|
|
|
|
menu-entry-device-subvol
|
2017-05-29 08:24:20 -04:00
|
|
|
|
menu-entry-linux
|
|
|
|
|
menu-entry-linux-arguments
|
|
|
|
|
menu-entry-initrd
|
2020-05-26 10:54:18 -04:00
|
|
|
|
menu-entry-multiboot-kernel
|
|
|
|
|
menu-entry-multiboot-arguments
|
|
|
|
|
menu-entry-multiboot-modules
|
2022-09-04 13:25:38 -04:00
|
|
|
|
menu-entry-chain-loader
|
2017-05-29 08:24:20 -04:00
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
normalize-file
|
2019-08-28 17:27:20 -04:00
|
|
|
|
menu-entry->sexp
|
|
|
|
|
sexp->menu-entry
|
|
|
|
|
|
2017-05-29 08:24:20 -04:00
|
|
|
|
bootloader
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader?
|
|
|
|
|
bootloader-name
|
2024-08-06 20:11:17 -04:00
|
|
|
|
bootloader-default-targets
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-installer
|
|
|
|
|
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
bootloader-target
|
|
|
|
|
bootloader-target?
|
|
|
|
|
bootloader-target-type
|
|
|
|
|
bootloader-target-expected?
|
|
|
|
|
bootloader-target-path
|
|
|
|
|
bootloader-target-offset
|
|
|
|
|
bootloader-target-device
|
|
|
|
|
bootloader-target-file-system
|
|
|
|
|
|
|
|
|
|
target-error?
|
|
|
|
|
target-error-type
|
|
|
|
|
target-error-targets
|
|
|
|
|
|
2024-09-29 07:31:21 -04:00
|
|
|
|
find-mount
|
|
|
|
|
find-file-system
|
|
|
|
|
label->uuid
|
|
|
|
|
uuid->file-system
|
|
|
|
|
mount-point->block-device
|
|
|
|
|
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
gbegin
|
|
|
|
|
:path :devpath :device :fs :label :uuid
|
|
|
|
|
with-targets
|
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration
|
|
|
|
|
bootloader-configuration?
|
|
|
|
|
bootloader-configuration-bootloader
|
2021-08-06 16:33:02 -04:00
|
|
|
|
bootloader-configuration-targets
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration-menu-entries
|
|
|
|
|
bootloader-configuration-default-entry
|
2024-08-06 20:11:17 -04:00
|
|
|
|
bootloader-configuration-efi-removable?
|
|
|
|
|
bootloader-configuration-32bit?
|
2024-08-06 20:11:24 -04:00
|
|
|
|
bootloader-configuration-keypair
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration-timeout
|
2019-03-17 17:37:53 -04:00
|
|
|
|
bootloader-configuration-keyboard-layout
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration-theme
|
|
|
|
|
bootloader-configuration-terminal-outputs
|
|
|
|
|
bootloader-configuration-terminal-inputs
|
|
|
|
|
bootloader-configuration-serial-unit
|
|
|
|
|
bootloader-configuration-serial-speed
|
2022-08-28 04:04:46 -04:00
|
|
|
|
bootloader-configuration-device-tree-support?
|
2024-01-11 12:35:40 -05:00
|
|
|
|
bootloader-configuration-extra-initrd
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
bootloader-configuration->gexp
|
|
|
|
|
bootloader-configurations->gexp
|
2020-10-25 12:59:19 -04:00
|
|
|
|
|
2024-09-15 13:16:24 -04:00
|
|
|
|
match-bootloader-configuration
|
|
|
|
|
match-menu-entry
|
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
%efi-supported-systems
|
|
|
|
|
efi-arch
|
gnu: bootloader: Add Raspberry Pi bootloader.
Less adding and more making it an actual bootloader rather than some
weirdly specified packages. The GRUB EFI bootloader can be recreated by
combining a Raspberry Pi bootloader with grub-efi.
* gnu/bootloader.scm (efi-bootloader-profile, efi-bootloader-chain):
Delete procedures.
* gnu/bootloader/u-boot.scm (rpi-config, install-rpi,
make-u-boot-rpi-bootloader): New procedures.
(u-boot-rpi-2-bootloader, u-boot-rpi-3-bootloader,
u-boot-rpi-4-bootloader, u-boot-rpi-bootloader): New variables.
* gnu/packages/bootloaders.scm (make-u-boot-bin-package): Delete
procedure.
(%u-boot-rpi-efi-description, %u-boot-rpi-efi-description-32-bit,
u-boot-rpi-2-efi, u-boot-rpi-3-32b-efi, u-boot-rpi-4-32b-efi,
u-boot-rpi-arm64-efi, u-boot-rpi-2-bin, u-boot-rpi-3_32b-bin,
u-boot-rpi-4_32b-bin, u-boot-rpi-arm64-bin, u-boot-rpi-2-efi-bin,
u-boot-rpi-3-32b-efi-bin, u-boot-rpi-4-32b-efi-bin,
u-boot-rpi-arm64-efi-bin): Delete variables.
* gnu/packages/raspberry-pi.scm (grub-efi-bootloader-chain-raspi-64):
Delete procedure.
* gnu/system/examples/raspberry-pi-64-nfs-root.tmpl (bootloader),
gnu/system/examples/raspberry-pi-64.tmpl (bootloader): Use new target
system.
Change-Id: I5139a0b00ec89189e8e7c84e06a7a3b7240259cd
2024-08-06 20:11:19 -04:00
|
|
|
|
install-efi))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
2017-05-29 08:24:20 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Menu-entry record.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-record-type* <menu-entry>
|
|
|
|
|
menu-entry make-menu-entry
|
|
|
|
|
menu-entry?
|
|
|
|
|
(label menu-entry-label)
|
|
|
|
|
(device menu-entry-device ; file system uuid, label, or #f
|
|
|
|
|
(default #f))
|
2017-06-29 06:42:59 -04:00
|
|
|
|
(device-mount-point menu-entry-device-mount-point
|
|
|
|
|
(default #f))
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(device-subvol menu-entry-device-subvol
|
|
|
|
|
(default #f))
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(linux menu-entry-linux
|
|
|
|
|
(default #f))
|
2017-05-29 08:24:20 -04:00
|
|
|
|
(linux-arguments menu-entry-linux-arguments
|
|
|
|
|
(default '())) ; list of string-valued gexps
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(initrd menu-entry-initrd ; file name of the initrd as a gexp
|
|
|
|
|
(default #f))
|
|
|
|
|
(multiboot-kernel menu-entry-multiboot-kernel
|
|
|
|
|
(default #f))
|
|
|
|
|
(multiboot-arguments menu-entry-multiboot-arguments
|
|
|
|
|
(default '())) ; list of string-valued gexps
|
|
|
|
|
(multiboot-modules menu-entry-multiboot-modules
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(default '())) ; list of multiboot commands, where
|
2020-05-26 10:54:18 -04:00
|
|
|
|
; a command is a list of <string>
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(chain-loader menu-entry-chain-loader
|
|
|
|
|
(default #f))) ; string, path of efi file
|
2017-05-29 08:24:20 -04:00
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(define (normalize-file entry file)
|
|
|
|
|
"Normalize a file FILE stored in a menu entry into one suitable for a
|
|
|
|
|
bootloader. Realizes device-mount-point and device-subvol."
|
|
|
|
|
(match-menu-entry entry (device-mount-point device-subvol)
|
|
|
|
|
;; Avoid using cut procedure from SRFI-26 inside G-exp.
|
|
|
|
|
(let ((mount (and=> device-mount-point (cut string-trim <> #\/))))
|
|
|
|
|
#~(let* ((file (string-trim #$file #\/))
|
|
|
|
|
(file (if (and #$mount (string-prefix? #$mount file))
|
|
|
|
|
(substring file (string-length #$mount))
|
|
|
|
|
file)))
|
|
|
|
|
(string-append (or #$device-subvol "") "/" file)))))
|
|
|
|
|
|
2022-09-04 13:25:42 -04:00
|
|
|
|
(define (report-menu-entry-error menu-entry)
|
|
|
|
|
(raise
|
|
|
|
|
(condition
|
|
|
|
|
(&message
|
|
|
|
|
(message
|
|
|
|
|
(format #f (G_ "invalid menu-entry: ~a") menu-entry)))
|
|
|
|
|
(&fix-hint
|
|
|
|
|
(hint
|
|
|
|
|
(G_ "Please chose only one of:
|
|
|
|
|
@enumerate
|
|
|
|
|
@item direct boot by specifying fields @code{linux},
|
|
|
|
|
@code{linux-arguments} and @code{linux-modules},
|
|
|
|
|
@item multiboot by specifying fields @code{multiboot-kernel},
|
|
|
|
|
@code{multiboot-arguments} and @code{multiboot-modules},
|
|
|
|
|
@item chain-loader by specifying field @code{chain-loader}.
|
|
|
|
|
@end enumerate"))))))
|
|
|
|
|
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(define (menu-entry->sexp entry)
|
|
|
|
|
"Return ENTRY serialized as an sexp."
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(define (device->sexp device)
|
|
|
|
|
(match device
|
|
|
|
|
((? uuid? uuid)
|
gnu: build: file-systems: Return uuid records.
* gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): Swap order in
match subprocedures.
* gnu/build/file-systems.scm (ext2-superblock-uuid,
linux-swap-superblock-uuid, bcachefs-superblock-external-uuid,
btrfs-superblock-uuid, exfat-superblock-uuid, fat32-superblock-uuid,
fat16-superblock-uuid, iso9660-superblock-uuid, jfs-superblock-uuid,
f2fs-superblock-uuid, luks-header-uuid, ntfs-superblock-uuid,
xfs-superblock-uuid): Wrap bytevector in uuid record.
* gnu/build/image.scm (make-iso9660-image): Take uuid as string.
* gnu/installer/parted.scm (user-partition->file-system): Do not provide
uuid-type.
* gnu/system/image.scm (system-iso9660-image): Convert uuid to string.
* gnu/system/uuid.scm (dce-uuid->string, iso9660-uuid->string): Do not
export.
Change-Id: I35435de0d808e66e17fd9b54247a7a11a93ecd62
2024-10-01 07:35:08 -04:00
|
|
|
|
`(uuid ,(uuid->string uuid) ,(uuid-type uuid)))
|
2022-08-21 04:41:15 -04:00
|
|
|
|
((? file-system-label? label)
|
|
|
|
|
`(label ,(file-system-label->string label)))
|
|
|
|
|
(_ device)))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(match entry
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(($ <menu-entry> label device mount-point subvol
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(? identity linux) linux-arguments (? identity initrd)
|
|
|
|
|
#f () () #f)
|
2019-08-28 17:27:20 -04:00
|
|
|
|
`(menu-entry (version 0)
|
|
|
|
|
(label ,label)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(device ,(device->sexp device))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(device-mount-point ,mount-point)
|
|
|
|
|
(linux ,linux)
|
|
|
|
|
(linux-arguments ,linux-arguments)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(initrd ,initrd)
|
|
|
|
|
(device-subvol ,subvol)))
|
|
|
|
|
(($ <menu-entry> label device mount-point subvol #f () #f
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(? identity multiboot-kernel) multiboot-arguments
|
|
|
|
|
multiboot-modules #f)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
`(menu-entry (version 0)
|
|
|
|
|
(label ,label)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(device ,(device->sexp device))
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(device-mount-point ,mount-point)
|
|
|
|
|
(multiboot-kernel ,multiboot-kernel)
|
|
|
|
|
(multiboot-arguments ,multiboot-arguments)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(multiboot-modules ,multiboot-modules)
|
|
|
|
|
(device-subvol ,subvol)))
|
|
|
|
|
(($ <menu-entry> label device mount-point subvol #f () #f #f () ()
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(? identity chain-loader))
|
|
|
|
|
`(menu-entry (version 0)
|
|
|
|
|
(label ,label)
|
|
|
|
|
(device ,(device->sexp device))
|
|
|
|
|
(device-mount-point ,mount-point)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(chain-loader ,chain-loader)
|
|
|
|
|
(device-subvol ,subvol)))
|
2022-09-04 13:25:42 -04:00
|
|
|
|
(_ (report-menu-entry-error entry))))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
|
|
|
|
|
(define (sexp->menu-entry sexp)
|
|
|
|
|
"Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
|
|
|
|
|
record."
|
2024-08-06 20:11:17 -04:00
|
|
|
|
;; XXX: The match ORs shadow subvol.
|
|
|
|
|
(define subvol #f)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(define (sexp->device device-sexp)
|
|
|
|
|
(match device-sexp
|
gnu: build: file-systems: Return uuid records.
* gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): Swap order in
match subprocedures.
* gnu/build/file-systems.scm (ext2-superblock-uuid,
linux-swap-superblock-uuid, bcachefs-superblock-external-uuid,
btrfs-superblock-uuid, exfat-superblock-uuid, fat32-superblock-uuid,
fat16-superblock-uuid, iso9660-superblock-uuid, jfs-superblock-uuid,
f2fs-superblock-uuid, luks-header-uuid, ntfs-superblock-uuid,
xfs-superblock-uuid): Wrap bytevector in uuid record.
* gnu/build/image.scm (make-iso9660-image): Take uuid as string.
* gnu/installer/parted.scm (user-partition->file-system): Do not provide
uuid-type.
* gnu/system/image.scm (system-iso9660-image): Convert uuid to string.
* gnu/system/uuid.scm (dce-uuid->string, iso9660-uuid->string): Do not
export.
Change-Id: I35435de0d808e66e17fd9b54247a7a11a93ecd62
2024-10-01 07:35:08 -04:00
|
|
|
|
(('uuid uuid-string type)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(uuid uuid-string type))
|
|
|
|
|
(('label label)
|
|
|
|
|
(file-system-label label))
|
|
|
|
|
(_ device-sexp)))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(match sexp
|
|
|
|
|
(('menu-entry ('version 0)
|
|
|
|
|
('label label) ('device device)
|
|
|
|
|
('device-mount-point mount-point)
|
|
|
|
|
('linux linux) ('linux-arguments linux-arguments)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
('initrd initrd)
|
|
|
|
|
(or ('device-subvol subvol _ ...) (_ ...)))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(menu-entry
|
|
|
|
|
(label label)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(device (sexp->device device))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(device-mount-point mount-point)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(device-subvol subvol)
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(linux linux)
|
|
|
|
|
(linux-arguments linux-arguments)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(initrd initrd)))
|
|
|
|
|
(('menu-entry ('version 0)
|
|
|
|
|
('label label) ('device device)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
('device-mount-point mount-point) ('device-subvol subvol)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
('multiboot-kernel multiboot-kernel)
|
|
|
|
|
('multiboot-arguments multiboot-arguments)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
('multiboot-modules multiboot-modules)
|
|
|
|
|
(or ('device-subvol subvol _ ...) (_ ...)))
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(menu-entry
|
|
|
|
|
(label label)
|
2022-08-21 04:41:15 -04:00
|
|
|
|
(device (sexp->device device))
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(device-mount-point mount-point)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(device-subvol subvol)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(multiboot-kernel multiboot-kernel)
|
|
|
|
|
(multiboot-arguments multiboot-arguments)
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(multiboot-modules multiboot-modules)))
|
|
|
|
|
(('menu-entry ('version 0)
|
|
|
|
|
('label label) ('device device)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
('device-mount-point mount-point) ('device-subvol subvol)
|
|
|
|
|
('chain-loader chain-loader)
|
|
|
|
|
(or ('device-subvol subvol _ ...) (_ ...)))
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(menu-entry
|
|
|
|
|
(label label)
|
|
|
|
|
(device (sexp->device device))
|
|
|
|
|
(device-mount-point mount-point)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(device-subvol subvol)
|
2022-09-04 13:25:38 -04:00
|
|
|
|
(chain-loader chain-loader)))))
|
2019-08-28 17:27:20 -04:00
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader record.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
;; The <bootloader> record contains fields expressing how the bootloader
|
|
|
|
|
;; should be installed. Every bootloader in gnu/bootloader/ directory
|
|
|
|
|
;; has to be described by this record.
|
|
|
|
|
|
|
|
|
|
(define-record-type* <bootloader>
|
2024-08-06 20:11:17 -04:00
|
|
|
|
bootloader make-bootloader bootloader?
|
|
|
|
|
(name bootloader-name)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(default-targets bootloader-default-targets (default '()))
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(installer bootloader-installer))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader target record.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
;; <bootloader-target> represents different kinds of targets in a
|
|
|
|
|
;; normalized form.
|
|
|
|
|
|
2024-10-01 07:57:57 -04:00
|
|
|
|
(define (string-or-boolean? x)
|
|
|
|
|
(or (string? x) (boolean? x)))
|
|
|
|
|
|
|
|
|
|
(define (symbol-or-boolean? x)
|
|
|
|
|
(or (symbol? x) (boolean? x)))
|
|
|
|
|
|
|
|
|
|
;; XXX: Are file-system-labels all that good?
|
|
|
|
|
;; Could a block-device record be better, instead?
|
|
|
|
|
(define (file-system-label-or-boolean? x)
|
|
|
|
|
(or (file-system-label? x) (boolean? x)))
|
|
|
|
|
|
2024-10-01 16:09:30 -04:00
|
|
|
|
;; TODO: Create wrapper record for block-device.
|
|
|
|
|
(define (uuid-or-string-or-boolean? x)
|
|
|
|
|
(or (uuid? x) (string? x) (boolean? x)))
|
2024-10-01 07:57:57 -04:00
|
|
|
|
|
|
|
|
|
(define-configuration/no-serialization bootloader-target
|
|
|
|
|
(type symbol "What target this record describes, e.g. 'esp or 'disk.")
|
|
|
|
|
(expected? (boolean #f) "TODO")
|
|
|
|
|
(path (string-or-boolean #f) "TODO")
|
|
|
|
|
(offset (symbol-or-boolean #f) "TODO")
|
|
|
|
|
(device
|
2024-10-01 16:09:30 -04:00
|
|
|
|
(uuid-or-string-or-boolean #f)
|
2024-10-01 07:57:57 -04:00
|
|
|
|
"Refers to a physical device or partition. A string is interpreted
|
|
|
|
|
as a block device. Note that block devices can vary per boot and may
|
|
|
|
|
not exist at boot-time. The find-partition-uuid procedure returns a
|
|
|
|
|
block device's UUID.")
|
|
|
|
|
(file-system
|
|
|
|
|
(string-or-boolean #f)
|
|
|
|
|
"Set the type of the file system, in case it isn't being detected
|
|
|
|
|
properly, or it is unmounted during bootloader installation. See also
|
2024-10-01 16:09:30 -04:00
|
|
|
|
the find-file-system and uuid->file-system procedures."))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
|
|
|
|
|
(define-condition-type &target-error &error target-error?
|
|
|
|
|
(type target-error-type)
|
|
|
|
|
(targets target-error-targets))
|
|
|
|
|
|
2024-09-29 07:31:21 -04:00
|
|
|
|
;; XXX: Use a more appropriate name than FS?
|
|
|
|
|
(define (find-mount block-device-or-fs)
|
|
|
|
|
"Return the <mount> record with source BLOCK-DEVICE-OR-FS, or #f
|
|
|
|
|
otherwise. An FS could be efivarsfs, cgroup etc.."
|
|
|
|
|
(define (block-device-or-fs? mount)
|
|
|
|
|
(and (string=? block-device-or-fs (mount-source mount)) mount))
|
|
|
|
|
;; A mount source is either a block device or an FS.
|
|
|
|
|
(when (and (not (string-prefix? "/dev/" block-device-or-fs))
|
|
|
|
|
(or (string-contains "/" block-device-or-fs)
|
|
|
|
|
(string=? "none" block-device-or-fs)))
|
|
|
|
|
(error (G_ "not a block device with mount~%") block-device-or-fs))
|
|
|
|
|
(any block-device-or-fs? (mounts)))
|
|
|
|
|
|
|
|
|
|
(define (find-file-system block-device)
|
|
|
|
|
"Detects the type of a given block device. Return #f if not found."
|
|
|
|
|
(and=> (find-mount block-device) mount-type))
|
|
|
|
|
|
|
|
|
|
(define (label->uuid label)
|
|
|
|
|
(and=> (find-partition-by-label (file-system-label->string label))
|
|
|
|
|
read-partition-uuid))
|
|
|
|
|
|
|
|
|
|
(define (uuid->file-system uuid)
|
|
|
|
|
"Returns the UUID's type as a string. Does not depend on current
|
|
|
|
|
mounts, unlike find-file-system. Use together with the find-uuid, or
|
|
|
|
|
label->uuid procedure."
|
|
|
|
|
(symbol->string (uuid-type uuid)))
|
|
|
|
|
|
|
|
|
|
;; TODO: Test together with find-mount.
|
|
|
|
|
(define (mount-point->block-device point)
|
|
|
|
|
"Return the block device mounted on POINT, or #f otherwise."
|
|
|
|
|
(define (point? mount)
|
|
|
|
|
(and (string=? point (mount-point mount)) (mount-source mount)))
|
|
|
|
|
;; A mount point is an absolute path.
|
|
|
|
|
(unless (string-prefix? "/" point)
|
|
|
|
|
(error (G_ "mount point is not an absolute path~%") point))
|
|
|
|
|
(any point? (mounts)))
|
|
|
|
|
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
(define (pathcat p1 p2)
|
|
|
|
|
(string-append (string-trim-right p1 #\/) "/" (string-trim p2 #\/)))
|
|
|
|
|
|
|
|
|
|
(define* (get-target-of-type type targets #:optional require?)
|
2024-10-01 07:57:57 -04:00
|
|
|
|
"Finds a target in TARGETS of type TYPE, returns #f if REQUIRE? is #f,
|
|
|
|
|
and provides an error otherwise."
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
(define (type? target)
|
|
|
|
|
(eq? type (bootloader-target-type target)))
|
|
|
|
|
(match (filter type? targets)
|
|
|
|
|
((target _ ...) target)
|
|
|
|
|
(_ (and require?
|
|
|
|
|
(raise
|
|
|
|
|
(condition
|
|
|
|
|
(&message (message (G_ "required, but not provided")))
|
|
|
|
|
(&target-error (type type) (targets targets))))))))
|
|
|
|
|
|
|
|
|
|
(define (parent-of target targets)
|
|
|
|
|
"Resolve the parent of TARGET in TARGETS, return #f if orphan."
|
|
|
|
|
(and=> (bootloader-target-offset target)
|
|
|
|
|
(cut get-target-of-type <> targets #t)))
|
|
|
|
|
|
|
|
|
|
(define (unfold-pathcat target targets)
|
|
|
|
|
"Find the full VFS path of TARGET."
|
|
|
|
|
(let ((quit (lambda (t) (not (and=> t bootloader-target-path))))
|
|
|
|
|
(parent-of (cut parent-of <> targets)))
|
|
|
|
|
(reduce pathcat #f
|
|
|
|
|
(unfold quit bootloader-target-path parent-of target))))
|
|
|
|
|
|
|
|
|
|
(define (target-base? t)
|
|
|
|
|
(or (not t) (match-record t <bootloader-target>
|
2024-10-01 16:09:30 -04:00
|
|
|
|
(expected? offset device)
|
|
|
|
|
(or device (not offset) expected?))))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
|
|
|
|
|
(define (type-major? target) (memq target '(root esp disk)))
|
|
|
|
|
|
|
|
|
|
(define (ensure types targets end)
|
|
|
|
|
(let* ((used-in (cute unfold end identity (cut parent-of <> targets) <>))
|
|
|
|
|
(cons-in (lambda (t) (cons t (used-in t))))
|
|
|
|
|
(ensure (map (cut get-target-of-type <> targets #t) types)))
|
|
|
|
|
(filter identity (apply append (map cons-in ensure)))))
|
|
|
|
|
|
|
|
|
|
(define* (ensure-target-types types targets #:optional (base? #f))
|
|
|
|
|
"Ensures all TYPES are provided in TARGETS. Returns #t iff every ensured
|
|
|
|
|
target and its requirements are fully provided. Errors out when a required TYPE
|
|
|
|
|
isn't provided. When BASE?, only ensure path requirements up to a device."
|
2024-10-01 07:57:57 -04:00
|
|
|
|
(let ((base (if base? target-base? not)))
|
|
|
|
|
(not (any bootloader-target-expected? (ensure types targets base)))))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
|
|
|
|
|
(define (ensure-majors types targets)
|
|
|
|
|
"Errors out when a required TYPE isn't provided, or when use of multiple major
|
|
|
|
|
targets is detected."
|
2024-10-01 07:57:57 -04:00
|
|
|
|
(let* ((all (map bootloader-target-type
|
|
|
|
|
(ensure types targets target-base?)))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
(majors (delete-duplicates (filter type-major? all) eq?)))
|
|
|
|
|
(if (< (length majors) 2) #t
|
|
|
|
|
(raise (condition (&message (message (G_ "multiple major targets used")))
|
|
|
|
|
(&target-error (type majors) (targets targets)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (gbegin . gex)
|
|
|
|
|
"Sequence provided g-expressions."
|
|
|
|
|
(case (length gex) ((0) #f) ((1) (car gex)) (else #~(begin #$@gex))))
|
|
|
|
|
|
|
|
|
|
;; syntax matching on free literals breaks easily, so bind them
|
|
|
|
|
(define-syntax-rule (define-literal id) (define-syntax id (syntax-rules ())))
|
|
|
|
|
(define-literal :path)
|
|
|
|
|
(define-literal :devpath)
|
|
|
|
|
(define-literal :device)
|
|
|
|
|
(define-literal :fs)
|
|
|
|
|
(define-literal :label)
|
|
|
|
|
(define-literal :uuid)
|
|
|
|
|
|
|
|
|
|
(define-syntax with-targets
|
|
|
|
|
(cut syntax-case <> ()
|
|
|
|
|
((_ targets-expr block ...)
|
|
|
|
|
(let* ((genvars (compose generate-temporaries make-list))
|
|
|
|
|
(targets (car (genvars 1))))
|
|
|
|
|
(define (resolve in target base)
|
|
|
|
|
(with-syntax ((target target) (base base) (targets targets))
|
|
|
|
|
(syntax-case in
|
|
|
|
|
(:path :devpath :device :fs :label :uuid)
|
|
|
|
|
((name _) (not (identifier? #'name))
|
|
|
|
|
#`(_ (syntax-error "binds must be to identifiers" #,in)))
|
2024-10-01 16:09:30 -04:00
|
|
|
|
((name :device)
|
|
|
|
|
#'(name (and (string? (bootloader-target-device base))
|
|
|
|
|
(bootloader-target-device base))))
|
|
|
|
|
((name :label)
|
|
|
|
|
#'(name (and (string? (bootloader-target-device base))
|
|
|
|
|
(bootloader-target-device base))))
|
|
|
|
|
((name :uuid)
|
|
|
|
|
#'(name (and (uuid? (bootloader-target-device base))
|
|
|
|
|
(bootloader-target-device base))))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
((name :fs) #'(name (bootloader-target-file-system base)))
|
|
|
|
|
((name :path) #'(name (unfold-pathcat target targets)))
|
|
|
|
|
((name :devpath)
|
|
|
|
|
#'(name (if (target-base? target)
|
|
|
|
|
"/"
|
|
|
|
|
(pathcat "/" (bootloader-target-path target)))))
|
|
|
|
|
(_ #`(_ (syntax-error "invalid binding spec" #,in))))))
|
|
|
|
|
|
|
|
|
|
(define (binds spec)
|
|
|
|
|
(syntax-case spec (=>)
|
|
|
|
|
((type => binds ...)
|
|
|
|
|
(with-syntax (((target base) (genvars 2)) (targets targets))
|
|
|
|
|
(append
|
|
|
|
|
#`((get (lambda (t) (get-target-of-type t targets #t)))
|
|
|
|
|
(target (get type))
|
|
|
|
|
(base (if (target-base? target)
|
|
|
|
|
target
|
|
|
|
|
(get (bootloader-target-offset target)))))
|
|
|
|
|
(map (cut resolve <> #'target #'base) #'(binds ...)))))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
|
|
|
|
|
(define blocks
|
|
|
|
|
(cut syntax-case <> ()
|
|
|
|
|
((spec ... expr)
|
|
|
|
|
(let* ((path? (cut syntax-case <> (:path) ((_ :path) #t) (_ #f)))
|
|
|
|
|
(qualified? (cut syntax-case <> (=>)
|
2024-10-01 07:57:57 -04:00
|
|
|
|
((_ => spec ...)
|
|
|
|
|
(any path? #'(spec ...)))
|
gnu: bootloader: Add bootloader-target record and infastructure.
* gnu/bootloader.scm (bootloader-target): New record.
(&target-error): New condition.
(pathcat, get-target-of-type, parent-of, unfold-pathcat, target-base?,
type-major?, ensure, ensure-target-types, ensure-majors, gbegin): New
procedures.
(define-literal, with-targets, :path, :devpath, :device, :fs, :label,
:uuid): New macros.
* guix/ui.scm (call-with-error-handling)[target-error?]: Handle
target-errors.
Change-Id: I3f07c9096dd8b91c04449b6360b3b7d21640da14
2024-08-06 20:11:15 -04:00
|
|
|
|
(_ #f)))
|
|
|
|
|
(specs #'(spec ...))
|
|
|
|
|
(lets (apply append (filter-map binds specs)))
|
|
|
|
|
(type (cut syntax-case <> (=>)
|
|
|
|
|
((t => _ ...) #'t) (t #'t))))
|
|
|
|
|
(receive (full part) (partition qualified? specs)
|
|
|
|
|
#`(and (ensure-majors (list #,@(map type specs)) #,targets)
|
|
|
|
|
(ensure-target-types (list #,@(map type part))
|
|
|
|
|
#,targets #t)
|
|
|
|
|
(ensure-target-types (list #,@(map type full))
|
|
|
|
|
#,targets #f)
|
|
|
|
|
(let* #,lets expr)))))
|
|
|
|
|
(bad #'(syntax-error "malformed block" bad))))
|
|
|
|
|
"Using the list TARGETS, evaluate and sequence each BLOCK to produce a
|
|
|
|
|
gexp. BLOCK is a set of SPECs followed by an EXPR (evaluating to a gexp).
|
|
|
|
|
Each SPEC denotes a type of target to guard EXPR on their existance and
|
|
|
|
|
full-qualification. This procedure is linear in regard to BLOCKs.
|
|
|
|
|
|
|
|
|
|
SPEC may be of the following forms:
|
|
|
|
|
@itemize
|
|
|
|
|
@item 'TYPE Requires TYPE to be fully present or promised. Errors otherwise.
|
|
|
|
|
@item ('TYPE => (VAR COMPONENT) ...): As type, but also binds variables. TYPE's
|
|
|
|
|
COMPONENT is bound to the variable VAR as described below.
|
|
|
|
|
@end itemize
|
|
|
|
|
|
|
|
|
|
Available COMPONENTs are:
|
|
|
|
|
@itemize
|
|
|
|
|
@item :path (fully-qualified)
|
|
|
|
|
@item :devpath (relative from device)
|
|
|
|
|
@item :device (auto-detected from uuid and label if not user-provided)
|
|
|
|
|
@item :fs
|
|
|
|
|
@item :label
|
|
|
|
|
@item :uuid
|
|
|
|
|
@end itemize
|
|
|
|
|
|
|
|
|
|
Note that installers may be called multiple times with different targets being
|
|
|
|
|
fully-qualified. To ensure that targets aren't installed multiple times, make sure
|
|
|
|
|
that each BLOCK ensures at least one major target, either directly or indirectly.
|
|
|
|
|
Likewise, at most one major target should be ensured per BLOCK, under the same
|
|
|
|
|
conditions. Major targets originate from disk image handling, and are currently:
|
|
|
|
|
@itemize
|
|
|
|
|
@item disk
|
|
|
|
|
@item root
|
|
|
|
|
@item esp
|
|
|
|
|
@end itemize"
|
|
|
|
|
#`(let ((#,targets targets-expr))
|
|
|
|
|
(apply gbegin (filter identity
|
|
|
|
|
(list #,@(map blocks #'(block ...))))))))
|
|
|
|
|
(bad #'(syntax-error "must provide targets" bad))))
|
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader configuration record.
|
|
|
|
|
;;;
|
|
|
|
|
|
gnu: bootloader: Update bootloader-configuration targets field.
* gnu/bootloader.scm (warn-update-targets): New procedure.
(bootloader-configuration)[targets]: Use warn-update-targets sanitizer.
* gnu/installer/parted.scm (bootloader-configuration): Use new target
field format.
* gnu/system/images/hurd.scm (hurd-barebones-os)[bootloader],
gnu/system/images/novena.scm (novena-barebones-os)[bootloader],
gnu/system/images/orangepi-r1-plus-lts-rk3328.scm
(orangepi-r1-plus-lts-rk3328-barebones-os)[bootloader],
gnu/system/images/pine64.scm (pine64-barebones-os)[bootloader],
gnu/system/images/pinebook-pro.scm
(pinebook-pro-barebones-os)[bootloader],
gnu/system/images/rock64.scm (rock64-barebones-os)[bootloader],
gnu/system/images/unmatched.scm (unmatched-barebones-os)[bootloader],
gnu/system/images/visionfive2.scm
(visionfive2-barebones-os)[bootloader]: Use new target format.
* gnu/system/install.scm (installation-os)[bootloader]: Use new format.
(embedded-installation-os): Use new format and adjust description.
(beaglebone-black-installation-os, a20-olinuxino-lime-installation-os,
a20-olinuxino-lime2-emmc-installation-os,
a20-olinuxino-micro-installation-os, bananapi-m2-ultra-installation-os,
firefly-rk3399-installation-os, mx6cuboxi-installation-os,
novena-installation-os, nintendo-nes-classic-edition-installation-os,
orangepi-r1-plus-lts-rk3328-installation-os, pine64-plus-installation-os,
pinebook-installation-os, rock64-installation-os,
rockpro64-installation-os, rk3399-puma-installation-os,
wandboard-installation-os): Don't guess block device.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
;; The <bootloader-configuration> record contains bootloader independent
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;; configuration used to fill bootloader configuration file.
|
|
|
|
|
|
gnu: bootloader: Update bootloader-configuration targets field.
* gnu/bootloader.scm (warn-update-targets): New procedure.
(bootloader-configuration)[targets]: Use warn-update-targets sanitizer.
* gnu/installer/parted.scm (bootloader-configuration): Use new target
field format.
* gnu/system/images/hurd.scm (hurd-barebones-os)[bootloader],
gnu/system/images/novena.scm (novena-barebones-os)[bootloader],
gnu/system/images/orangepi-r1-plus-lts-rk3328.scm
(orangepi-r1-plus-lts-rk3328-barebones-os)[bootloader],
gnu/system/images/pine64.scm (pine64-barebones-os)[bootloader],
gnu/system/images/pinebook-pro.scm
(pinebook-pro-barebones-os)[bootloader],
gnu/system/images/rock64.scm (rock64-barebones-os)[bootloader],
gnu/system/images/unmatched.scm (unmatched-barebones-os)[bootloader],
gnu/system/images/visionfive2.scm
(visionfive2-barebones-os)[bootloader]: Use new target format.
* gnu/system/install.scm (installation-os)[bootloader]: Use new format.
(embedded-installation-os): Use new format and adjust description.
(beaglebone-black-installation-os, a20-olinuxino-lime-installation-os,
a20-olinuxino-lime2-emmc-installation-os,
a20-olinuxino-micro-installation-os, bananapi-m2-ultra-installation-os,
firefly-rk3399-installation-os, mx6cuboxi-installation-os,
novena-installation-os, nintendo-nes-classic-edition-installation-os,
orangepi-r1-plus-lts-rk3328-installation-os, pine64-plus-installation-os,
pinebook-installation-os, rock64-installation-os,
rockpro64-installation-os, rk3399-puma-installation-os,
wandboard-installation-os): Don't guess block device.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
;; Based on report-duplicate-field-specifier from (guix records).
|
|
|
|
|
(define (report-duplicate-type-field targets)
|
|
|
|
|
"Report the first target with duplicate type among TARGETS."
|
|
|
|
|
(let loop ((targets targets)
|
|
|
|
|
(seen '()))
|
|
|
|
|
(match targets
|
|
|
|
|
((target rest ...)
|
|
|
|
|
(let ((type (bootloader-target-type target)))
|
|
|
|
|
(when (memq type seen)
|
|
|
|
|
(error loc (G_ "target with duplicate type~%") duplicate))
|
|
|
|
|
(loop rest (cons type seen))))
|
|
|
|
|
(() #t))))
|
|
|
|
|
|
|
|
|
|
(define-with-syntax-properties (warn-update-targets (value properties))
|
|
|
|
|
(let ((targets (wrap-element value))
|
|
|
|
|
(loc (source-properties->location properties)))
|
|
|
|
|
(define string->target
|
|
|
|
|
(match-lambda
|
|
|
|
|
((? bootloader-target? target) target)
|
|
|
|
|
((? string? s) (if (string-prefix? "/dev" s)
|
|
|
|
|
(if (string-match ".+p[0-9]+$" s)
|
|
|
|
|
(bootloader-target
|
|
|
|
|
(type 'part)
|
|
|
|
|
(device s))
|
|
|
|
|
(bootloader-target
|
|
|
|
|
(type 'disk)
|
|
|
|
|
(device s)))
|
|
|
|
|
(bootloader-target
|
|
|
|
|
(type 'esp)
|
|
|
|
|
(offset 'root)
|
|
|
|
|
(path s))))
|
|
|
|
|
(x (error loc (G_ "invalid target '~a'~%") x))))
|
|
|
|
|
|
|
|
|
|
;; XXX: Should this be an error?
|
|
|
|
|
(when (any string? targets)
|
|
|
|
|
(warning loc (G_ "the 'targets' field should now contain \
|
|
|
|
|
<bootloader-target> records, inferring a best guess, this might break!~%")))
|
|
|
|
|
(let* ((targets (map string->target targets)))
|
|
|
|
|
(report-duplicate-type-field targets)
|
|
|
|
|
targets)))
|
2021-08-30 08:22:35 -04:00
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(define-record-type* <bootloader-configuration>
|
|
|
|
|
bootloader-configuration make-bootloader-configuration
|
|
|
|
|
bootloader-configuration?
|
2022-08-29 16:24:24 -04:00
|
|
|
|
(bootloader
|
2024-08-06 20:11:17 -04:00
|
|
|
|
bootloader-configuration-bootloader) ;<bootloader>
|
gnu: bootloader: grub: Rewrite entirely.
* gnu/bootloader.scm (bootloader-configuration)[terminal-outputs,
terminal-inputs]: Don't assume grub.
[%bootloader-configuration-targets]: Rename to the below.
(bootloader-configuration-targets): Delete procedure.
* gnu/bootloader/grub.scm (normalize-file, bootloader-theme, image->png,
grub-background-image, grub-locale-directory, eye-candy,
keyboard-layout-file, grub-setup-io, grub-root-search,
make-grub-configuration, grub-configuration-file,
grub-efi-configuration-file, install-grub, install-grub-disk-image,
install-grub-efi, install-grub-efi-removable, install-grub-efi32,
make-grub-efi-netboot-installer, make-grub-efi-netboot-bootloader):
Remove procedures.
(grub-cfg, grub-mkrescue-bootloader): Remove variables.
(grub-efi-removable-bootloader, grub-efi32-bootloader,
grub-efi-netboot-bootloader, grub-efi-netboot-removable-bootloader):
Deprecate variables.
(grub-configuration): Remove macro.
(sanitize, search/target, search/menu-entry, when-list, grub-theme-png,
core.cfg->core.img, core.cfg, core.img, menu-entry->gexp, make-grub.cfg,
grub.cfg, grub.dir, install-grub.dir, install-grub-bios,
install-grub-efi, deprecated-installer): Add procedures.
(%grub-default-targets, %netboot-targets): Add variables.
(keyboard-layout-file): Return computed file.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): Delete
procedure.
* doc/guix.texi (system Configuration)[Bootloader Configuration]: Update
terminal-outputs and terminal-inputs to not be GRUB-specific.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
(targets bootloader-configuration-targets
|
gnu: bootloader: Update bootloader-configuration targets field.
* gnu/bootloader.scm (warn-update-targets): New procedure.
(bootloader-configuration)[targets]: Use warn-update-targets sanitizer.
* gnu/installer/parted.scm (bootloader-configuration): Use new target
field format.
* gnu/system/images/hurd.scm (hurd-barebones-os)[bootloader],
gnu/system/images/novena.scm (novena-barebones-os)[bootloader],
gnu/system/images/orangepi-r1-plus-lts-rk3328.scm
(orangepi-r1-plus-lts-rk3328-barebones-os)[bootloader],
gnu/system/images/pine64.scm (pine64-barebones-os)[bootloader],
gnu/system/images/pinebook-pro.scm
(pinebook-pro-barebones-os)[bootloader],
gnu/system/images/rock64.scm (rock64-barebones-os)[bootloader],
gnu/system/images/unmatched.scm (unmatched-barebones-os)[bootloader],
gnu/system/images/visionfive2.scm
(visionfive2-barebones-os)[bootloader]: Use new target format.
* gnu/system/install.scm (installation-os)[bootloader]: Use new format.
(embedded-installation-os): Use new format and adjust description.
(beaglebone-black-installation-os, a20-olinuxino-lime-installation-os,
a20-olinuxino-lime2-emmc-installation-os,
a20-olinuxino-micro-installation-os, bananapi-m2-ultra-installation-os,
firefly-rk3399-installation-os, mx6cuboxi-installation-os,
novena-installation-os, nintendo-nes-classic-edition-installation-os,
orangepi-r1-plus-lts-rk3328-installation-os, pine64-plus-installation-os,
pinebook-installation-os, rock64-installation-os,
rockpro64-installation-os, rk3399-puma-installation-os,
wandboard-installation-os): Don't guess block device.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
(default '()) ;list of strings
|
|
|
|
|
(sanitize warn-update-targets))
|
2022-08-29 16:24:24 -04:00
|
|
|
|
(menu-entries bootloader-configuration-menu-entries
|
|
|
|
|
(default '())) ;list of <menu-entry>
|
|
|
|
|
(default-entry bootloader-configuration-default-entry
|
|
|
|
|
(default 0)) ;integer
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(efi-removable? bootloader-configuration-efi-removable?
|
|
|
|
|
(default #f)) ;bool
|
|
|
|
|
(32bit? bootloader-configuration-32bit?
|
|
|
|
|
(default #f)) ;bool
|
2024-08-06 20:11:24 -04:00
|
|
|
|
(keypair bootloader-configuration-keypair
|
|
|
|
|
(default #f)) ;(cert . priv) pair
|
2022-08-29 16:24:24 -04:00
|
|
|
|
(timeout bootloader-configuration-timeout
|
|
|
|
|
(default 5)) ;seconds as integer
|
|
|
|
|
(keyboard-layout bootloader-configuration-keyboard-layout
|
|
|
|
|
(default #f)) ;<keyboard-layout> | #f
|
|
|
|
|
(theme bootloader-configuration-theme
|
|
|
|
|
(default #f)) ;bootloader-specific theme
|
|
|
|
|
(terminal-outputs bootloader-configuration-terminal-outputs
|
gnu: bootloader: grub: Rewrite entirely.
* gnu/bootloader.scm (bootloader-configuration)[terminal-outputs,
terminal-inputs]: Don't assume grub.
[%bootloader-configuration-targets]: Rename to the below.
(bootloader-configuration-targets): Delete procedure.
* gnu/bootloader/grub.scm (normalize-file, bootloader-theme, image->png,
grub-background-image, grub-locale-directory, eye-candy,
keyboard-layout-file, grub-setup-io, grub-root-search,
make-grub-configuration, grub-configuration-file,
grub-efi-configuration-file, install-grub, install-grub-disk-image,
install-grub-efi, install-grub-efi-removable, install-grub-efi32,
make-grub-efi-netboot-installer, make-grub-efi-netboot-bootloader):
Remove procedures.
(grub-cfg, grub-mkrescue-bootloader): Remove variables.
(grub-efi-removable-bootloader, grub-efi32-bootloader,
grub-efi-netboot-bootloader, grub-efi-netboot-removable-bootloader):
Deprecate variables.
(grub-configuration): Remove macro.
(sanitize, search/target, search/menu-entry, when-list, grub-theme-png,
core.cfg->core.img, core.cfg, core.img, menu-entry->gexp, make-grub.cfg,
grub.cfg, grub.dir, install-grub.dir, install-grub-bios,
install-grub-efi, deprecated-installer): Add procedures.
(%grub-default-targets, %netboot-targets): Add variables.
(keyboard-layout-file): Return computed file.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): Delete
procedure.
* doc/guix.texi (system Configuration)[Bootloader Configuration]: Update
terminal-outputs and terminal-inputs to not be GRUB-specific.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
(default #f)) ;list of symbols | #f (default outs)
|
2022-08-29 16:24:24 -04:00
|
|
|
|
(terminal-inputs bootloader-configuration-terminal-inputs
|
gnu: bootloader: grub: Rewrite entirely.
* gnu/bootloader.scm (bootloader-configuration)[terminal-outputs,
terminal-inputs]: Don't assume grub.
[%bootloader-configuration-targets]: Rename to the below.
(bootloader-configuration-targets): Delete procedure.
* gnu/bootloader/grub.scm (normalize-file, bootloader-theme, image->png,
grub-background-image, grub-locale-directory, eye-candy,
keyboard-layout-file, grub-setup-io, grub-root-search,
make-grub-configuration, grub-configuration-file,
grub-efi-configuration-file, install-grub, install-grub-disk-image,
install-grub-efi, install-grub-efi-removable, install-grub-efi32,
make-grub-efi-netboot-installer, make-grub-efi-netboot-bootloader):
Remove procedures.
(grub-cfg, grub-mkrescue-bootloader): Remove variables.
(grub-efi-removable-bootloader, grub-efi32-bootloader,
grub-efi-netboot-bootloader, grub-efi-netboot-removable-bootloader):
Deprecate variables.
(grub-configuration): Remove macro.
(sanitize, search/target, search/menu-entry, when-list, grub-theme-png,
core.cfg->core.img, core.cfg, core.img, menu-entry->gexp, make-grub.cfg,
grub.cfg, grub.dir, install-grub.dir, install-grub-bios,
install-grub-efi, deprecated-installer): Add procedures.
(%grub-default-targets, %netboot-targets): Add variables.
(keyboard-layout-file): Return computed file.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): Delete
procedure.
* doc/guix.texi (system Configuration)[Bootloader Configuration]: Update
terminal-outputs and terminal-inputs to not be GRUB-specific.
Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739
2024-08-06 20:11:17 -04:00
|
|
|
|
(default #f)) ;list of symbols | #f (default ins)
|
2022-08-29 16:24:24 -04:00
|
|
|
|
(serial-unit bootloader-configuration-serial-unit
|
|
|
|
|
(default #f)) ;integer | #f
|
|
|
|
|
(serial-speed bootloader-configuration-serial-speed
|
|
|
|
|
(default #f)) ;integer | #f
|
|
|
|
|
(device-tree-support? bootloader-configuration-device-tree-support?
|
2024-01-11 12:35:40 -05:00
|
|
|
|
(default #t)) ;boolean
|
|
|
|
|
(extra-initrd bootloader-configuration-extra-initrd
|
|
|
|
|
(default #f))) ;string | #f
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader installation paths.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (target-overrides . layers)
|
|
|
|
|
(let* ((types (flat-map (cute map bootloader-target-type <>) layers))
|
|
|
|
|
;; TODO: use loop instead of fold for early termination.
|
|
|
|
|
(pred (lambda (type layer found)
|
|
|
|
|
(or found (get-target-of-type type layer))))
|
|
|
|
|
(find (lambda (type) (fold (cute pred type <> <>) #f layers))))
|
|
|
|
|
(filter identity (map find (delete-duplicates types)))))
|
|
|
|
|
|
|
|
|
|
(define (normalize targets)
|
|
|
|
|
"Augments TARGETS with filesystem information at runtime, allowing
|
|
|
|
|
users to specify a lot less information. Puts TARGETS into a normal
|
|
|
|
|
form, where each path is fully specified up to a device offset."
|
|
|
|
|
(define (mass m)
|
|
|
|
|
`((,(mount-source m) . ,m)
|
|
|
|
|
(,(mount-point m) . ,m)))
|
|
|
|
|
|
|
|
|
|
(define (arborify target targets)
|
|
|
|
|
(let* ((up (lambda (t) (and t (parent-of t targets))))
|
|
|
|
|
(proto (unfold target-base? identity up (up target) list))
|
|
|
|
|
(chain (reverse (cons target proto))))
|
|
|
|
|
(bootloader-target
|
|
|
|
|
(inherit target)
|
|
|
|
|
(offset (and=> (car chain) bootloader-target-type))
|
|
|
|
|
(path (reduce pathcat #f (map bootloader-target-path (cdr chain)))))))
|
|
|
|
|
|
|
|
|
|
(let ((amounts (delay (apply append (map mass (mounts))))))
|
|
|
|
|
(define (assoc-mnt f)
|
|
|
|
|
(lambda (v) (and=> (assoc-ref (force amounts) v) f)))
|
|
|
|
|
|
|
|
|
|
(define (scrape target)
|
|
|
|
|
(match-record target <bootloader-target>
|
2024-10-01 16:09:30 -04:00
|
|
|
|
(expected? path offset device file-system)
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(if expected? target
|
|
|
|
|
(bootloader-target
|
|
|
|
|
(inherit target)
|
|
|
|
|
(device (or device
|
|
|
|
|
(and path ((assoc-mnt mount-source)
|
|
|
|
|
(unfold-pathcat target targets)))))
|
2024-10-01 16:09:30 -04:00
|
|
|
|
(file-system (or file-system
|
|
|
|
|
(match device
|
|
|
|
|
((? string?) ((assoc-mnt mount-type) device))
|
|
|
|
|
((? uuid?) (uuid->file-system device))
|
|
|
|
|
(_ #f))))
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(offset (and path offset))
|
|
|
|
|
(path (or path (and=> device (assoc-mnt mount-point))))))))
|
|
|
|
|
|
2024-10-01 16:09:30 -04:00
|
|
|
|
(let ((mid (map scrape targets)))
|
2024-08-06 20:11:17 -04:00
|
|
|
|
(map (cut arborify <> mid) mid))))
|
|
|
|
|
|
|
|
|
|
(define* (bootloader-configuration->gexp bootloader-config args #:key
|
|
|
|
|
(root-offset "/") (overrides '()))
|
|
|
|
|
"Returns a gexp to install BOOTLOADER-CONFIG to its targets, passing ARGS
|
|
|
|
|
to each installer alongside the additional #:bootloader-config keyword
|
|
|
|
|
arguments. Target OVERRIDES are applied and all path targets have ROOT-OFFSET
|
|
|
|
|
applied. The following keyword arguments are expected in ARGS:
|
|
|
|
|
@enumerate
|
|
|
|
|
@item current-boot-alternative
|
|
|
|
|
@item old-boot-alternatives
|
|
|
|
|
@item locale (from bootmeta)
|
|
|
|
|
@item store-directory-prefix (from bootmeta)
|
|
|
|
|
@item store-crypto-devices (from bootmeta)
|
|
|
|
|
@end enumerate"
|
|
|
|
|
(let* ((bootloader (bootloader-configuration-bootloader bootloader-config))
|
|
|
|
|
(installer (bootloader-installer bootloader))
|
|
|
|
|
(auto-targets (list (bootloader-target
|
|
|
|
|
(type 'root)
|
|
|
|
|
(path root-offset)
|
|
|
|
|
(offset #f))))
|
|
|
|
|
(targets (target-overrides
|
|
|
|
|
overrides
|
|
|
|
|
(bootloader-configuration-targets bootloader-config)
|
|
|
|
|
auto-targets
|
|
|
|
|
(bootloader-default-targets bootloader)))
|
|
|
|
|
(conf (bootloader-configuration
|
|
|
|
|
(inherit bootloader-config)
|
|
|
|
|
(targets (normalize targets)))))
|
|
|
|
|
(apply installer #:bootloader-config conf args)))
|
|
|
|
|
|
|
|
|
|
(define (bootloader-configurations->gexp bootloader-configs . rest)
|
|
|
|
|
(apply gbegin (filter-map (cut apply bootloader-configuration->gexp <> rest)
|
|
|
|
|
bootloader-configs)))
|
|
|
|
|
|
2024-09-15 13:16:24 -04:00
|
|
|
|
;; In lieu of exporting bootloader-configuration and menu-entry RTDs.
|
|
|
|
|
(define-syntax match-bootloader-configuration
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
"Bind each BOOTLOADER-CONFIGURATION field in FIELDS."
|
|
|
|
|
((_ bootloader-configuration (fields ...) body ...)
|
|
|
|
|
(match-record bootloader-configuration <bootloader-configuration>
|
|
|
|
|
(fields ...) body ...))))
|
|
|
|
|
|
|
|
|
|
(define-syntax match-menu-entry
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
"Bind each MENU-ENTRY field in FIELDS."
|
|
|
|
|
((_ menu-entry (fields ...) body ...)
|
|
|
|
|
(match-record menu-entry <menu-entry> (fields ...) body ...))))
|
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
2024-08-06 20:11:17 -04:00
|
|
|
|
;;; Bootloader installation to ESP.
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;;;
|
|
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
|
;; systems currently supported by efi-arch. should be used for packages relying
|
|
|
|
|
;; on it.
|
|
|
|
|
(define %efi-supported-systems
|
|
|
|
|
'("i686-linux" "x86_64-linux" "armhf-linux" "aarch64-linux" "riscv64-linux"))
|
|
|
|
|
|
|
|
|
|
(define* (efi-arch #:key (target (or (%current-target-system) (%current-system)))
|
|
|
|
|
(32? #f))
|
|
|
|
|
"Returns the UEFI architecture name for the current target, in lowercase."
|
|
|
|
|
(cond ((target-x86-32? target) "ia32")
|
|
|
|
|
((target-x86-64? target) (if 32? "ia32" "x64"))
|
|
|
|
|
((target-arm32? target) "arm")
|
|
|
|
|
((target-aarch64? target) (if 32? "arm" "aa64"))
|
|
|
|
|
((target-riscv64? target) (if 32? "riscv32" "riscv64"))
|
|
|
|
|
(else (raise (formatted-message (G_ "no UEFI standard arch for ~a!")
|
|
|
|
|
target)))))
|
|
|
|
|
|
|
|
|
|
(define (lazy-efibootmgr)
|
|
|
|
|
"Lazy-loaded efibootmgr package, in order to prevent circular refs."
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages linux)) 'efibootmgr))
|
|
|
|
|
|
|
|
|
|
(define (install-efi bootloader-config plan)
|
|
|
|
|
"Returns a gexp installing PLAN to the ESP, as denoted by the 'vendir target.
|
|
|
|
|
PLAN is a gexp of a list of '(BUILDER DEST-BASENAME . LABEL) triples, that
|
|
|
|
|
should be in boot order. If the user selects a removable bootloader, only the
|
|
|
|
|
first entry in PLAN is used."
|
|
|
|
|
(match-record bootloader-config <bootloader-configuration>
|
|
|
|
|
(targets efi-removable? 32bit?)
|
|
|
|
|
(if efi-removable?
|
|
|
|
|
;; Hard code the output location to a well-known path recognized by
|
|
|
|
|
;; compliant firmware. See "3.5.1.1 Removable Media Boot Behaviour":
|
|
|
|
|
;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_6.pdf
|
|
|
|
|
(with-targets targets
|
|
|
|
|
(('esp => (path :path))
|
|
|
|
|
#~(let ((boot #$(string-append path "/EFI/BOOT"))
|
|
|
|
|
(arch #$(string-upcase (efi-arch #:32? 32bit?)))
|
|
|
|
|
(builder (car (car #$plan))))
|
|
|
|
|
(mkdir-p boot)
|
|
|
|
|
;; Only realize the first planspec.
|
|
|
|
|
(builder (string-append boot "/BOOT" arch ".EFI")))))
|
|
|
|
|
;; Install normally if not configured as removable.
|
|
|
|
|
(with-targets targets
|
|
|
|
|
(('vendir => (vendir :path) (loader :devpath) (disk :device))
|
|
|
|
|
#~(install-efi #+(file-append (lazy-efibootmgr) "/sbin/efibootmgr")
|
|
|
|
|
#$vendir #$loader #$disk #$plan))))))
|