From ae7a316b9da0d1a50c5abdc531c68c8e98e561c9 Mon Sep 17 00:00:00 2001
From: Ludovic Courtès <ludo@gnu.org>
Date: Wed, 20 Mar 2019 12:19:14 +0100
Subject: system: Initialize console keyboard layout in the initrd.

Partially fixes <https://bugs.gnu.org/25453>.

* gnu/system.scm (<operating-system>)[keyboard-layout]: New field.
(operating-system-initrd-file): Pass #:keyboard-layout to MAKE-INITRD.
* gnu/system/linux-initrd.scm (raw-initrd): Add #:keyboard-layout.
Pass #:keymap-file to 'boot-system'.
(base-initrd): Add #:keyboard-layout.
[helper-packages]: Add LOADKEYS-STATIC when KEYBOARD-LAYOUT is true.
Pass #:keyboard-layout to 'raw-initrd'.
* gnu/build/linux-boot.scm (boot-system): Add #:keymap-file and honor
it.
* doc/guix.texi (operating-system Reference): Document the
'keyboard-layout' field.
(Initial RAM Disk): Update 'raw-initrd' and 'base-initrd' documentation.
---
 gnu/build/linux-boot.scm | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

(limited to 'gnu/build')

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 44b3506284..a35d18ad7c 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -437,6 +437,7 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
 (define* (boot-system #:key
                       (linux-modules '())
                       linux-module-directory
+                      keymap-file
                       qemu-guest-networking?
                       volatile-root?
                       pre-mount
@@ -444,7 +445,8 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
                       (on-error 'debug))
   "This procedure is meant to be called from an initrd.  Boot a system by
 first loading LINUX-MODULES (a list of module names) from
-LINUX-MODULE-DIRECTORY, then setting up QEMU guest networking if
+LINUX-MODULE-DIRECTORY, then installing KEYMAP-FILE with 'loadkeys' (if
+KEYMAP-FILE is true), then setting up QEMU guest networking if
 QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems
 specified in MOUNTS, and finally booting into the new root if any.  The initrd
 supports kernel command-line options '--load', '--root', and '--repl'.
@@ -491,6 +493,15 @@ upon error."
                       #:lookup-module lookup-module)
                  (map lookup-module linux-modules))
 
+       (when keymap-file
+         (let ((status (system* "loadkeys" keymap-file)))
+           (unless (zero? status)
+             ;; Emit a warning rather than abort when we cannot load
+             ;; KEYMAP-FILE.
+             (format (current-error-port)
+                     "warning: 'loadkeys' exited with status ~a~%"
+                     status))))
+
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
            (display "network interface is DOWN\n")))
-- 
cgit v1.2.3