1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 David Craven <david@craven.ch>
3 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
4 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu bootloader)
22 #:use-module (guix discovery)
23 #:use-module (guix records)
24 #:use-module (guix ui)
25 #:use-module (srfi srfi-1)
31 menu-entry-linux-arguments
39 bootloader-configuration-file
40 bootloader-configuration-file-generator
42 bootloader-configuration
43 bootloader-configuration?
44 bootloader-configuration-bootloader
45 bootloader-configuration-device
46 bootloader-configuration-menu-entries
47 bootloader-configuration-default-entry
48 bootloader-configuration-timeout
49 bootloader-configuration-theme
50 bootloader-configuration-terminal-outputs
51 bootloader-configuration-terminal-inputs
52 bootloader-configuration-serial-unit
53 bootloader-configuration-serial-speed
54 bootloader-configuration-additional-configuration
57 lookup-bootloader-by-name))
61 ;;; Menu-entry record.
64 (define-record-type* <menu-entry>
65 menu-entry make-menu-entry
67 (label menu-entry-label)
68 (device menu-entry-device ; file system uuid, label, or #f
70 (linux menu-entry-linux)
71 (linux-arguments menu-entry-linux-arguments
72 (default '())) ; list of string-valued gexps
73 (initrd menu-entry-initrd)) ; file name of the initrd as a gexp
77 ;;; Bootloader record.
80 ;; The <bootloader> record contains fields expressing how the bootloader
81 ;; should be installed. Every bootloader in gnu/bootloader/ directory
82 ;; has to be described by this record.
84 (define-record-type* <bootloader>
85 bootloader make-bootloader
87 (name bootloader-name)
88 (package bootloader-package)
89 (installer bootloader-installer)
90 (configuration-file bootloader-configuration-file)
91 (configuration-file-generator bootloader-configuration-file-generator))
95 ;;; Bootloader configuration record.
98 ;; The <bootloader-configuration> record contains bootloader independant
99 ;; configuration used to fill bootloader configuration file.
101 (define-record-type* <bootloader-configuration>
102 bootloader-configuration make-bootloader-configuration
103 bootloader-configuration?
104 (bootloader bootloader-configuration-bootloader) ; <bootloader>
105 (device bootloader-configuration-device ; string
107 (menu-entries bootloader-configuration-menu-entries ; list of <boot-parameters>
109 (default-entry bootloader-configuration-default-entry ; integer
111 (timeout bootloader-configuration-timeout ; seconds as integer
113 (theme bootloader-configuration-theme ; bootloader-specific theme
115 (terminal-outputs bootloader-configuration-terminal-outputs ; list of symbols
116 (default '(gfxterm)))
117 (terminal-inputs bootloader-configuration-terminal-inputs ; list of symbols
119 (serial-unit bootloader-configuration-serial-unit ; integer | #f
121 (serial-speed bootloader-configuration-serial-speed ; integer | #f
123 (additional-configuration bootloader-configuration-additional-configuration ; record
131 (define (bootloader-modules)
132 "Return the list of bootloader modules."
133 (all-modules (map (lambda (entry)
134 `(,entry . "gnu/bootloader"))
138 ;; The list of publically-known bootloaders.
139 (delay (fold-module-public-variables (lambda (obj result)
140 (if (bootloader? obj)
144 (bootloader-modules))))
146 (define (lookup-bootloader-by-name name)
147 "Return the bootloader called NAME."
148 (or (find (lambda (bootloader)
149 (eq? name (bootloader-name bootloader)))
150 (force %bootloaders))
151 (leave (G_ "~a: no such bootloader~%") name)))