GNU bug report logs - #45680
[PATCH] Allow customised xkeyboard-config package in initrd

Previous Next

Package: guix-patches;

Reported by: Maxime Devos <maximedevos <at> telenet.be>

Date: Tue, 5 Jan 2021 21:38:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 45680 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#45680; Package guix-patches. (Tue, 05 Jan 2021 21:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxime Devos <maximedevos <at> telenet.be>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 05 Jan 2021 21:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: guix-patches <at> gnu.org
Subject: [PATCH] Allow customised xkeyboard-config package in initrd
Date: Tue, 05 Jan 2021 22:37:06 +0100
[Message part 1 (text/plain, inline)]
Hi Guix!

This patch *should* allow using a custom xkeyboard-config
package the initrd. (moesasji was interested in such a thing
on January the fourth on #guix)
‘make check’ doesn't give any error messages. However, I don't
have any custom xkeyboard-config package to test this with,
so I'll leave that to interested people.
-- 
Maxime Devos <maximedevos <at> telenet.be>
PGP Key: C1F3 3EE2 0C52 8FDB 7DD7  011F 49E3 EE22 1917 25EE
Freenode handle: mdevos
[0001-gnu-Allow-custom-xkeyboard-config-package-in-initrd.patch (text/x-patch, inline)]
From 85d509121b95d4da7048b045d41d57a2e71efc8f Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos <at> telenet.be>
Date: Tue, 5 Jan 2021 22:20:42 +0100
Subject: [PATCH] gnu: Allow custom xkeyboard-config package in initrd

* gnu/system/linux-initrd.scm (raw-initrd): New argument xkeyboard-config.
* gnu/system/linux-initrd.scm (base-initrd): Likewise.
* doc/contributing.texi (raw-initrd): Document new argument.
* doc/contributing.texi (base-initrd): Likewise.
---
 doc/guix.texi               | 13 ++++++++++---
 gnu/system/linux-initrd.scm | 17 +++++++++++++++--
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1081ed26a3..e410ccb141 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -86,6 +86,7 @@ Copyright @copyright{} 2020 raingloom@*
 Copyright @copyright{} 2020 Daniel Brooks@*
 Copyright @copyright{} 2020 John Soo@*
 Copyright @copyright{} 2020 Jonathan Brielmaier@*
+Copyright @copyright{} 2021 Maxime Devos@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -30631,7 +30632,7 @@ here is how to use it and customize it further.
 @cindex initial RAM disk
 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
        [#:linux-modules '()] [#:mapped-devices '()] @
-       [#:keyboard-layout #f] @
+       [#:keyboard-layout #f] [#:xkeyboard-config xkeyboard-config] @
        [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
 Return a derivation that builds a raw initrd.  @var{file-systems} is
 a list of file systems to be mounted by the initrd, possibly in addition to
@@ -30649,6 +30650,9 @@ are set up and before @var{file-systems} are mounted such that, should the
 user need to enter a passphrase or use the REPL, this happens using the
 intended keyboard layout.
 
+When @var{xkeyboard-config} is set, it is the @code{xkeyboard-config} package
+where @var{keyboard-layout} will be searched for.
+
 When @var{qemu-networking?} is true, set up networking with the standard QEMU
 parameters.  When @var{virtio?} is true, load additional modules so that the
 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
@@ -30659,8 +30663,8 @@ to it are lost.
 
 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
        [#:mapped-devices '()] [#:keyboard-layout #f] @
-       [#:qemu-networking? #f] [#:volatile-root? #f] @
-       [#:linux-modules '()]
+       [#:xkeyboard-config xkeyboard-config] [#:qemu-networking? #f] @
+       [#:volatile-root? #f] [#:linux-modules '()]
 Return as a file-like object a generic initrd, with kernel
 modules taken from @var{linux}.  @var{file-systems} is a list of file-systems to be
 mounted by the initrd, possibly in addition to the root file system specified
@@ -30673,6 +30677,9 @@ are set up and before @var{file-systems} are mounted such that, should the
 user need to enter a passphrase or use the REPL, this happens using the
 intended keyboard layout.
 
+When @var{xkeyboard-config} is set, it is the @code{xkeyboard-config} package
+where @var{keyboard-layout} will be searched for.
+
 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
 
 The initrd is automatically populated with all the kernel modules necessary
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index c6ba9bb560..64305e5fa6 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2021 Maxime Devos <maximedevos <at> telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -175,6 +176,7 @@ MODULES and taken from LINUX."
                       (mapped-devices '())
                       (keyboard-layout #f)
                       (helper-packages '())
+                      (xkeyboard-config xkeyboard-config)
                       qemu-networking?
                       volatile-root?
                       (on-error 'debug))
@@ -192,6 +194,9 @@ console keyboard layout.  This is done before MAPPED-DEVICES are set up and
 before FILE-SYSTEMS are mounted such that, should the user need to enter a
 passphrase or use the REPL, this happens using the intended keyboard layout.
 
+When XKEYBOARD-CONFIG is set, it is the xkeyboard-config package where
+the KEYBOARD-LAYOUT will be searched for.
+
 When QEMU-NETWORKING? is true, set up networking with the standard QEMU
 parameters.
 
@@ -213,6 +218,10 @@ upon error."
   (define kodir
     (flat-linux-module-directory linux linux-modules))
 
+  (define keymap-file
+    (and keyboard-layout
+         (keyboard-layout->console-keymap
+          keyboard-layout #:xkeyboard-config xkeyboard-config)))
   (expression->initrd
    (with-imported-modules (source-module-closure
                            '((gnu build linux-boot)
@@ -248,8 +257,7 @@ upon error."
                                       (and #$@device-mapping-commands))
                         #:linux-modules '#$linux-modules
                         #:linux-module-directory '#$kodir
-                        #:keymap-file #+(and=> keyboard-layout
-                                               keyboard-layout->console-keymap)
+                        #:keymap-file #+keymap-file
                         #:qemu-guest-networking? #$qemu-networking?
                         #:volatile-root? '#$volatile-root?
                         #:on-error '#$on-error))))
@@ -349,6 +357,7 @@ FILE-SYSTEMS."
                       (linux linux-libre)
                       (linux-modules '())
                       (mapped-devices '())
+                      (xkeyboard-config xkeyboard-config)
                       (keyboard-layout #f)
                       qemu-networking?
                       volatile-root?
@@ -365,6 +374,9 @@ console keyboard layout.  This is done before MAPPED-DEVICES are set up and
 before FILE-SYSTEMS are mounted such that, should the user need to enter a
 passphrase or use the REPL, this happens using the intended keyboard layout.
 
+When XKEYBOARD-CONFIG is set, it is the xkeyboard-config package where
+the KEYBOARD-LAYOUT will be searched for.
+
 QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd.
 
 The initrd is automatically populated with all the kernel modules necessary
@@ -392,6 +404,7 @@ loaded at boot time in the order in which they appear."
               #:linux-modules linux-modules*
               #:mapped-devices mapped-devices
               #:helper-packages helper-packages
+              #:xkeyboard-config xkeyboard-config
               #:keyboard-layout keyboard-layout
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
-- 
2.29.2

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#45680; Package guix-patches. (Tue, 05 Jan 2021 23:29:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: henkjan gersen <h.gersen <at> gmail.com>
To: maximedevos <at> telenet.be
Cc: guix-patches <at> gnu.org
Subject: [bug#45680] [PATCH] Allow customised xkeyboard-config package in
 initrd
Date: Tue, 5 Jan 2021 23:27:48 +0000
As I triggered this patch with my question on the chat....

Looking at the patch I don't think it does what is intended as the
keymaps defined in xkeyboard-config are in an xkb format and need to
be converted to the correct format to allow them to be loaded in an
initrd. For the console keymap layout ckbcomp is used in keyboard.scm
to do this conversion that is then loaded by loadkeys, which is a
pretty elegant approach. I actually don't know how the keymaps used in
an initrd are defined or whether it is even needed to add them as they
wouldn't help for the disk decryption password.

Note that my original question was how I could replace
xkeyboard-config for a patched version that has my own customized
keyboard layout included; this does mean that any patch that adds
keyboard layouts to initrd can be tested using the standard keyboard
layouts that are available in the "standard" xkeyboard-config. If it
works for existing layouts included it should also work for additional
keyboard layouts I add to my version of xkeyboard-config.




This bug report was last modified 3 years and 119 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.