2017-05-15 16:24:18 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
|
;;; Copyright © 2017 David Craven <david@craven.ch>
|
2020-05-23 13:09:14 -04:00
|
|
|
|
;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
|
2019-08-28 17:27:20 -04:00
|
|
|
|
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
|
2020-05-26 10:54:18 -04:00
|
|
|
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
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)
|
|
|
|
|
#:use-module (guix discovery)
|
|
|
|
|
#:use-module (guix records)
|
|
|
|
|
#:use-module (guix ui)
|
|
|
|
|
#:use-module (srfi srfi-1)
|
2019-08-28 17:27:20 -04:00
|
|
|
|
#:use-module (ice-9 match)
|
2017-05-29 08:24:20 -04:00
|
|
|
|
#:export (menu-entry
|
|
|
|
|
menu-entry?
|
|
|
|
|
menu-entry-label
|
|
|
|
|
menu-entry-device
|
|
|
|
|
menu-entry-linux
|
|
|
|
|
menu-entry-linux-arguments
|
|
|
|
|
menu-entry-initrd
|
2017-06-29 06:42:59 -04:00
|
|
|
|
menu-entry-device-mount-point
|
2020-05-26 10:54:18 -04:00
|
|
|
|
menu-entry-multiboot-kernel
|
|
|
|
|
menu-entry-multiboot-arguments
|
|
|
|
|
menu-entry-multiboot-modules
|
2017-05-29 08:24:20 -04:00
|
|
|
|
|
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
|
|
|
|
|
bootloader-package
|
|
|
|
|
bootloader-installer
|
2020-05-23 13:09:14 -04:00
|
|
|
|
bootloader-disk-image-installer
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration-file
|
|
|
|
|
bootloader-configuration-file-generator
|
|
|
|
|
|
|
|
|
|
bootloader-configuration
|
|
|
|
|
bootloader-configuration?
|
|
|
|
|
bootloader-configuration-bootloader
|
2017-08-23 15:48:58 -04:00
|
|
|
|
bootloader-configuration-target
|
2017-05-15 16:24:18 -04:00
|
|
|
|
bootloader-configuration-menu-entries
|
|
|
|
|
bootloader-configuration-default-entry
|
|
|
|
|
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
|
|
|
|
|
bootloader-configuration-additional-configuration
|
|
|
|
|
|
|
|
|
|
%bootloaders
|
|
|
|
|
lookup-bootloader-by-name))
|
|
|
|
|
|
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))
|
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
|
|
|
|
|
(default '()))) ; list of multiboot commands, where
|
|
|
|
|
; a command is a list of <string>
|
2017-05-29 08:24:20 -04:00
|
|
|
|
|
2019-08-28 17:27:20 -04:00
|
|
|
|
(define (menu-entry->sexp entry)
|
|
|
|
|
"Return ENTRY serialized as an sexp."
|
|
|
|
|
(match entry
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(($ <menu-entry> label device mount-point linux linux-arguments initrd #f
|
|
|
|
|
())
|
2019-08-28 17:27:20 -04:00
|
|
|
|
`(menu-entry (version 0)
|
|
|
|
|
(label ,label)
|
|
|
|
|
(device ,device)
|
|
|
|
|
(device-mount-point ,mount-point)
|
|
|
|
|
(linux ,linux)
|
|
|
|
|
(linux-arguments ,linux-arguments)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(initrd ,initrd)))
|
|
|
|
|
(($ <menu-entry> label device mount-point #f () #f
|
|
|
|
|
multiboot-kernel multiboot-arguments multiboot-modules)
|
|
|
|
|
`(menu-entry (version 0)
|
|
|
|
|
(label ,label)
|
|
|
|
|
(device ,device)
|
|
|
|
|
(device-mount-point ,mount-point)
|
|
|
|
|
(multiboot-kernel ,multiboot-kernel)
|
|
|
|
|
(multiboot-arguments ,multiboot-arguments)
|
|
|
|
|
(multiboot-modules ,multiboot-modules)))))
|
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."
|
|
|
|
|
(match sexp
|
|
|
|
|
(('menu-entry ('version 0)
|
|
|
|
|
('label label) ('device device)
|
|
|
|
|
('device-mount-point mount-point)
|
|
|
|
|
('linux linux) ('linux-arguments linux-arguments)
|
|
|
|
|
('initrd initrd) _ ...)
|
|
|
|
|
(menu-entry
|
|
|
|
|
(label label)
|
|
|
|
|
(device device)
|
|
|
|
|
(device-mount-point mount-point)
|
|
|
|
|
(linux linux)
|
|
|
|
|
(linux-arguments linux-arguments)
|
2020-05-26 10:54:18 -04:00
|
|
|
|
(initrd initrd)))
|
|
|
|
|
(('menu-entry ('version 0)
|
|
|
|
|
('label label) ('device device)
|
|
|
|
|
('device-mount-point mount-point)
|
|
|
|
|
('multiboot-kernel multiboot-kernel)
|
|
|
|
|
('multiboot-arguments multiboot-arguments)
|
|
|
|
|
('multiboot-modules multiboot-modules) _ ...)
|
|
|
|
|
(menu-entry
|
|
|
|
|
(label label)
|
|
|
|
|
(device device)
|
|
|
|
|
(device-mount-point mount-point)
|
|
|
|
|
(multiboot-kernel multiboot-kernel)
|
|
|
|
|
(multiboot-arguments multiboot-arguments)
|
|
|
|
|
(multiboot-modules multiboot-modules)))))
|
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>
|
|
|
|
|
bootloader make-bootloader
|
|
|
|
|
bootloader?
|
|
|
|
|
(name bootloader-name)
|
|
|
|
|
(package bootloader-package)
|
|
|
|
|
(installer bootloader-installer)
|
2020-05-23 13:09:14 -04:00
|
|
|
|
(disk-image-installer bootloader-disk-image-installer
|
|
|
|
|
(default #f))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(configuration-file bootloader-configuration-file)
|
|
|
|
|
(configuration-file-generator bootloader-configuration-file-generator))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader configuration record.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
;; The <bootloader-configuration> record contains bootloader independant
|
|
|
|
|
;; configuration used to fill bootloader configuration file.
|
|
|
|
|
|
|
|
|
|
(define-record-type* <bootloader-configuration>
|
|
|
|
|
bootloader-configuration make-bootloader-configuration
|
|
|
|
|
bootloader-configuration?
|
2019-03-17 17:14:30 -04:00
|
|
|
|
(bootloader bootloader-configuration-bootloader) ;<bootloader>
|
|
|
|
|
(target bootloader-configuration-target ;string
|
|
|
|
|
(default #f))
|
2019-08-29 04:03:42 -04:00
|
|
|
|
(menu-entries bootloader-configuration-menu-entries ;list of <menu-entry>
|
2019-03-17 17:14:30 -04:00
|
|
|
|
(default '()))
|
|
|
|
|
(default-entry bootloader-configuration-default-entry ;integer
|
|
|
|
|
(default 0))
|
|
|
|
|
(timeout bootloader-configuration-timeout ;seconds as integer
|
|
|
|
|
(default 5))
|
2019-03-17 17:37:53 -04:00
|
|
|
|
(keyboard-layout bootloader-configuration-keyboard-layout ;<keyboard-layout> | #f
|
|
|
|
|
(default #f))
|
2019-03-17 17:14:30 -04:00
|
|
|
|
(theme bootloader-configuration-theme ;bootloader-specific theme
|
|
|
|
|
(default #f))
|
|
|
|
|
(terminal-outputs bootloader-configuration-terminal-outputs ;list of symbols
|
|
|
|
|
(default '(gfxterm)))
|
|
|
|
|
(terminal-inputs bootloader-configuration-terminal-inputs ;list of symbols
|
|
|
|
|
(default '()))
|
|
|
|
|
(serial-unit bootloader-configuration-serial-unit ;integer | #f
|
|
|
|
|
(default #f))
|
|
|
|
|
(serial-speed bootloader-configuration-serial-speed ;integer | #f
|
|
|
|
|
(default #f)))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloaders.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (bootloader-modules)
|
|
|
|
|
"Return the list of bootloader modules."
|
|
|
|
|
(all-modules (map (lambda (entry)
|
|
|
|
|
`(,entry . "gnu/bootloader"))
|
2018-03-26 17:42:59 -04:00
|
|
|
|
%load-path)
|
|
|
|
|
#:warn warn-about-load-error))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
(define %bootloaders
|
|
|
|
|
;; The list of publically-known bootloaders.
|
|
|
|
|
(delay (fold-module-public-variables (lambda (obj result)
|
|
|
|
|
(if (bootloader? obj)
|
|
|
|
|
(cons obj result)
|
|
|
|
|
result))
|
|
|
|
|
'()
|
|
|
|
|
(bootloader-modules))))
|
|
|
|
|
|
|
|
|
|
(define (lookup-bootloader-by-name name)
|
|
|
|
|
"Return the bootloader called NAME."
|
|
|
|
|
(or (find (lambda (bootloader)
|
|
|
|
|
(eq? name (bootloader-name bootloader)))
|
|
|
|
|
(force %bootloaders))
|
|
|
|
|
(leave (G_ "~a: no such bootloader~%") name)))
|