summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-03-20 12:19:14 +0100
committerLudovic Courtès <ludo@gnu.org>2019-03-24 23:06:12 +0100
commitae7a316b9da0d1a50c5abdc531c68c8e98e561c9 (patch)
treec9d07ee413f3b9e2896931e4c49daf9acadf37fc /gnu
parent48e595b7a8f8f83ba00386e4dccf1ef809474226 (diff)
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.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/build/linux-boot.scm15
-rw-r--r--gnu/system.scm7
-rw-r--r--gnu/system/linux-initrd.scm26
3 files changed, 42 insertions, 6 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 44b35062847..a35d18ad7c2 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
@@ -437,6 +437,7 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
437(define* (boot-system #:key 437(define* (boot-system #:key
438 (linux-modules '()) 438 (linux-modules '())
439 linux-module-directory 439 linux-module-directory
440 keymap-file
440 qemu-guest-networking? 441 qemu-guest-networking?
441 volatile-root? 442 volatile-root?
442 pre-mount 443 pre-mount
@@ -444,7 +445,8 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
444 (on-error 'debug)) 445 (on-error 'debug))
445 "This procedure is meant to be called from an initrd. Boot a system by 446 "This procedure is meant to be called from an initrd. Boot a system by
446first loading LINUX-MODULES (a list of module names) from 447first loading LINUX-MODULES (a list of module names) from
447LINUX-MODULE-DIRECTORY, then setting up QEMU guest networking if 448LINUX-MODULE-DIRECTORY, then installing KEYMAP-FILE with 'loadkeys' (if
449KEYMAP-FILE is true), then setting up QEMU guest networking if
448QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems 450QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems
449specified in MOUNTS, and finally booting into the new root if any. The initrd 451specified in MOUNTS, and finally booting into the new root if any. The initrd
450supports kernel command-line options '--load', '--root', and '--repl'. 452supports kernel command-line options '--load', '--root', and '--repl'.
@@ -491,6 +493,15 @@ upon error."
491 #:lookup-module lookup-module) 493 #:lookup-module lookup-module)
492 (map lookup-module linux-modules)) 494 (map lookup-module linux-modules))
493 495
496 (when keymap-file
497 (let ((status (system* "loadkeys" keymap-file)))
498 (unless (zero? status)
499 ;; Emit a warning rather than abort when we cannot load
500 ;; KEYMAP-FILE.
501 (format (current-error-port)
502 "warning: 'loadkeys' exited with status ~a~%"
503 status))))
504
494 (when qemu-guest-networking? 505 (when qemu-guest-networking?
495 (unless (configure-qemu-networking) 506 (unless (configure-qemu-networking)
496 (display "network interface is DOWN\n"))) 507 (display "network interface is DOWN\n")))
diff --git a/gnu/system.scm b/gnu/system.scm
index 6bccdaa8c2d..035bbd82a11 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com> 4;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
5;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> 5;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
@@ -157,6 +157,8 @@
157 (default '())) ; list of gexps/strings 157 (default '())) ; list of gexps/strings
158 (bootloader operating-system-bootloader) ; <bootloader-configuration> 158 (bootloader operating-system-bootloader) ; <bootloader-configuration>
159 159
160 (keyboard-layout operating-system-keyboard-layout ;#f | <keyboard-layout>
161 (default #f))
160 (initrd operating-system-initrd ; (list fs) -> file-like 162 (initrd operating-system-initrd ; (list fs) -> file-like
161 (default base-initrd)) 163 (default base-initrd))
162 (initrd-modules operating-system-initrd-modules ; list of strings 164 (initrd-modules operating-system-initrd-modules ; list of strings
@@ -878,7 +880,8 @@ hardware-related operations as necessary when booting a Linux container."
878 #:linux (operating-system-kernel os) 880 #:linux (operating-system-kernel os)
879 #:linux-modules 881 #:linux-modules
880 (operating-system-initrd-modules os) 882 (operating-system-initrd-modules os)
881 #:mapped-devices mapped-devices)) 883 #:mapped-devices mapped-devices
884 #:keyboard-layout (operating-system-keyboard-layout os)))
882 885
883(define (locale-name->definition* name) 886(define (locale-name->definition* name)
884 "Variant of 'locale-name->definition' that raises an error upon failure." 887 "Variant of 'locale-name->definition' that raises an error upon failure."
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 983c6d81c86..656afd1ddb5 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2016 Mark H Weaver <mhw@netris.org> 3;;; Copyright © 2016 Mark H Weaver <mhw@netris.org>
4;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> 4;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -31,10 +31,13 @@
31 #:use-module (gnu packages disk) 31 #:use-module (gnu packages disk)
32 #:use-module (gnu packages linux) 32 #:use-module (gnu packages linux)
33 #:use-module (gnu packages guile) 33 #:use-module (gnu packages guile)
34 #:use-module ((gnu packages xorg)
35 #:select (console-setup xkeyboard-config))
34 #:use-module ((gnu packages make-bootstrap) 36 #:use-module ((gnu packages make-bootstrap)
35 #:select (%guile-static-stripped)) 37 #:select (%guile-static-stripped))
36 #:use-module (gnu system file-systems) 38 #:use-module (gnu system file-systems)
37 #:use-module (gnu system mapped-devices) 39 #:use-module (gnu system mapped-devices)
40 #:use-module (gnu system keyboard)
38 #:use-module (ice-9 match) 41 #:use-module (ice-9 match)
39 #:use-module (ice-9 regex) 42 #:use-module (ice-9 regex)
40 #:use-module (ice-9 vlist) 43 #:use-module (ice-9 vlist)
@@ -139,6 +142,7 @@ MODULES and taken from LINUX."
139 (linux linux-libre) 142 (linux linux-libre)
140 (linux-modules '()) 143 (linux-modules '())
141 (mapped-devices '()) 144 (mapped-devices '())
145 (keyboard-layout #f)
142 (helper-packages '()) 146 (helper-packages '())
143 qemu-networking? 147 qemu-networking?
144 volatile-root? 148 volatile-root?
@@ -152,6 +156,11 @@ mappings to realize before FILE-SYSTEMS are mounted.
152HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include 156HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include
153e2fsck/static or other packages needed by the initrd to check root partition. 157e2fsck/static or other packages needed by the initrd to check root partition.
154 158
159When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired
160console keyboard layout. This is done before MAPPED-DEVICES are set up and
161before FILE-SYSTEMS are mounted such that, should the user need to enter a
162passphrase or use the REPL, this happens using the intended keyboard layout.
163
155When QEMU-NETWORKING? is true, set up networking with the standard QEMU 164When QEMU-NETWORKING? is true, set up networking with the standard QEMU
156parameters. 165parameters.
157 166
@@ -206,6 +215,8 @@ upon error."
206 (and #$@device-mapping-commands)) 215 (and #$@device-mapping-commands))
207 #:linux-modules '#$linux-modules 216 #:linux-modules '#$linux-modules
208 #:linux-module-directory '#$kodir 217 #:linux-module-directory '#$kodir
218 #:keymap-file #+(and=> keyboard-layout
219 keyboard-layout->console-keymap)
209 #:qemu-guest-networking? #$qemu-networking? 220 #:qemu-guest-networking? #$qemu-networking?
210 #:volatile-root? '#$volatile-root? 221 #:volatile-root? '#$volatile-root?
211 #:on-error '#$on-error))) 222 #:on-error '#$on-error)))
@@ -290,6 +301,7 @@ FILE-SYSTEMS."
290 (linux linux-libre) 301 (linux linux-libre)
291 (linux-modules '()) 302 (linux-modules '())
292 (mapped-devices '()) 303 (mapped-devices '())
304 (keyboard-layout #f)
293 qemu-networking? 305 qemu-networking?
294 volatile-root? 306 volatile-root?
295 (extra-modules '()) ;deprecated 307 (extra-modules '()) ;deprecated
@@ -300,6 +312,11 @@ mounted by the initrd, possibly in addition to the root file system specified
300on the kernel command line via '--root'. MAPPED-DEVICES is a list of device 312on the kernel command line via '--root'. MAPPED-DEVICES is a list of device
301mappings to realize before FILE-SYSTEMS are mounted. 313mappings to realize before FILE-SYSTEMS are mounted.
302 314
315When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired
316console keyboard layout. This is done before MAPPED-DEVICES are set up and
317before FILE-SYSTEMS are mounted such that, should the user need to enter a
318passphrase or use the REPL, this happens using the intended keyboard layout.
319
303QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd. 320QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd.
304 321
305The initrd is automatically populated with all the kernel modules necessary 322The initrd is automatically populated with all the kernel modules necessary
@@ -316,13 +333,18 @@ loaded at boot time in the order in which they appear."
316 ,@extra-modules)) 333 ,@extra-modules))
317 334
318 (define helper-packages 335 (define helper-packages
319 (file-system-packages file-systems #:volatile-root? volatile-root?)) 336 (append (file-system-packages file-systems
337 #:volatile-root? volatile-root?)
338 (if keyboard-layout
339 (list loadkeys-static)
340 '())))
320 341
321 (raw-initrd file-systems 342 (raw-initrd file-systems
322 #:linux linux 343 #:linux linux
323 #:linux-modules linux-modules* 344 #:linux-modules linux-modules*
324 #:mapped-devices mapped-devices 345 #:mapped-devices mapped-devices
325 #:helper-packages helper-packages 346 #:helper-packages helper-packages
347 #:keyboard-layout keyboard-layout
326 #:qemu-networking? qemu-networking? 348 #:qemu-networking? qemu-networking?
327 #:volatile-root? volatile-root? 349 #:volatile-root? volatile-root?
328 #:on-error on-error)) 350 #:on-error on-error))