gnu: giac-xcas: Update to 1.5.0-43.
[jackhill/guix/guix.git] / gnu / bootloader.scm
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>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
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.
12 ;;;
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.
17 ;;;
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/>.
20
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)
26 #:export (menu-entry
27 menu-entry?
28 menu-entry-label
29 menu-entry-device
30 menu-entry-linux
31 menu-entry-linux-arguments
32 menu-entry-initrd
33 menu-entry-device-mount-point
34
35 bootloader
36 bootloader?
37 bootloader-name
38 bootloader-package
39 bootloader-installer
40 bootloader-configuration-file
41 bootloader-configuration-file-generator
42
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-theme
51 bootloader-configuration-terminal-outputs
52 bootloader-configuration-terminal-inputs
53 bootloader-configuration-serial-unit
54 bootloader-configuration-serial-speed
55 bootloader-configuration-additional-configuration
56
57 %bootloaders
58 lookup-bootloader-by-name))
59
60 \f
61 ;;;
62 ;;; Menu-entry record.
63 ;;;
64
65 (define-record-type* <menu-entry>
66 menu-entry make-menu-entry
67 menu-entry?
68 (label menu-entry-label)
69 (device menu-entry-device ; file system uuid, label, or #f
70 (default #f))
71 (device-mount-point menu-entry-device-mount-point
72 (default #f))
73 (linux menu-entry-linux)
74 (linux-arguments menu-entry-linux-arguments
75 (default '())) ; list of string-valued gexps
76 (initrd menu-entry-initrd)) ; file name of the initrd as a gexp
77
78 \f
79 ;;;
80 ;;; Bootloader record.
81 ;;;
82
83 ;; The <bootloader> record contains fields expressing how the bootloader
84 ;; should be installed. Every bootloader in gnu/bootloader/ directory
85 ;; has to be described by this record.
86
87 (define-record-type* <bootloader>
88 bootloader make-bootloader
89 bootloader?
90 (name bootloader-name)
91 (package bootloader-package)
92 (installer bootloader-installer)
93 (configuration-file bootloader-configuration-file)
94 (configuration-file-generator bootloader-configuration-file-generator))
95
96 \f
97 ;;;
98 ;;; Bootloader configuration record.
99 ;;;
100
101 ;; The <bootloader-configuration> record contains bootloader independant
102 ;; configuration used to fill bootloader configuration file.
103
104 (define-record-type* <bootloader-configuration>
105 bootloader-configuration make-bootloader-configuration
106 bootloader-configuration?
107 (bootloader bootloader-configuration-bootloader) ; <bootloader>
108 (target bootloader-configuration-target ; string
109 (default #f))
110 (menu-entries bootloader-configuration-menu-entries ; list of <boot-parameters>
111 (default '()))
112 (default-entry bootloader-configuration-default-entry ; integer
113 (default 0))
114 (timeout bootloader-configuration-timeout ; seconds as integer
115 (default 5))
116 (theme bootloader-configuration-theme ; bootloader-specific theme
117 (default #f))
118 (terminal-outputs bootloader-configuration-terminal-outputs ; list of symbols
119 (default '(gfxterm)))
120 (terminal-inputs bootloader-configuration-terminal-inputs ; list of symbols
121 (default '()))
122 (serial-unit bootloader-configuration-serial-unit ; integer | #f
123 (default #f))
124 (serial-speed bootloader-configuration-serial-speed ; integer | #f
125 (default #f))
126 (additional-configuration bootloader-configuration-additional-configuration ; record
127 (default #f)))
128
129 \f
130 ;;;
131 ;;; Bootloaders.
132 ;;;
133
134 (define (bootloader-modules)
135 "Return the list of bootloader modules."
136 (all-modules (map (lambda (entry)
137 `(,entry . "gnu/bootloader"))
138 %load-path)
139 #:warn warn-about-load-error))
140
141 (define %bootloaders
142 ;; The list of publically-known bootloaders.
143 (delay (fold-module-public-variables (lambda (obj result)
144 (if (bootloader? obj)
145 (cons obj result)
146 result))
147 '()
148 (bootloader-modules))))
149
150 (define (lookup-bootloader-by-name name)
151 "Return the bootloader called NAME."
152 (or (find (lambda (bootloader)
153 (eq? name (bootloader-name bootloader)))
154 (force %bootloaders))
155 (leave (G_ "~a: no such bootloader~%") name)))