summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-08-28 23:27:20 +0200
committerLudovic Courtès <ludo@gnu.org>2019-08-30 01:33:45 +0200
commita28cfee841e9c5ab179291d3065f1486fd065e7e (patch)
tree539e7d4c15350a8a52eedfc12e10822c825f4cea /gnu
parent546a709f202024c8a5173ad372a87ddc1c284c63 (diff)
system: Add 'bootloader-menu-entries' field to <boot-parameters>.
This allows us to keep track of the extra menu entries specified in the OS configuration. * gnu/system.scm (<boot-parameters>)[bootloader-menu-entries]: New field. (read-boot-parameters): Initialize it. (operating-system-boot-parameters): Likewise. (operating-system-boot-parameters-file): Serialize it. * gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): New procedures.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/bootloader.scm34
-rw-r--r--gnu/system.scm15
2 files changed, 49 insertions, 0 deletions
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 909036042fd..01bdd4acaa9 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -2,6 +2,7 @@
2;;; Copyright © 2017 David Craven <david@craven.ch> 2;;; Copyright © 2017 David Craven <david@craven.ch>
3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
4;;; Copyright © 2017 Leo Famulari <leo@famulari.name> 4;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
5;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
5;;; 6;;;
6;;; This file is part of GNU Guix. 7;;; This file is part of GNU Guix.
7;;; 8;;;
@@ -23,6 +24,7 @@
23 #:use-module (guix records) 24 #:use-module (guix records)
24 #:use-module (guix ui) 25 #:use-module (guix ui)
25 #:use-module (srfi srfi-1) 26 #:use-module (srfi srfi-1)
27 #:use-module (ice-9 match)
26 #:export (menu-entry 28 #:export (menu-entry
27 menu-entry? 29 menu-entry?
28 menu-entry-label 30 menu-entry-label
@@ -32,6 +34,9 @@
32 menu-entry-initrd 34 menu-entry-initrd
33 menu-entry-device-mount-point 35 menu-entry-device-mount-point
34 36
37 menu-entry->sexp
38 sexp->menu-entry
39
35 bootloader 40 bootloader
36 bootloader? 41 bootloader?
37 bootloader-name 42 bootloader-name
@@ -76,6 +81,35 @@
76 (default '())) ; list of string-valued gexps 81 (default '())) ; list of string-valued gexps
77 (initrd menu-entry-initrd)) ; file name of the initrd as a gexp 82 (initrd menu-entry-initrd)) ; file name of the initrd as a gexp
78 83
84(define (menu-entry->sexp entry)
85 "Return ENTRY serialized as an sexp."
86 (match entry
87 (($ <menu-entry> label device mount-point linux linux-arguments initrd)
88 `(menu-entry (version 0)
89 (label ,label)
90 (device ,device)
91 (device-mount-point ,mount-point)
92 (linux ,linux)
93 (linux-arguments ,linux-arguments)
94 (initrd ,initrd)))))
95
96(define (sexp->menu-entry sexp)
97 "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
98record."
99 (match sexp
100 (('menu-entry ('version 0)
101 ('label label) ('device device)
102 ('device-mount-point mount-point)
103 ('linux linux) ('linux-arguments linux-arguments)
104 ('initrd initrd) _ ...)
105 (menu-entry
106 (label label)
107 (device device)
108 (device-mount-point mount-point)
109 (linux linux)
110 (linux-arguments linux-arguments)
111 (initrd initrd)))))
112
79 113
80;;; 114;;;
81;;; Bootloader record. 115;;; Bootloader record.
diff --git a/gnu/system.scm b/gnu/system.scm
index 01be1243fea..c860c22433f 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -116,6 +116,7 @@
116 boot-parameters-label 116 boot-parameters-label
117 boot-parameters-root-device 117 boot-parameters-root-device
118 boot-parameters-bootloader-name 118 boot-parameters-bootloader-name
119 boot-parameters-bootloader-menu-entries
119 boot-parameters-store-device 120 boot-parameters-store-device
120 boot-parameters-store-mount-point 121 boot-parameters-store-mount-point
121 boot-parameters-kernel 122 boot-parameters-kernel
@@ -251,6 +252,8 @@ directly by the user."
251 ;; OS's root file system, so it might be a device path like "/dev/sda3". 252 ;; OS's root file system, so it might be a device path like "/dev/sda3".
252 (root-device boot-parameters-root-device) 253 (root-device boot-parameters-root-device)
253 (bootloader-name boot-parameters-bootloader-name) 254 (bootloader-name boot-parameters-bootloader-name)
255 (bootloader-menu-entries ;list of <menu-entry>
256 boot-parameters-bootloader-menu-entries)
254 (store-device boot-parameters-store-device) 257 (store-device boot-parameters-store-device)
255 (store-mount-point boot-parameters-store-mount-point) 258 (store-mount-point boot-parameters-store-mount-point)
256 (kernel boot-parameters-kernel) 259 (kernel boot-parameters-kernel)
@@ -297,6 +300,11 @@ file system labels."
297 ((_ args) args) 300 ((_ args) args)
298 (#f 'grub))) ; for compatibility reasons. 301 (#f 'grub))) ; for compatibility reasons.
299 302
303 (bootloader-menu-entries
304 (match (assq 'bootloader-menu-entries rest)
305 ((_ entries) (map sexp->menu-entry entries))
306 (#f '())))
307
300 ;; In the past, we would store the directory name of the kernel instead 308 ;; In the past, we would store the directory name of the kernel instead
301 ;; of the absolute file name of its image. Detect that and correct it. 309 ;; of the absolute file name of its image. Detect that and correct it.
302 (kernel (if (string=? linux (direct-store-path linux)) 310 (kernel (if (string=? linux (direct-store-path linux))
@@ -1005,6 +1013,8 @@ such as '--root' and '--load' to <boot-parameters>."
1005 (operating-system-user-kernel-arguments os))) 1013 (operating-system-user-kernel-arguments os)))
1006 (initrd initrd) 1014 (initrd initrd)
1007 (bootloader-name bootloader-name) 1015 (bootloader-name bootloader-name)
1016 (bootloader-menu-entries
1017 (bootloader-configuration-menu-entries (operating-system-bootloader os)))
1008 (store-device (ensure-not-/dev (file-system-device store))) 1018 (store-device (ensure-not-/dev (file-system-device store)))
1009 (store-mount-point (file-system-mount-point store))))) 1019 (store-mount-point (file-system-mount-point store)))))
1010 1020
@@ -1046,6 +1056,11 @@ being stored into the \"parameters\" file)."
1046 #$(boot-parameters-kernel-arguments params)) 1056 #$(boot-parameters-kernel-arguments params))
1047 (initrd #$(boot-parameters-initrd params)) 1057 (initrd #$(boot-parameters-initrd params))
1048 (bootloader-name #$(boot-parameters-bootloader-name params)) 1058 (bootloader-name #$(boot-parameters-bootloader-name params))
1059 (bootloader-menu-entries
1060 #$(map menu-entry->sexp
1061 (or (and=> (operating-system-bootloader os)
1062 bootloader-configuration-menu-entries)
1063 '())))
1049 (store 1064 (store
1050 (device 1065 (device
1051 #$(device->sexp (boot-parameters-store-device params))) 1066 #$(device->sexp (boot-parameters-store-device params)))