From patchwork Wed Mar 20 23:04:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1506 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BB1F616DB7; Wed, 20 Mar 2019 23:05:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 450E016DB5 for ; Wed, 20 Mar 2019 23:05:10 +0000 (GMT) Received: from localhost ([127.0.0.1]:56165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kGj-0007Qf-Se for patchwork@mira.cbaines.net; Wed, 20 Mar 2019 19:05:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kGh-0007P0-4d for guix-patches@gnu.org; Wed, 20 Mar 2019 19:05:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6kGf-0002gp-S3 for guix-patches@gnu.org; Wed, 20 Mar 2019 19:05:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38901) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6kGf-0002gX-K7 for guix-patches@gnu.org; Wed, 20 Mar 2019 19:05:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h6kGf-0005f3-BO for guix-patches@gnu.org; Wed, 20 Mar 2019 19:05:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2019 23:05:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34929@debbugs.gnu.org Received: via spool by 34929-submit@debbugs.gnu.org id=B34929.155312309921689 (code B ref 34929); Wed, 20 Mar 2019 23:05:05 +0000 Received: (at 34929) by debbugs.gnu.org; 20 Mar 2019 23:04:59 +0000 Received: from localhost ([127.0.0.1]:52432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGY-0005dX-MK for submit@debbugs.gnu.org; Wed, 20 Mar 2019 19:04:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGV-0005ca-Fq for 34929@debbugs.gnu.org; Wed, 20 Mar 2019 19:04:56 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kGP-0002Ny-MX; Wed, 20 Mar 2019 19:04:49 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57670 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h6kGP-0004wC-5o; Wed, 20 Mar 2019 19:04:49 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 21 Mar 2019 00:04:27 +0100 Message-Id: <20190320230435.25458-4-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320230435.25458-1-ludo@gnu.org> References: <20190320230435.25458-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nee Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/bootloader/grub.scm (keyboard-layout-file): New procedure. (grub-configuration-file)[keyboard-layout-file]: New variable. [builder]: Use it. * gnu/bootloader.scm ()[keyboard-layout]: New field. * doc/guix.texi (Bootloader Configuration): Document it. Co-authored-by: nee --- 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 63581bbe41..c687f78eac 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -23134,6 +23134,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. +@cindex keyboard layout, for the bootloader +@item @code{keyboard-layout} (default: @code{#f}) +If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard +layout, usually US@tie{}English (``qwerty''). + +Otherwise, this must be a @code{keyboard-layout} object. For instance, the +following example defines a standard German keyboard layout: + +@example +(keyboard-layout "de") +@end example + +@noindent +while the example below designates the bépo layout for French: + +@example +(keyboard-layout "fr" "bepo") +@end example + +The layout name and variant must match an existing layout in the +@code{xkeyboard-config} package under the @file{share/X11/xkb/symbols} +directory. + +@quotation Note +This option is currently ignored by bootloaders other than @code{grub} and +@code{grub-efi}. +@end 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 e48bcc073c..e7f7331dd8 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 ;string | #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 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 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~%"