[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/14: bootloader: Add a 'keyboard-layout' field.
From: |
guix-commits |
Subject: |
05/14: bootloader: Add a 'keyboard-layout' field. |
Date: |
Sun, 24 Mar 2019 18:10:21 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 8d058e7b1b1a409d3d9cc29c5650a98db4e78783
Author: Ludovic Courtès <address@hidden>
Date: Sun Mar 17 22:37:53 2019 +0100
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 <address@hidden>
---
doc/guix.texi | 28 ++++++++++++++++++++++++++++
gnu/bootloader.scm | 3 +++
gnu/bootloader/grub.scm | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index a58ca4b..af74f7a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -23654,6 +23654,34 @@ current system.
The number of seconds to wait for keyboard input before booting. Set to
0 to boot immediately, and to -1 to wait indefinitely.
address@hidden keyboard layout, for the bootloader
address@hidden @code{keyboard-layout} (default: @code{#f})
+If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
+layout, usually address@hidden (``qwerty'').
+
+Otherwise, this must be a @code{keyboard-layout} object. For instance, the
+following example defines a standard German keyboard layout:
+
address@hidden
+(keyboard-layout "de")
address@hidden example
+
address@hidden
+while the example below designates the bépo layout for French:
+
address@hidden
+(keyboard-layout "fr" "bepo")
address@hidden example
+
+The layout name and variant must match an existing layout in the
address@hidden package under the @file{share/X11/xkb/symbols}
+directory.
+
address@hidden Note
+This option is currently ignored by bootloaders other than @code{grub} and
address@hidden
address@hidden quotation
+
@item @code{theme} (default: @var{#f})
The bootloader theme object describing the theme to use. If no theme
is provided, some bootloaders might use a default theme, that's true
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index e48bcc0..a381f67 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -47,6 +47,7 @@
bootloader-configuration-menu-entries
bootloader-configuration-default-entry
bootloader-configuration-timeout
+ bootloader-configuration-keyboard-layout
bootloader-configuration-theme
bootloader-configuration-terminal-outputs
bootloader-configuration-terminal-inputs
@@ -113,6 +114,8 @@
(default 0))
(timeout bootloader-configuration-timeout ;seconds as integer
(default 5))
+ (keyboard-layout bootloader-configuration-keyboard-layout
;<keyboard-layout> | #f
+ (default #f))
(theme bootloader-configuration-theme ;bootloader-specific theme
(default #f))
(terminal-outputs bootloader-configuration-terminal-outputs ;list of
symbols
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 14aede7..e97a17b 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~%"
- branch master updated (37f6289 -> fab9aa1), guix-commits, 2019/03/24
- 01/14: gnu: flatpak: Use glib-or-gtk-build-system., guix-commits, 2019/03/24
- 03/14: bootloader: Reindent record type definition., guix-commits, 2019/03/24
- 02/14: bootloader: Remove unused 'additional-configuration' field., guix-commits, 2019/03/24
- 06/14: services: xorg: Remove unused #:guile parameter., guix-commits, 2019/03/24
- 05/14: bootloader: Add a 'keyboard-layout' field.,
guix-commits <=
- 04/14: Add (gnu system keyboard)., guix-commits, 2019/03/24
- 10/14: vm: 'virtualized-operating-system' inherits from the user's bootloader config., guix-commits, 2019/03/24
- 09/14: services: xorg: Add a 'keyboard-layout' field in <xorg-configuration>., guix-commits, 2019/03/24
- 11/14: gnu: Add loadkeys-static., guix-commits, 2019/03/24
- 08/14: services: sddm, slim, gdm: Take an <xorg-configuration> record., guix-commits, 2019/03/24
- 14/14: gnu: Add xfce4-whiskermenu-plugin., guix-commits, 2019/03/24
- 13/14: doc: Document keyboard layout., guix-commits, 2019/03/24
- 07/14: services: xorg: Define an <xorg-configuration> record type., guix-commits, 2019/03/24
- 12/14: system: Initialize console keyboard layout in the initrd., guix-commits, 2019/03/24