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
33 menu-entry-device-mount-point
40 bootloader-configuration-file
41 bootloader-configuration-file-generator
43 bootloader-configuration
44 bootloader-configuration?
45 bootloader-configuration-bootloader
46 bootloader-configuration-target
47 bootloader-configuration-menu-entries
48 bootloader-configuration-default-entry
49 bootloader-configuration-timeout
50 bootloader-configuration-keyboard-layout
51 bootloader-configuration-theme
52 bootloader-configuration-terminal-outputs
53 bootloader-configuration-terminal-inputs
54 bootloader-configuration-serial-unit
55 bootloader-configuration-serial-speed
56 bootloader-configuration-additional-configuration
59 lookup-bootloader-by-name))
63 ;;; Menu-entry record.
66 (define-record-type* <menu-entry>
67 menu-entry make-menu-entry
69 (label menu-entry-label)
70 (device menu-entry-device ; file system uuid, label, or #f
72 (device-mount-point menu-entry-device-mount-point
74 (linux menu-entry-linux)
75 (linux-arguments menu-entry-linux-arguments
76 (default '())) ; list of string-valued gexps
77 (initrd menu-entry-initrd)) ; file name of the initrd as a gexp
81 ;;; Bootloader record.
84 ;; The <bootloader> record contains fields expressing how the bootloader
85 ;; should be installed. Every bootloader in gnu/bootloader/ directory
86 ;; has to be described by this record.
88 (define-record-type* <bootloader>
89 bootloader make-bootloader
91 (name bootloader-name)
92 (package bootloader-package)
93 (installer bootloader-installer)
94 (configuration-file bootloader-configuration-file)
95 (configuration-file-generator bootloader-configuration-file-generator))
99 ;;; Bootloader configuration record.
102 ;; The <bootloader-configuration> record contains bootloader independant
103 ;; configuration used to fill bootloader configuration file.
105 (define-record-type* <bootloader-configuration>
106 bootloader-configuration make-bootloader-configuration
107 bootloader-configuration?
108 (bootloader bootloader-configuration-bootloader) ;<bootloader>
109 (target bootloader-configuration-target ;string
111 (menu-entries bootloader-configuration-menu-entries ;list of <boot-parameters>
113 (default-entry bootloader-configuration-default-entry ;integer
115 (timeout bootloader-configuration-timeout ;seconds as integer
117 (keyboard-layout bootloader-configuration-keyboard-layout ;<keyboard-layout> | #f
119 (theme bootloader-configuration-theme ;bootloader-specific theme
121 (terminal-outputs bootloader-configuration-terminal-outputs ;list of symbols
122 (default '(gfxterm)))
123 (terminal-inputs bootloader-configuration-terminal-inputs ;list of symbols
125 (serial-unit bootloader-configuration-serial-unit ;integer | #f
127 (serial-speed bootloader-configuration-serial-speed ;integer | #f
135 (define (bootloader-modules)
136 "Return the list of bootloader modules."
137 (all-modules (map (lambda (entry)
138 `(,entry . "gnu/bootloader"))
140 #:warn warn-about-load-error))
143 ;; The list of publically-known bootloaders.
144 (delay (fold-module-public-variables (lambda (obj result)
145 (if (bootloader? obj)
149 (bootloader-modules))))
151 (define (lookup-bootloader-by-name name)
152 "Return the bootloader called NAME."
153 (or (find (lambda (bootloader)
154 (eq? name (bootloader-name bootloader)))
155 (force %bootloaders))
156 (leave (G_ "~a: no such bootloader~%") name)))