diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-03-17 22:37:53 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-03-24 23:06:11 +0100 |
commit | 8d058e7b1b1a409d3d9cc29c5650a98db4e78783 (patch) | |
tree | e7ee0ae62b4fa7a5c5f3d7b6335d5ac0e01c1a5f /gnu/bootloader | |
parent | db1e2522f6222594fc507ce7a7ba7b1c0ac5037d (diff) | |
download | patches-8d058e7b1b1a409d3d9cc29c5650a98db4e78783.tar patches-8d058e7b1b1a409d3d9cc29c5650a98db4e78783.tar.gz |
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.scm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 14aede72c5..e97a17b3e2 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -27,8 +27,10 @@ #:use-module (gnu bootloader) #:use-module (gnu system uuid) #:use-module (gnu system file-systems) + #:use-module (gnu system keyboard) #:autoload (gnu packages bootloaders) (grub) #:autoload (gnu packages gtk) (guile-cairo guile-rsvg) + #:autoload (gnu packages xorg) (xkeyboard-config) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (srfi srfi-1) @@ -219,6 +221,26 @@ fi~%" ;;; Configuration file. ;;; +(define* (keyboard-layout-file layout + #:key + (grub grub)) + "Process the X keyboard layout description LAYOUT, a <keyboard-layout> record, +and return a file in the format for GRUB keymaps. LAYOUT must be present in +the 'share/X11/xkb/symbols/' directory of 'xkeyboard-config'." + (define builder + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + ;; 'grub-kbdcomp' passes all its arguments but '-o' to 'ckbcomp' + ;; (from the 'console-setup' package). + (invoke #$(file-append grub "/bin/grub-mklayout") + "-i" #+(keyboard-layout->console-keymap layout) + "-o" #$output)))) + + (computed-file (string-append "grub-keymap." (keyboard-layout-name layout)) + builder)) + (define (grub-setup-io config) "Return GRUB commands to configure the input / output interfaces. The result is a string that can be inserted in grub.cfg." @@ -330,6 +352,18 @@ entries corresponding to old generations of the system." #:system system #:port #~port)) + (define keyboard-layout-config + (let ((layout (bootloader-configuration-keyboard-layout config)) + (grub (bootloader-package + (bootloader-configuration-bootloader config)))) + #~(let ((keymap #$(and layout + (keyboard-layout-file layout #:grub grub)))) + (when keymap + (format port "\ +terminal_input at_keyboard +insmod keylayouts +keymap ~a~%" keymap))))) + (define builder #~(call-with-output-file #$output (lambda (port) @@ -338,6 +372,7 @@ entries corresponding to old generations of the system." # will be lost upon reconfiguration. ") #$sugar + #$keyboard-layout-config (format port " set default=~a set timeout=~a~%" |