summaryrefslogtreecommitdiff
path: root/gnu/bootloader.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/bootloader.scm')
-rw-r--r--gnu/bootloader.scm127
1 files changed, 127 insertions, 0 deletions
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
new file mode 100644
index 00000000000..4e77974d315
--- /dev/null
+++ b/gnu/bootloader.scm
@@ -0,0 +1,127 @@
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 (bootloader
27 bootloader?
28 bootloader-name
29 bootloader-package
30 bootloader-installer
31 bootloader-configuration-file
32 bootloader-configuration-file-generator
33
34 bootloader-configuration
35 bootloader-configuration?
36 bootloader-configuration-bootloader
37 bootloader-configuration-device
38 bootloader-configuration-menu-entries
39 bootloader-configuration-default-entry
40 bootloader-configuration-timeout
41 bootloader-configuration-theme
42 bootloader-configuration-terminal-outputs
43 bootloader-configuration-terminal-inputs
44 bootloader-configuration-serial-unit
45 bootloader-configuration-serial-speed
46 bootloader-configuration-additional-configuration
47
48 %bootloaders
49 lookup-bootloader-by-name))
50
51
52;;;
53;;; Bootloader record.
54;;;
55
56;; The <bootloader> record contains fields expressing how the bootloader
57;; should be installed. Every bootloader in gnu/bootloader/ directory
58;; has to be described by this record.
59
60(define-record-type* <bootloader>
61 bootloader make-bootloader
62 bootloader?
63 (name bootloader-name)
64 (package bootloader-package)
65 (installer bootloader-installer)
66 (configuration-file bootloader-configuration-file)
67 (configuration-file-generator bootloader-configuration-file-generator))
68
69
70;;;
71;;; Bootloader configuration record.
72;;;
73
74;; The <bootloader-configuration> record contains bootloader independant
75;; configuration used to fill bootloader configuration file.
76
77(define-record-type* <bootloader-configuration>
78 bootloader-configuration make-bootloader-configuration
79 bootloader-configuration?
80 (bootloader bootloader-configuration-bootloader) ; <bootloader>
81 (device bootloader-configuration-device ; string
82 (default #f))
83 (menu-entries bootloader-configuration-menu-entries ; list of <boot-parameters>
84 (default '()))
85 (default-entry bootloader-configuration-default-entry ; integer
86 (default 0))
87 (timeout bootloader-configuration-timeout ; seconds as integer
88 (default 5))
89 (theme bootloader-configuration-theme ; bootloader-specific theme
90 (default #f))
91 (terminal-outputs bootloader-configuration-terminal-outputs ; list of symbols
92 (default '(gfxterm)))
93 (terminal-inputs bootloader-configuration-terminal-inputs ; list of symbols
94 (default '()))
95 (serial-unit bootloader-configuration-serial-unit ; integer | #f
96 (default #f))
97 (serial-speed bootloader-configuration-serial-speed ; integer | #f
98 (default #f))
99 (additional-configuration bootloader-configuration-additional-configuration ; record
100 (default #f)))
101
102
103;;;
104;;; Bootloaders.
105;;;
106
107(define (bootloader-modules)
108 "Return the list of bootloader modules."
109 (all-modules (map (lambda (entry)
110 `(,entry . "gnu/bootloader"))
111 %load-path)))
112
113(define %bootloaders
114 ;; The list of publically-known bootloaders.
115 (delay (fold-module-public-variables (lambda (obj result)
116 (if (bootloader? obj)
117 (cons obj result)
118 result))
119 '()
120 (bootloader-modules))))
121
122(define (lookup-bootloader-by-name name)
123 "Return the bootloader called NAME."
124 (or (find (lambda (bootloader)
125 (eq? name (bootloader-name bootloader)))
126 (force %bootloaders))
127 (leave (G_ "~a: no such bootloader~%") name)))