summaryrefslogtreecommitdiff
path: root/gnu/bootloader
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-03-17 22:37:53 +0100
committerLudovic Courtès <ludo@gnu.org>2019-03-24 23:06:11 +0100
commit8d058e7b1b1a409d3d9cc29c5650a98db4e78783 (patch)
treee7ee0ae62b4fa7a5c5f3d7b6335d5ac0e01c1a5f /gnu/bootloader
parentdb1e2522f6222594fc507ce7a7ba7b1c0ac5037d (diff)
bootloader: Add a 'keyboard-layout' field.
* gnu/bootloader/grub.scm (keyboard-layout-file): New procedure. (grub-configuration-file)[keyboard-layout-file]: New variable. [builder]: Use it. * gnu/bootloader.scm (<bootloader-configuration>)[keyboard-layout]: New field. * doc/guix.texi (Bootloader Configuration): Document it. Co-authored-by: nee <nee-git@hidamari.blue>
Diffstat (limited to 'gnu/bootloader')
-rw-r--r--gnu/bootloader/grub.scm35
1 files changed, 35 insertions, 0 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 14aede72c5e..e97a17b3e20 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -27,8 +27,10 @@
27 #:use-module (gnu bootloader) 27 #:use-module (gnu bootloader)
28 #:use-module (gnu system uuid) 28 #:use-module (gnu system uuid)
29 #:use-module (gnu system file-systems) 29 #:use-module (gnu system file-systems)
30 #:use-module (gnu system keyboard)
30 #:autoload (gnu packages bootloaders) (grub) 31 #:autoload (gnu packages bootloaders) (grub)
31 #:autoload (gnu packages gtk) (guile-cairo guile-rsvg) 32 #:autoload (gnu packages gtk) (guile-cairo guile-rsvg)
33 #:autoload (gnu packages xorg) (xkeyboard-config)
32 #:use-module (ice-9 match) 34 #:use-module (ice-9 match)
33 #:use-module (ice-9 regex) 35 #:use-module (ice-9 regex)
34 #:use-module (srfi srfi-1) 36 #:use-module (srfi srfi-1)
@@ -219,6 +221,26 @@ fi~%"
219;;; Configuration file. 221;;; Configuration file.
220;;; 222;;;
221 223
224(define* (keyboard-layout-file layout
225 #:key
226 (grub grub))
227 "Process the X keyboard layout description LAYOUT, a <keyboard-layout> record,
228and return a file in the format for GRUB keymaps. LAYOUT must be present in
229the 'share/X11/xkb/symbols/' directory of 'xkeyboard-config'."
230 (define builder
231 (with-imported-modules '((guix build utils))
232 #~(begin
233 (use-modules (guix build utils))
234
235 ;; 'grub-kbdcomp' passes all its arguments but '-o' to 'ckbcomp'
236 ;; (from the 'console-setup' package).
237 (invoke #$(file-append grub "/bin/grub-mklayout")
238 "-i" #+(keyboard-layout->console-keymap layout)
239 "-o" #$output))))
240
241 (computed-file (string-append "grub-keymap." (keyboard-layout-name layout))
242 builder))
243
222(define (grub-setup-io config) 244(define (grub-setup-io config)
223 "Return GRUB commands to configure the input / output interfaces. The result 245 "Return GRUB commands to configure the input / output interfaces. The result
224is a string that can be inserted in grub.cfg." 246is a string that can be inserted in grub.cfg."
@@ -330,6 +352,18 @@ entries corresponding to old generations of the system."
330 #:system system 352 #:system system
331 #:port #~port)) 353 #:port #~port))
332 354
355 (define keyboard-layout-config
356 (let ((layout (bootloader-configuration-keyboard-layout config))
357 (grub (bootloader-package
358 (bootloader-configuration-bootloader config))))
359 #~(let ((keymap #$(and layout
360 (keyboard-layout-file layout #:grub grub))))
361 (when keymap
362 (format port "\
363terminal_input at_keyboard
364insmod keylayouts
365keymap ~a~%" keymap)))))
366
333 (define builder 367 (define builder
334 #~(call-with-output-file #$output 368 #~(call-with-output-file #$output
335 (lambda (port) 369 (lambda (port)
@@ -338,6 +372,7 @@ entries corresponding to old generations of the system."
338# will be lost upon reconfiguration. 372# will be lost upon reconfiguration.
339") 373")
340 #$sugar 374 #$sugar
375 #$keyboard-layout-config
341 (format port " 376 (format port "
342set default=~a 377set default=~a
343set timeout=~a~%" 378set timeout=~a~%"