all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration
@ 2019-03-20 22:32 Ludovic Courtès
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
  2019-03-24 10:03 ` [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Julien Lepiller
  0 siblings, 2 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 22:32 UTC (permalink / raw)
  To: 34929

Hello Guix!

This patch series attempts to address a longstanding issue in Guix:
keyboard layout configuration.

The end result is that you can configure the layout for GRUB,
the Linux console, and Xorg using a single <keyboard-layout> record,
which directly corresponds to an XKB layout specification.

The three things still have to be configured separately.  Here’s an
example where GRUB, Linux, and Xorg use the same layout:

  (operating-system
    ;; ...
    (keyboard-layout (keyboard-layout "tr"))  ;for the console
    (bootloader (bootloader-configuration
                  (bootloader grub-efi-bootloader)
                  (target "/boot/efi")
                  (keyboard-layout keyboard-layout))) ;for GRUB
    (services (modify-services %desktop-services
                (slim-service-type config =>
                  (slim-configuration
                    (inherit config)
                    (xorg-configuration
                      (xorg-configuration             ;for Xorg
                        (keyboard-layout keyboard-layout))))))))

Clearly the Xorg bit is suboptimal.  I don’t see any obvious way
to simplify this part unfortunately because the <xorg-configuration>
record is aggregated by ‘slim-configuration’ & co. (there’s no Xorg
service that we could extend.)  That’s something we can still improve
afterwards, though.

Potentially controversial issues:

  1. The Xorg API is changed in an incompatible way:
     ‘xorg-start-command’ has a different prototype, the ‘startx’
     field of ‘slim-configuration’ is gone, etc.  If you were using
     these, your config will have to be adjusted to use the new
     ‘xorg-configuration’ record. (But hey, we’re still pre-1.0!).

  2. Since both fields and the record constructor are called
     ‘keyboard-layout’, you could easily have name clashes (it’s
     more of an aesthetic consideration, not a showstopper.)

After that we should probably change the installer to generate
the right incantations.

These patches fix <https://issues.guix.info/issue/25453> and
<https://issues.guix.info/issue/26234>.

Feedback welcome!

And thanks to nee for the initial inspiration!

Ludo’.

Ludovic Courtès (12):
  bootloader: Remove unused 'additional-configuration' field.
  bootloader: Reindent record type definition.
  Add (gnu system keyboard).
  bootloader: Add a 'keyboard-layout' field.
  services: xorg: Remove unused #:guile parameter.
  services: xorg: Define and <xorg-configuration> record type.
  services: sddm, slim, gdm: Take an <xorg-configuration> record.
  services: xorg: Add a 'keyboard-layout' field in <xorg-configuration>.
  vm: 'virtualized-operating-system' inherits from the user's bootloader
    config.
  gnu: Add loadkeys-static.
  system: Initialize console keyboard layout in the initrd.
  doc: Document keyboard layout.

 doc/guix.texi               | 305 ++++++++++++++++++++++++------------
 gnu.scm                     |   3 +-
 gnu/bootloader.scm          |  43 ++---
 gnu/bootloader/grub.scm     |  35 +++++
 gnu/build/linux-boot.scm    |  15 +-
 gnu/local.mk                |   1 +
 gnu/packages/linux.scm      |  37 +++++
 gnu/services/sddm.scm       |  14 +-
 gnu/services/xorg.scm       | 182 ++++++++++++---------
 gnu/system.scm              |   7 +-
 gnu/system/keyboard.scm     |  98 ++++++++++++
 gnu/system/linux-initrd.scm |  26 ++-
 gnu/system/vm.scm           |   1 +
 13 files changed, 561 insertions(+), 206 deletions(-)
 create mode 100644 gnu/system/keyboard.scm

-- 
2.21.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field.
  2019-03-20 22:32 [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Ludovic Courtès
@ 2019-03-20 23:04 ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition Ludovic Courtès
                     ` (10 more replies)
  2019-03-24 10:03 ` [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Julien Lepiller
  1 sibling, 11 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/bootloader.scm (<bootloader-configuration>)[additional-configuration]:
Remove.
---
 gnu/bootloader.scm | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index a32bf5ec67..5ae8ea3ee3 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -122,8 +122,6 @@
   (serial-unit                     bootloader-configuration-serial-unit      ; integer | #f
                                    (default #f))
   (serial-speed                    bootloader-configuration-serial-speed     ; integer | #f
-                                   (default #f))
-  (additional-configuration        bootloader-configuration-additional-configuration ; record
                                    (default #f)))
 
 \f
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 03/12] Add (gnu system keyboard) Ludovic Courtès
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/bootloader.scm (<bootloader-configuration>): Reindent.
---
 gnu/bootloader.scm | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 5ae8ea3ee3..e48bcc073c 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -104,25 +104,25 @@
 (define-record-type* <bootloader-configuration>
   bootloader-configuration make-bootloader-configuration
   bootloader-configuration?
-  (bootloader                      bootloader-configuration-bootloader)    ; <bootloader>
-  (target                          bootloader-configuration-target         ; string
-                                   (default #f))
-  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
-                                   (default '()))
-  (default-entry                   bootloader-configuration-default-entry  ; integer
-                                   (default 0))
-  (timeout                         bootloader-configuration-timeout        ; seconds as integer
-                                   (default 5))
-  (theme                           bootloader-configuration-theme          ; bootloader-specific theme
-                                   (default #f))
-  (terminal-outputs                bootloader-configuration-terminal-outputs ; list of symbols
-                                   (default '(gfxterm)))
-  (terminal-inputs                 bootloader-configuration-terminal-inputs  ; list of symbols
-                                   (default '()))
-  (serial-unit                     bootloader-configuration-serial-unit      ; integer | #f
-                                   (default #f))
-  (serial-speed                    bootloader-configuration-serial-speed     ; integer | #f
-                                   (default #f)))
+  (bootloader         bootloader-configuration-bootloader) ;<bootloader>
+  (target             bootloader-configuration-target      ;string
+                      (default #f))
+  (menu-entries       bootloader-configuration-menu-entries ;list of <boot-parameters>
+                      (default '()))
+  (default-entry      bootloader-configuration-default-entry ;integer
+                      (default 0))
+  (timeout            bootloader-configuration-timeout ;seconds as integer
+                      (default 5))
+  (theme              bootloader-configuration-theme ;bootloader-specific theme
+                      (default #f))
+  (terminal-outputs   bootloader-configuration-terminal-outputs ;list of symbols
+                      (default '(gfxterm)))
+  (terminal-inputs    bootloader-configuration-terminal-inputs ;list of symbols
+                      (default '()))
+  (serial-unit        bootloader-configuration-serial-unit ;integer | #f
+                      (default #f))
+  (serial-speed       bootloader-configuration-serial-speed ;integer | #f
+                      (default #f)))
 
 \f
 ;;;
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 03/12] Add (gnu system keyboard).
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field Ludovic Courtès
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/system/keyboard.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu.scm (%public-modules): Add it.
---
 gnu.scm                 |  3 +-
 gnu/local.mk            |  1 +
 gnu/system/keyboard.scm | 98 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+), 1 deletion(-)
 create mode 100644 gnu/system/keyboard.scm

diff --git a/gnu.scm b/gnu.scm
index 3e7e7c0ebc..2c29b6dc3f 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
@@ -45,6 +45,7 @@
         (gnu system file-systems)
         (gnu bootloader)
         (gnu bootloader grub)
+        (gnu system keyboard)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/local.mk b/gnu/local.mk
index af2bf87273..b1ad9c9d8b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -536,6 +536,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/system/accounts.scm			\
   %D%/system/file-systems.scm			\
   %D%/system/install.scm			\
+  %D%/system/keyboard.scm			\
   %D%/system/linux-container.scm		\
   %D%/system/linux-initrd.scm			\
   %D%/system/locale.scm				\
diff --git a/gnu/system/keyboard.scm b/gnu/system/keyboard.scm
new file mode 100644
index 0000000000..cd3ab37b27
--- /dev/null
+++ b/gnu/system/keyboard.scm
@@ -0,0 +1,98 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu system keyboard)
+  #:use-module (guix gexp)
+  #:use-module ((gnu packages xorg)
+                #:select (xkeyboard-config console-setup))
+  #:use-module (srfi srfi-9 gnu)
+  #:use-module (ice-9 match)
+  #:export (keyboard-layout?
+            keyboard-layout
+            keyboard-layout-name
+            keyboard-layout-variant
+            keyboard-layout-model
+            keyboard-layout-options
+
+            keyboard-layout->console-keymap))
+
+;;; Commentary:
+;;;
+;;; This module provides a data structure to represent keyboard layouts
+;;; according to the XKB naming and classification (see the 'xkeyboard-config'
+;;; package).
+;;;
+;;; Code:
+
+(define-immutable-record-type <keyboard-layout>
+  (%keyboard-layout name variant model options)
+  keyboard-layout?
+  (name      keyboard-layout-name)                ;string
+  (variant   keyboard-layout-variant)             ;#f | string
+  (model     keyboard-layout-model)               ;#f | string
+  (options   keyboard-layout-options))            ;list of strings
+
+(define* (keyboard-layout name #:optional variant
+                          #:key model (options '()))
+  "Return a new keyboard layout with the given NAME and VARIANT.
+
+NAME must be a string such as \"fr\"; VARIANT must be a string such as
+\"bepo\" or \"nodeadkeys\".  See the 'xkeyboard-config' package for valid
+options."
+  (%keyboard-layout name variant model options))
+
+(define* (keyboard-layout->console-keymap layout
+                                          #:key
+                                          (xkeyboard-config xkeyboard-config))
+  "Return a Linux console keymap file for LAYOUT, a <keyboard-layout> record.
+Layout information is taken from the XKEYBOARD-CONFIG package."
+  (define build
+    (with-imported-modules '((guix build utils))
+      #~(begin
+          (use-modules (guix build utils)
+                       (ice-9 popen)
+                       (ice-9 match))
+
+          (define pipe
+            (open-pipe* OPEN_READ
+                        #+(file-append console-setup "/bin/ckbcomp")
+                        (string-append "-I"
+                                       #+(file-append xkeyboard-config
+                                                      "/share/X11/xkb"))
+                        "-rules" "base"
+                        #$@(match (keyboard-layout-model layout)
+                             (#f      '())
+                             (model   `("-model" ,model)))
+                        #$(keyboard-layout-name layout)
+                        #$(or (keyboard-layout-variant layout)
+                              "")
+                        #$(string-join (keyboard-layout-options layout) ",")))
+
+          (call-with-output-file #$output
+            (lambda (output)
+              (dump-port pipe output)))
+
+          ;; Note: ckbcomp errors out when the layout name is unknown, but
+          ;; merely emits a warning when the variant is unknown.
+          (unless (zero? (close-pipe pipe))
+            (error "failed to create console keymap for keyboard layout"
+                   #$(keyboard-layout-name layout))))))
+
+  (computed-file (string-append "console-keymap."
+                                (keyboard-layout-name layout))
+                 build))
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 03/12] Add (gnu system keyboard) Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-24  9:31     ` Julien Lepiller
  2019-03-20 23:04   ` [bug#34929] [PATCH 05/12] services: xorg: Remove unused #:guile parameter Ludovic Courtès
                     ` (7 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929; +Cc: nee

* 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 <nee-git@hidamari.blue>
---
 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 <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~%"
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 05/12] services: xorg: Remove unused #:guile parameter.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (2 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type Ludovic Courtès
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/services/xorg.scm (xorg-wrapper): Remove #:guile, which was unused.
(xorg-start-command): Likewise.
(xinitrc): Likewise.
---
 doc/guix.texi         | 2 +-
 gnu/services/xorg.scm | 9 ++-------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index c687f78eac..622740b11c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13310,7 +13310,7 @@ type @code{<sddm-configuration>}.
 @end example
 @end deffn
 
-@deffn {Scheme Procedure} xorg-start-command [#:guile] @
+@deffn {Scheme Procedure} xorg-start-command @
   [#:modules %default-xorg-modules] @
   [#:fonts %default-xorg-fonts] @
   [#:configuration-file (xorg-configuration-file @dots{})] @
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index f2a3c28c90..8381a7ed04 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -261,7 +261,6 @@ in @var{modules}."
                        #t))))
 
 (define* (xorg-wrapper #:key
-                       (guile (canonical-package guile-2.0))
                        (modules %default-xorg-modules)
                        (configuration-file (xorg-configuration-file
                                             #:modules modules))
@@ -287,7 +286,6 @@ in place of @code{/usr/bin/X}."
   (program-file "X-wrapper" exp))
 
 (define* (xorg-start-command #:key
-                             (guile (canonical-package guile-2.0))
                              (modules %default-xorg-modules)
                              (fonts %default-xorg-fonts)
                              (configuration-file
@@ -300,8 +298,7 @@ packages, and @var{fonts}, a list of X font directories, are available.  See
 @code{xorg-wrapper} for more details on the arguments.  The result should be
 used in place of @code{startx}."
   (define X
-    (xorg-wrapper #:guile guile
-                  #:configuration-file configuration-file
+    (xorg-wrapper #:configuration-file configuration-file
                   #:modules modules
                   #:xorg-server xorg-server))
   (define exp
@@ -312,9 +309,7 @@ used in place of @code{startx}."
 
   (program-file "startx" exp))
 
-(define* (xinitrc #:key
-                  (guile (canonical-package guile-2.0))
-                  fallback-session)
+(define* (xinitrc #:key fallback-session)
   "Return a system-wide xinitrc script that starts the specified X session,
 which should be passed to this script as the first argument.  If not, the
 @var{fallback-session} will be used or, if @var{fallback-session} is false, a
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (3 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 05/12] services: xorg: Remove unused #:guile parameter Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-24  9:46     ` Julien Lepiller
  2019-03-20 23:04   ` [bug#34929] [PATCH 07/12] services: sddm, slim, gdm: Take an <xorg-configuration> record Ludovic Courtès
                     ` (5 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/services/xorg.scm (<xorg-configuration>): New record type.
(xorg-configuration-file): Remove.
(xorg-wrapper): Remove #:modules, #:configuration-file, and
 #:xorg-server; add optional 'config' parameter instead.  Adjust
accordingly.
(xorg-start-command): Likewise.
* doc/guix.texi (X Window): Document 'xorg-configuration'.  Update
'xorg-start-command' documentation.  Remove 'xorg-configuration-file'
documentation.
---
 doc/guix.texi         | 134 ++++++++++++++----------------------------
 gnu/services/xorg.scm | 115 ++++++++++++++++++------------------
 2 files changed, 101 insertions(+), 148 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 622740b11c..2363874cf9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13310,99 +13310,53 @@ type @code{<sddm-configuration>}.
 @end example
 @end deffn
 
-@deffn {Scheme Procedure} xorg-start-command @
-  [#:modules %default-xorg-modules] @
-  [#:fonts %default-xorg-fonts] @
-  [#:configuration-file (xorg-configuration-file @dots{})] @
-  [#:xorg-server @var{xorg-server}]
-  [#:xserver-arguments '("-nolisten" "tcp")]
-Return a @code{startx} script in which @var{modules}, a list of X module
-packages, and @var{fonts}, a list of X font directories, are available.  See
-@code{xorg-wrapper} for more details on the arguments.  The result should be
-used in place of @code{startx}.
-
-Usually the X server is started by a login manager.
-@end deffn
-
-@cindex @code{-listen tcp}, for X11.
-This procedure is useful to override command line options for the X server,
-such as having it listen to over TCP:
-
-@example
-(operating-system
-  ...
-  (services
-    (modify-services %desktop-services
-      (slim-service-type config =>
-        (slim-configuration
-          (inherit config)
-          (startx (xorg-start-command
-                   #:xserver-arguments '("-listen" "tcp"))))))))
-@end example
-
-@deffn {Scheme Procedure} xorg-configuration-file @
-  [#:modules %default-xorg-modules] @
-  [#:fonts %default-xorg-fonts] @
-  [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
-Return a configuration file for the Xorg server containing search paths for
-all the common drivers.
-
-@var{modules} must be a list of @dfn{module packages} loaded by the Xorg
+@cindex Xorg, configuration
+@deftp {Data Type} xorg-configuration
+This data type represents the configuration of the Xorg graphical display
+server.  Note that there is not Xorg service; instead, the X server is started
+by a ``display manager'' such as GDM, SDDM, and SLiM.  Thus, the configuration
+of these display managers aggregates an @code{xorg-configuration} record.
+
+@table @asis
+@item @code{modules} (default: @code{%default-xorg-modules})
+This is a list of @dfn{module packages} loaded by the Xorg
 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
-@var{fonts} must be a list of font directories to add to the server's
-@dfn{font path}.
-
-@var{drivers} must be either the empty list, in which case Xorg chooses a
-graphics driver automatically, or a list of driver names that will be tried in
-this order---e.g., @code{("modesetting" "vesa")}.
-
-Likewise, when @var{resolutions} is the empty list, Xorg chooses an
-appropriate screen resolution; otherwise, it must be a list of
-resolutions---e.g., @code{((1024 768) (640 480))}.
-
-Last, @var{extra-config} is a list of strings or objects appended to the
-configuration file.  It is used to pass extra text to be
-added verbatim to the configuration file.
-
-@cindex keymap
-@cindex keyboard layout
-This procedure is especially useful to configure a different keyboard layout
-than the default US keymap.  For instance, to use the ``bépo'' keymap by
-default on the display manager:
-
-@example
-(define bepo-evdev
-  "Section \"InputClass\"
-        Identifier \"evdev keyboard catchall\"
-        Driver \"evdev\"
-        MatchIsKeyboard \"on\"
-        Option \"xkb_layout\" \"fr\"
-        Option \"xkb_variant\" \"bepo\"
-EndSection")
-
-(operating-system
-  ...
-  (services
-    (modify-services %desktop-services
-      (slim-service-type config =>
-        (slim-configuration
-          (inherit config)
-          (startx (xorg-start-command
-                   #:configuration-file
-                   (xorg-configuration-file
-                     #:extra-config
-                     (list bepo-evdev)))))))))
-@end example
-
-The @code{MatchIsKeyboard} line specifies that we only apply the configuration
-to keyboards.  Without this line, other devices such as touchpad may not work
-correctly because they will be attached to the wrong driver.  In this example,
-the user typically used @code{setxkbmap fr bepo} to set their favorite keymap
-once logged in.  The first argument corresponds to the layout, while the second
-argument corresponds to the variant.  The @code{xkb_variant} line can be omitted
-to select the default variant.
+
+@item @code{fonts} (default: @code{%default-xorg-fonts})
+This is a list of font directories to add to the server's @dfn{font path}.
+
+@item @code{drivers} (default: @code{'()})
+This must be either the empty list, in which case Xorg chooses a graphics
+driver automatically, or a list of driver names that will be tried in this
+order---e.g., @code{("modesetting" "vesa")}.
+
+@item @code{resolutions} (default: @code{'()})
+When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
+resolution.  Otherwise, it must be a list of resolutions---e.g., @code{((1024
+768) (640 480))}.
+
+@item @code{extra-config} (default: @code{'()})
+This is a list of strings or objects appended to the configuration file.  It
+is used to pass extra text to be added verbatim to the configuration file.
+
+@item @code{server} (default: @code{xorg-server})
+This is the package providing the Xorg server.
+
+@item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
+This is the list of command-line arguments to pass to the X server.  The
+default is @code{-nolisten tcp}.
+@end table
+@end deftp
+
+@deffn {Scheme Procedure} xorg-start-command [@var{config}]
+Return a @code{startx} script in which the modules, fonts, etc. specified
+in @var{config}, are available.  The result should be used in place of
+@code{startx}.
+
+Usually the X server is started by a login manager.
 @end deffn
 
+
 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
 Add @var{package}, a package for a screen locker or screen saver whose
 command is @var{program}, to the set of setuid programs and add a PAM entry
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 8381a7ed04..3c547c1303 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -48,7 +48,16 @@
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (xorg-configuration-file
+  #:export (xorg-configuration
+            xorg-configuration?
+            xorg-configuration-modules
+            xorg-configuration-fonts
+            xorg-configuration-drivers
+            xorg-configuration-resolutions
+            xorg-configuration-extra-config
+            xorg-configuration-server
+            xorg-configuration-server-arguments
+
             %default-xorg-modules
             %default-xorg-fonts
             xorg-wrapper
@@ -122,33 +131,36 @@
                      "/share/fonts/X11/misc")
         (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
 
-(define* (xorg-configuration-file #:key
-                                  (modules %default-xorg-modules)
-                                  (fonts %default-xorg-fonts)
-                                  (drivers '()) (resolutions '())
-                                  (extra-config '()))
-  "Return a configuration file for the Xorg server containing search paths for
-all the common drivers.
+(define %default-xorg-server-arguments
+  ;; Default command-line arguments for X.
+  '("-nolisten" "tcp"))
 
-@var{modules} must be a list of @dfn{module packages} loaded by the Xorg
-server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
-@var{fonts} must be a list of font directories to add to the server's
-@dfn{font path}.
+;; Configuration of an Xorg server.
+(define-record-type* <xorg-configuration>
+  xorg-configuration make-xorg-configuration
+  xorg-configuration?
+  (modules          xorg-configuration-modules    ;list of packages
+                    (default %default-xorg-modules))
+  (fonts            xorg-configuration-fonts      ;list of packges
+                    (default %default-xorg-fonts))
+  (drivers          xorg-configuration-drivers    ;list of strings
+                    (default '()))
+  (resolutions      xorg-configuration-resolutions ;list of tuples
+                    (default '()))
+  (extra-config     xorg-configuration-extra-config ;list of strings
+                    (default '()))
+  (server           xorg-configuration-server     ;package
+                    (default xorg-server))
+  (server-arguments xorg-configuration-server-arguments ;list of strings
+                    (default %default-xorg-server-arguments)))
 
-@var{drivers} must be either the empty list, in which case Xorg chooses a
-graphics driver automatically, or a list of driver names that will be tried in
-this order---e.g., @code{(\"modesetting\" \"vesa\")}.
-
-Likewise, when @var{resolutions} is the empty list, Xorg chooses an
-appropriate screen resolution; otherwise, it must be a list of
-resolutions---e.g., @code{((1024 768) (640 480))}.
-
-Last, @var{extra-config} is a list of strings or objects appended to the
-configuration file.  It is used to pass extra text to be
-added verbatim to the configuration file."
+(define (xorg-configuration->file config)
+  "Compute an Xorg configuration file corresponding to CONFIG, an
+<xorg-configuration> record."
   (define all-modules
     ;; 'xorg-server' provides 'fbdevhw.so' etc.
-    (append modules (list xorg-server)))
+    (append (xorg-configuration-modules config)
+            (list xorg-server)))
 
   (define build
     #~(begin
@@ -159,7 +171,7 @@ added verbatim to the configuration file."
         (call-with-output-file #$output
           (lambda (port)
             (define drivers
-              '#$drivers)
+              '#$(xorg-configuration-drivers config))
 
             (define (device-section driver)
               (string-append "
@@ -201,7 +213,7 @@ EndSection"))
             (display "Section \"Files\"\n" port)
             (for-each (lambda (font)
                         (format port "  FontPath \"~a\"~%" font))
-                      '#$fonts)
+                      '#$(xorg-configuration-fonts config))
             (for-each (lambda (module)
                         (format port
                                 "  ModulePath \"~a\"~%"
@@ -221,7 +233,8 @@ EndSection\n" port)
                      port)
             (newline port)
             (display (string-join
-                      (map (cut screen-section <> '#$resolutions)
+                      (map (cut screen-section <>
+                                '#$(xorg-configuration-resolutions config))
                            drivers)
                       "\n")
                      port)
@@ -229,11 +242,10 @@ EndSection\n" port)
 
             (for-each (lambda (config)
                         (display config port))
-                      '#$extra-config)))))
+                      '#$(xorg-configuration-extra-config config))))))
 
   (computed-file "xserver.conf" build))
 
-
 (define (xorg-configuration-directory modules)
   "Return a directory that contains the @code{.conf} files for X.org that
 includes the @code{share/X11/xorg.conf.d} directories of each package listed
@@ -260,51 +272,38 @@ in @var{modules}."
                                  files)
                        #t))))
 
-(define* (xorg-wrapper #:key
-                       (modules %default-xorg-modules)
-                       (configuration-file (xorg-configuration-file
-                                            #:modules modules))
-                       (xorg-server xorg-server))
-  "Return a derivation that builds a @var{guile} script to start the X server
-from @var{xorg-server}.  @var{configuration-file} is the server configuration
-file or a derivation that builds it; when omitted, the result of
-@code{xorg-configuration-file} is used.  The resulting script should be used
-in place of @code{/usr/bin/X}."
+(define* (xorg-wrapper #:optional (config (xorg-configuration)))
+  "Return a derivation that builds a script to start the X server with the
+given @var{config}.  The resulting script should be used in place of
+@code{/usr/bin/X}."
   (define exp
     ;; Write a small wrapper around the X server.
     #~(begin
         (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
         (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
 
-        (let ((X (string-append #$xorg-server "/bin/X")))
+        (let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
           (apply execl X X
                  "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
-                 "-config" #$configuration-file
-                 "-configdir" #$(xorg-configuration-directory modules)
+                 "-config" #$(xorg-configuration->file config)
+                 "-configdir" #$(xorg-configuration-directory
+                                 (xorg-configuration-modules config))
                  (cdr (command-line))))))
 
   (program-file "X-wrapper" exp))
 
-(define* (xorg-start-command #:key
-                             (modules %default-xorg-modules)
-                             (fonts %default-xorg-fonts)
-                             (configuration-file
-                              (xorg-configuration-file #:modules modules
-                                                       #:fonts fonts))
-                             (xorg-server xorg-server)
-                             (xserver-arguments '("-nolisten" "tcp")))
-  "Return a @code{startx} script in which @var{modules}, a list of X module
-packages, and @var{fonts}, a list of X font directories, are available.  See
-@code{xorg-wrapper} for more details on the arguments.  The result should be
-used in place of @code{startx}."
+(define* (xorg-start-command #:optional (config (xorg-configuration)))
+  "Return a @code{startx} script in which the modules, fonts, etc. specified
+in @var{config}, are available.  The result should be used in place of
+@code{startx}."
   (define X
-    (xorg-wrapper #:configuration-file configuration-file
-                  #:modules modules
-                  #:xorg-server xorg-server))
+    (xorg-wrapper config))
+
   (define exp
     ;; Write a small wrapper around the X server.
     #~(apply execl #$X #$X ;; Second #$X is for argv[0].
-             "-logverbose" "-verbose" "-terminate" #$@xserver-arguments
+             "-logverbose" "-verbose" "-terminate"
+             #$@(xorg-configuration-server-arguments config)
               (cdr (command-line))))
 
   (program-file "startx" exp))
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 07/12] services: sddm, slim, gdm: Take an <xorg-configuration> record.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (4 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration> Ludovic Courtès
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/services/sddm.scm (<sddm-configuration>)[xorg-server-path]
[xserver-arguments]: Remove.
[xorg-configuration]: New field.
(sddm-configuration-file): Adjust accordingly.
* gnu/services/xorg.scm (<slim-configuration>)[startx]: Remove.
[xorg-configuration]: New field.
(slim-shepherd-service, slim-service): Adjust accordingly.
(<gdm-configuration>)[x-server]: Remove.
[xorg-configuration]: New field.
(gdm-shepherd-service, gdm-service): Adjust accordingly.
* doc/guix.texi (X Window): Update accordingly.
---
 doc/guix.texi         | 11 ++++-------
 gnu/services/sddm.scm | 14 ++++++++------
 gnu/services/xorg.scm | 19 +++++++++----------
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2363874cf9..6b73225697 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13181,8 +13181,8 @@ your user profile.  Failing to do that, if @code{auto-login-session} is
 false, you will be unable to log in.
 @end quotation
 
-@item @code{startx} (default: @code{(xorg-start-command)})
-The command used to start the X11 graphical server.
+@item @code{xorg-configuration} (default @code{(xorg-configuration)})
+Configuration of the Xorg graphical server.
 
 @item @code{xauth} (default: @code{xauth})
 The XAuth package to use.
@@ -13258,8 +13258,8 @@ Script to run before starting a wayland session.
 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
 Directory to look for desktop files starting wayland sessions.
 
-@item @code{xorg-server-path} (default @code{xorg-start-command})
-Path to xorg-server.
+@item @code{xorg-configuration} (default @code{(xorg-configuration)})
+Configuration of the Xorg graphical server.
 
 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
 Path to xauth.
@@ -13282,9 +13282,6 @@ Directory to look for desktop files starting X sessions.
 @item @code{minimum-vt} (default: 7)
 Minimum VT to use.
 
-@item @code{xserver-arguments} (default "-nolisten tcp")
-Arguments to pass to xorg-server.
-
 @item @code{auto-login-user} (default "")
 User to use for auto-login.
 
diff --git a/gnu/services/sddm.scm b/gnu/services/sddm.scm
index 2ebfe22016..a33eb39c43 100644
--- a/gnu/services/sddm.scm
+++ b/gnu/services/sddm.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -83,8 +84,8 @@
   (sessions-directory     sddm-configuration-sessions-directory
                           (default "/run/current-system/profile/share/wayland-sessions"))
   ;; [X11]
-  (xorg-server-path       sddm-configuration-xorg-server-path
-                          (default (xorg-start-command)))
+  (xorg-configuration     sddm-configuration-xorg
+                          (default (xorg-configuration)))
   (xauth-path             sddm-configuration-xauth-path
                           (default (file-append xauth "/bin/xauth")))
   (xephyr-path            sddm-configuration-xephyr-path
@@ -99,8 +100,6 @@
                           (default "/run/current-system/profile/share/xsessions"))
   (minimum-vt             sddm-configuration-minimum-vt
                           (default 7))
-  (xserver-arguments      sddm-configuration-xserver-arguments
-                          (default "-nolisten tcp"))
 
   ;; [Autologin]
   (auto-login-user        sddm-configuration-auto-login-user
@@ -140,7 +139,8 @@ SessionCommand="       (sddm-configuration-session-command config)             "
 SessionDir="           (sddm-configuration-sessions-directory config)          "
 
 [X11]
-ServerPath="           (sddm-configuration-xorg-server-path config)            "
+ServerPath="           (xorg-configuration-server
+                        (sddm-configuration-xorg config))            "
 XauthPath="            (sddm-configuration-xauth-path config)                  "
 XephyrPath="           (sddm-configuration-xephyr-path config)                 "
 DisplayCommand="       (sddm-configuration-xdisplay-start config)              "
@@ -148,7 +148,9 @@ DisplayStopCommand="   (sddm-configuration-xdisplay-stop config)               "
 SessionCommand="       (sddm-configuration-xsession-command config)            "
 SessionDir="           (sddm-configuration-xsessions-directory config)         "
 MinimumVT="            (number->string (sddm-configuration-minimum-vt config)) "
-ServerArguments="      (sddm-configuration-xserver-arguments config)           "
+ServerArguments="      (string-join
+                        (xorg-configuration-server-arguments
+                         (sddm-configuration-xorg config)))           "
 
 [Autologin]
 User="                 (sddm-configuration-auto-login-user config)             "
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 3c547c1303..a3a4d769d7 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -436,8 +436,8 @@ desktop session from the system or user profile will be used."
             (default shepherd))
   (auto-login-session slim-configuration-auto-login-session
                       (default #f))
-  (startx slim-configuration-startx
-          (default (xorg-start-command)))
+  (xorg-configuration slim-configuration-xorg
+                      (default (xorg-configuration)))
   (sessreg slim-configuration-sessreg
            (default sessreg)))
 
@@ -454,7 +454,7 @@ desktop session from the system or user profile will be used."
                             (slim-configuration-auto-login-session config)))
           (slim    (slim-configuration-slim config))
           (xauth   (slim-configuration-xauth config))
-          (startx  (slim-configuration-startx config))
+          (startx  (xorg-start-command (slim-configuration-xorg config)))
           (shepherd   (slim-configuration-shepherd config))
           (theme-name (slim-configuration-theme-name config))
           (sessreg (slim-configuration-sessreg config)))
@@ -561,8 +561,7 @@ theme."
             (auto-login? auto-login?) (default-user default-user)
             (theme theme) (theme-name theme-name)
             (xauth xauth) (shepherd shepherd)
-            (auto-login-session auto-login-session)
-            (startx startx))))
+            (auto-login-session auto-login-session))))
 
 \f
 ;;;
@@ -641,8 +640,8 @@ makes the good ol' XlockMore usable."
   (default-user gdm-configuration-default-user (default #f))
   (gnome-shell-assets gdm-configuration-gnome-shell-assets
                       (default (list adwaita-icon-theme font-cantarell)))
-  (x-server gdm-configuration-x-server
-            (default (xorg-wrapper)))
+  (xorg-configuration gdm-configuration-xorg
+                      (default (xorg-configuration)))
   (x-session gdm-configuration-x-session
              (default (xinitrc))))
 
@@ -714,7 +713,8 @@ makes the good ol' XlockMore usable."
                             #$(gdm-configuration-dbus-daemon config))
                            (string-append
                             "GDM_X_SERVER="
-                            #$(gdm-configuration-x-server config))
+                            #$(xorg-wrapper
+                               (gdm-configuration-xorg config)))
                            (string-append
                             "GDM_X_SESSION="
                             #$(gdm-configuration-x-session config))
@@ -779,7 +779,6 @@ password."
   (service gdm-service-type
            (gdm-configuration
             (gdm gdm)
-            (allow-empty-passwords? allow-empty-passwords?)
-            (x-server x-server))))
+            (allow-empty-passwords? allow-empty-passwords?))))
 
 ;;; xorg.scm ends here
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration>.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (5 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 07/12] services: sddm, slim, gdm: Take an <xorg-configuration> record Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-24  9:50     ` Julien Lepiller
  2019-03-20 23:04   ` [bug#34929] [PATCH 09/12] vm: 'virtualized-operating-system' inherits from the user's bootloader config Ludovic Courtès
                     ` (3 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929; +Cc: nee

* gnu/services/xorg.scm (<xorg-configuration>)[keyboard-layout]: New
field.
(xorg-configuration->file)[input-class-section]: New procedure.
Use it.
* doc/guix.texi (X Window): Document 'keyboard-layout' field.

Co-authored-by: nee <nee-git@hidamari.blue>
---
 doc/guix.texi         |  8 ++++++++
 gnu/services/xorg.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6b73225697..5fa68d5e5a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13332,6 +13332,14 @@ When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
 resolution.  Otherwise, it must be a list of resolutions---e.g., @code{((1024
 768) (640 480))}.
 
+@cindex keyboard layout, for Xorg
+@item @code{keyboard-layout} (default: @code{#f})
+If this is @code{#f}, Xorg uses the default keyboard layout---usually US
+English (``qwerty'') for a 105-key PC keyboard.
+
+Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
+layout in use when Xorg is running.
+
 @item @code{extra-config} (default: @code{'()})
 This is a list of strings or objects appended to the configuration file.  It
 is used to pass extra text to be added verbatim to the configuration file.
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index a3a4d769d7..05465f3bdf 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -25,6 +25,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu system pam)
+  #:use-module (gnu system keyboard)
   #:use-module (gnu services dbus)
   #:use-module ((gnu packages base) #:select (canonical-package))
   #:use-module (gnu packages guile)
@@ -147,6 +148,8 @@
                     (default '()))
   (resolutions      xorg-configuration-resolutions ;list of tuples
                     (default '()))
+  (keyboard-layout  xorg-configuration-keyboard-layout ;#f | <keyboard-layout>
+                    (default #f))
   (extra-config     xorg-configuration-extra-config ;list of strings
                     (default '()))
   (server           xorg-configuration-server     ;package
@@ -195,6 +198,31 @@ Section \"Screen\"
   EndSubSection
 EndSection"))
 
+            (define (input-class-section layout variant model options)
+              (string-append "
+Section \"InputClass\"
+  Identifier \"evdev keyboard catchall\"
+  MatchIsKeyboard \"on\"
+  Option \"XkbLayout\" " (object->string layout)
+  (if variant
+      (string-append "  Option \"XkbVariant\" \""
+                     variant "\"")
+      "")
+  (if model
+      (string-append "  Option \"XkbModel\" \""
+                     model "\"")
+      "")
+  (match options
+    (()
+     "")
+    (_
+     (string-append "  Option \"XkbOptions\" \""
+                    (string-join options ",") "\""))) "
+
+  MatchDevicePath \"/dev/input/event*\"
+  Driver \"evdev\"
+EndSection\n"))
+
             (define (expand modules)
               ;; Append to MODULES the relevant /lib/xorg/modules
               ;; sub-directories.
@@ -240,6 +268,19 @@ EndSection\n" port)
                      port)
             (newline port)
 
+            (let ((layout  #$(and=> (xorg-configuration-keyboard-layout config)
+                                    keyboard-layout-name))
+                  (variant #$(and=> (xorg-configuration-keyboard-layout config)
+                                    keyboard-layout-variant))
+                  (model   #$(and=> (xorg-configuration-keyboard-layout config)
+                                    keyboard-layout-model))
+                  (options '#$(keyboard-layout-options
+                               (xorg-configuration-keyboard-layout config))))
+              (when layout
+                (display (input-class-section layout variant model options)
+                         port)
+                (newline port)))
+
             (for-each (lambda (config)
                         (display config port))
                       '#$(xorg-configuration-extra-config config))))))
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 09/12] vm: 'virtualized-operating-system' inherits from the user's bootloader config.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (6 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration> Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 10/12] gnu: Add loadkeys-static Ludovic Courtès
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/system/vm.scm (virtualized-operating-system): Inherit from the
bootloader of OS.
---
 gnu/system/vm.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b671c74ab8..b529cc4631 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -787,6 +787,7 @@ environment with the store shared with the host.  MAPPINGS is a list of
     ;; force the traditional i386/BIOS method.
     ;; See <https://bugs.gnu.org/28768>.
     (bootloader (bootloader-configuration
+                  (inherit (operating-system-bootloader os))
                   (bootloader grub-bootloader)
                   (target "/dev/vda")))
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 10/12] gnu: Add loadkeys-static.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (7 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 09/12] vm: 'virtualized-operating-system' inherits from the user's bootloader config Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 12/12] doc: Document keyboard layout Ludovic Courtès
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* gnu/packages/linux.scm (loadkeys-static): New variable.
---
 gnu/packages/linux.scm | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index e9d8ea45c1..de1a9ba24e 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1995,6 +1995,43 @@ for systems using the Linux kernel.  This includes commands such as
 'loadkeys', 'setfont', 'kbdinfo', and 'chvt'.")
     (license license:gpl2+)))
 
+(define-public loadkeys-static
+  (package
+    (inherit kbd)
+    (name "loadkeys-static")
+    (arguments
+     (substitute-keyword-arguments (package-arguments kbd)
+       ((#:configure-flags flags ''())
+        `(append '("LDFLAGS=-static" "--disable-shared" "--disable-nls"
+                   "--disable-vlock"              ;so we don't need libpam
+                   "--disable-libkeymap")
+                 ,flags))
+       ((#:make-flags flags ''())
+        `(cons "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 ;; The binary keeps references to gzip, among other things,
+                 ;; which we don't need in the initrd, so strip references.
+                 (remove-store-references "src/loadkeys")
+
+                 (install-file "src/loadkeys"
+                               (string-append out "/bin"))
+                 #t)))
+           (delete 'post-install)))
+       ((#:strip-flags _ '())
+        ''("--strip-all"))
+       ((#:allowed-references _ '())
+        '())))
+
+    (synopsis "Statically-linked @command{loadkeys} program")
+
+    ;; This package is meant to be used internally in the initrd so don't
+    ;; expose it.
+    (properties '((hidden? . #t)))))
+
 (define-public inotify-tools
   (package
     (name "inotify-tools")
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (8 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 10/12] gnu: Add loadkeys-static Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  2019-03-20 23:04   ` [bug#34929] [PATCH 12/12] doc: Document keyboard layout Ludovic Courtès
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

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.
---
 doc/guix.texi               | 34 +++++++++++++++++++++++++++++++++-
 gnu/build/linux-boot.scm    | 15 +++++++++++++--
 gnu/system.scm              |  7 +++++--
 gnu/system/linux-initrd.scm | 26 ++++++++++++++++++++++++--
 4 files changed, 75 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5fa68d5e5a..e2bd84493b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10364,6 +10364,24 @@ the command-line of the kernel---e.g., @code{("console=ttyS0")}.
 @item @code{bootloader}
 The system bootloader configuration object.  @xref{Bootloader Configuration}.
 
+@item @code{keyboard-layout} (default: @code{#f})
+This field specifies the keyboard layout to use in the console.  It can be
+either @code{#f}, in which case the default keyboard layout is used (usually
+US English), or a @code{<keyboard-layout>} record.
+
+This keyboard layout is in effect as soon as the kernel has booted.  For
+instance, it is the keyboard layout in effect when you type a passphrase if
+your root file system is on a @code{luks-device-mapping} mapped device
+(@pxref{Mapped Devices}).
+
+@quotation Note
+This does @emph{not} specify the keyboard layout used by the bootloader, nor
+that used by the graphical display server.  @xref{Bootloader Configuration},
+for information on how to specify the bootloader's keyboard layout.  @xref{X
+Window}, for information on how to specify the keyboard layout used by the X
+Window System.
+@end quotation
+
 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
 @cindex initrd
 @cindex initial RAM disk
@@ -22972,6 +22990,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] @
        [#: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
@@ -22983,6 +23002,12 @@ the root file system specified on the kernel command line via @code{--root}.
 include @code{e2fsck/static} or other packages needed by the initrd to check
 the root file system.
 
+When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
+the desired console keyboard layout.  This is done before @var{mapped-devices}
+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{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.
@@ -22992,7 +23017,8 @@ to it are lost.
 @end deffn
 
 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
-       [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
+       [#:mapped-devices '()] [#:keyboard-layout #f] @
+       [#: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
@@ -23000,6 +23026,12 @@ mounted by the initrd, possibly in addition to the root file system specified
 on the kernel command line via @code{--root}.  @var{mapped-devices} is a list of device
 mappings to realize before @var{file-systems} are mounted.
 
+When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
+the desired console keyboard layout.  This is done before @var{mapped-devices}
+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.
+
 @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/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")))
diff --git a/gnu/system.scm b/gnu/system.scm
index e6c86cb9ba..d25eb40325 100644
--- a/gnu/system.scm
+++ b/gnu/system.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 © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
@@ -157,6 +157,8 @@
                     (default '()))                ; list of gexps/strings
   (bootloader operating-system-bootloader)        ; <bootloader-configuration>
 
+  (keyboard-layout operating-system-keyboard-layout ;#f | <keyboard-layout>
+                   (default #f))
   (initrd operating-system-initrd                 ; (list fs) -> file-like
           (default base-initrd))
   (initrd-modules operating-system-initrd-modules ; list of strings
@@ -878,7 +880,8 @@ hardware-related operations as necessary when booting a Linux container."
                #:linux (operating-system-kernel os)
                #:linux-modules
                (operating-system-initrd-modules os)
-               #:mapped-devices mapped-devices))
+               #:mapped-devices mapped-devices
+               #:keyboard-layout (operating-system-keyboard-layout os)))
 
 (define (locale-name->definition* name)
   "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 983c6d81c8..656afd1ddb 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.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 © 2016 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -31,10 +31,13 @@
   #:use-module (gnu packages disk)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages guile)
+  #:use-module ((gnu packages xorg)
+                #:select (console-setup xkeyboard-config))
   #:use-module ((gnu packages make-bootstrap)
                 #:select (%guile-static-stripped))
   #:use-module (gnu system file-systems)
   #:use-module (gnu system mapped-devices)
+  #:use-module (gnu system keyboard)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 vlist)
@@ -139,6 +142,7 @@ MODULES and taken from LINUX."
                       (linux linux-libre)
                       (linux-modules '())
                       (mapped-devices '())
+                      (keyboard-layout #f)
                       (helper-packages '())
                       qemu-networking?
                       volatile-root?
@@ -152,6 +156,11 @@ mappings to realize before FILE-SYSTEMS are mounted.
 HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include
 e2fsck/static or other packages needed by the initrd to check root partition.
 
+When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired
+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 QEMU-NETWORKING? is true, set up networking with the standard QEMU
 parameters.
 
@@ -206,6 +215,8 @@ upon error."
                                     (and #$@device-mapping-commands))
                       #:linux-modules '#$linux-modules
                       #:linux-module-directory '#$kodir
+                      #:keymap-file #+(and=> keyboard-layout
+                                             keyboard-layout->console-keymap)
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
@@ -290,6 +301,7 @@ FILE-SYSTEMS."
                       (linux linux-libre)
                       (linux-modules '())
                       (mapped-devices '())
+                      (keyboard-layout #f)
                       qemu-networking?
                       volatile-root?
                       (extra-modules '())         ;deprecated
@@ -300,6 +312,11 @@ mounted by the initrd, possibly in addition to the root file system specified
 on the kernel command line via '--root'.  MAPPED-DEVICES is a list of device
 mappings to realize before FILE-SYSTEMS are mounted.
 
+When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired
+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.
+
 QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd.
 
 The 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."
       ,@extra-modules))
 
   (define helper-packages
-    (file-system-packages file-systems #:volatile-root? volatile-root?))
+    (append (file-system-packages file-systems
+                                  #:volatile-root? volatile-root?)
+            (if keyboard-layout
+                (list loadkeys-static)
+                '())))
 
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules*
               #:mapped-devices mapped-devices
               #:helper-packages helper-packages
+              #:keyboard-layout keyboard-layout
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 12/12] doc: Document keyboard layout.
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
                     ` (9 preceding siblings ...)
  2019-03-20 23:04   ` [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd Ludovic Courtès
@ 2019-03-20 23:04   ` Ludovic Courtès
  10 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-20 23:04 UTC (permalink / raw)
  To: 34929

* doc/guix.texi (Keyboard Layout): New node.
(Bootloader Configuration): Remove examples and refer to it.
(X Window): Add cross-reference.
---
 doc/guix.texi | 126 ++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 108 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e2bd84493b..f339d52808 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -251,6 +251,7 @@ System Configuration
 * File Systems::                Configuring file system mounts.
 * Mapped Devices::              Block device extra processing.
 * User Accounts::               Specifying user accounts.
+* Keyboard Layout::             How the system interprets key strokes.
 * Locales::                     Language and cultural convention settings.
 * Services::                    Specifying system services.
 * Setuid Programs::             Programs running with root privileges.
@@ -10091,6 +10092,7 @@ instance to support new system services.
 * File Systems::                Configuring file system mounts.
 * Mapped Devices::              Block device extra processing.
 * User Accounts::               Specifying user accounts.
+* Keyboard Layout::             How the system interprets key strokes.
 * Locales::                     Language and cultural convention settings.
 * Services::                    Specifying system services.
 * Setuid Programs::             Programs running with root privileges.
@@ -10951,6 +10953,108 @@ Note that the ``root'' account is not included here.  It is a
 special-case and is automatically added whether or not it is specified.
 @end defvr
 
+@node Keyboard Layout
+@section Keyboard Layout
+
+To specify what each key of your keyboard does, you need to tell the operating
+system what @dfn{keyboard layout} you want to use.  The default, when nothing
+is specified, is the US English QWERTY layout for 105-key PC keyboards.
+However, German speakers will usually prefer the German QWERTZ layout, French
+speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
+or bépo, and they might even want to further customize the effect of some of
+the keys.  This section explains how to get that done.
+
+@cindex keyboard layout, definition
+There are three components that will want to know about your keyboard layout:
+
+@itemize
+@item
+The @emph{bootloader} may want to know what keyboard layout you want to use
+(@pxref{Bootloader Configuration, @code{keyboard-layout}}).  This is useful if
+you want, for instance, to make sure that you can type the passphrase of your
+encrypted root partition using the right layout.
+
+@item
+The @emph{operating system kernel}, Linux, will need that so that the console
+is properly configured (@pxref{operating-system Reference,
+@code{keyboard-layout}}).
+
+@item
+The @emph{graphical display server}, usually Xorg, also has its own idea of
+the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
+@end itemize
+
+Guix allows you to configure all three separately but, fortunately, it allows
+you to share the same keyboard layout for all three components.
+
+@cindex XKB, keyboard layouts
+Keyboard layouts are represented by records created by the
+@code{keyboard-layout} procedure of @code{(gnu system keyboard)}.  Following
+the X Keyboard extension (XKB), each layout has four attributes: a name (often
+a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
+optional variant name, an optional keyboard model name, and a possibly empty
+list of additional options.  In most cases the layout name is all you care
+about.  Here are a few example:
+
+@example
+;; The German QWERTZ layout.  Here we assume a standard
+;; "pc105" keyboard model.
+(keyboard-layout "de")
+
+;; The bépo variant of the French layout.
+(keyboard-layout "fr" "bepo")
+
+;; The Catalan layout.
+(keyboard-layout "es" "cat")
+
+;; The Latin American Spanish layout.  In addition, the
+;; "Caps Lock" keys is used as an additional "Ctrl" key,
+;; and the "Menu" key is used as a "Compose" key to enter
+;; accented letters.
+(keyboard-layout "latam"
+                 #:options '("ctrl:nocaps" "compose:menu"))
+
+;; The Russian layout for a ThinkPad keyboard.
+(keyboard-layout "ru" #:model "thinkpad")
+
+;; The "US international" layout, which is the US layout plus
+;; dead keys to enter accented characters.  This is for an
+;; Apple MacBook keyboard.
+(keyboard-layout "us" "intl" #:model "macbook78")
+@end example
+
+See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
+for a complete list of supported layouts, variants, and models.
+
+@cindex keyboard layout, configuration
+Let's say you want your system to use the Turkish keyboard layout throughout
+your system---bootloader, console, and Xorg.  Here's what your system
+configuration would look like:
+
+@lisp
+;; Using the Turkish layout for the bootloader, the console,
+;; and for Xorg.
+
+(operating-system
+  ;; ...
+  (keyboard-layout (keyboard-layout "tr"))  ;for the console
+  (bootloader (bootloader-configuration
+                (bootloader grub-efi-bootloader)
+                (target "/boot/efi")
+                (keyboard-layout keyboard-layout))) ;for GRUB
+  (services (modify-services %desktop-services
+              (slim-service-type config =>
+                (slim-configuration
+                  (inherit config)
+                  (xorg-configuration
+                    (xorg-configuration             ;for Xorg
+                      (keyboard-layout keyboard-layout))))))))
+@end lisp
+
+In the example above, for GRUB and for Xorg, we just refer to the
+@code{keyboard-layout} field defined above, but we could just as well refer to
+a different layout.
+
 @node Locales
 @section Locales
 
@@ -13356,7 +13460,8 @@ If this is @code{#f}, Xorg uses the default keyboard layout---usually US
 English (``qwerty'') for a 105-key PC keyboard.
 
 Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
-layout in use when Xorg is running.
+layout in use when Xorg is running.  @xref{Keyboard Layout}, for more
+information on how to specify the keyboard layout.
 
 @item @code{extra-config} (default: @code{'()})
 This is a list of strings or objects appended to the configuration file.  It
@@ -23130,23 +23235,8 @@ The number of seconds to wait for keyboard input before booting.  Set to
 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.
+Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
+Layout}).
 
 @quotation Note
 This option is currently ignored by bootloaders other than @code{grub} and
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field.
  2019-03-20 23:04   ` [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field Ludovic Courtès
@ 2019-03-24  9:31     ` Julien Lepiller
  2019-03-24 21:18       ` Ludovic Courtès
  0 siblings, 1 reply; 20+ messages in thread
From: Julien Lepiller @ 2019-03-24  9:31 UTC (permalink / raw)
  To: 34929

Le Thu, 21 Mar 2019 00:04:27 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :

> * 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 <nee-git@hidamari.blue>
> ---
>  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

I think these examples are a bit confusing, because they could be
interpreted as:

(bootloader (bootloader-configuration
                (target "/boot/efi")
                (bootloader grub-efi-bootloader)
                (keyboard-layout "fr" "bepo")))

as well as:

(bootloader (bootloader-configuration
                (target "/boot/efi")
                (bootloader grub-efi-bootloader)
                (keyboard-layout (keyboard-layout "fr" "bepo"))))

and I think you mean the second one, but the first one is the one that
comes immediately to mind when reading the manual. Maybe you could add
the full 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

I think you mean "<keyboard-layout> | #f"

> +                      (default #f))

The rest of the patch lgtm :)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type.
  2019-03-20 23:04   ` [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type Ludovic Courtès
@ 2019-03-24  9:46     ` Julien Lepiller
  2019-03-24 21:18       ` Ludovic Courtès
  0 siblings, 1 reply; 20+ messages in thread
From: Julien Lepiller @ 2019-03-24  9:46 UTC (permalink / raw)
  To: 34929

Le Thu, 21 Mar 2019 00:04:29 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :

I think there's a typo in the subject.

My email client did something weird with your patch :/

> * gnu/services/xorg.scm (<xorg-configuration>): New record type.
> (xorg-configuration-file): Remove.
> (xorg-wrapper): Remove #:modules, #:configuration-file, and
>  #:xorg-server; add optional 'config' parameter instead.  Adjust
> accordingly.
> (xorg-start-command): Likewise.
> * doc/guix.texi (X Window): Document 'xorg-configuration'.  Update
> 'xorg-start-command' documentation.  Remove 'xorg-configuration-file'
> documentation.
> ---
>  doc/guix.texi         | 134
> ++++++++++++++---------------------------- gnu/services/xorg.scm |
> 115 ++++++++++++++++++------------------ 2 files changed, 101
> insertions(+), 148 deletions(-)
> 
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 622740b11c..2363874cf9 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -13310,99 +13310,53 @@ type @code{<sddm-configuration>}.
>  @end example
>  @end deffn
>  
> -@deffn {Scheme Procedure} xorg-start-command @
> -  [#:modules %default-xorg-modules] @
> -  [#:fonts %default-xorg-fonts] @
> -  [#:configuration-file (xorg-configuration-file @dots{})] @
> -  [#:xorg-server @var{xorg-server}]
> -  [#:xserver-arguments '("-nolisten" "tcp")]
> -Return a @code{startx} script in which @var{modules}, a list of X
> module -packages, and @var{fonts}, a list of X font directories, are
> available.  See -@code{xorg-wrapper} for more details on the
> arguments.  The result should be -used in place of @code{startx}.
> -
> -Usually the X server is started by a login manager.
> -@end deffn
> -
> -@cindex @code{-listen tcp}, for X11.
> -This procedure is useful to override command line options for the X
> server, -such as having it listen to over TCP:
> -
> -@example
> -(operating-system
> -  ...
> -  (services
> -    (modify-services %desktop-services
> -      (slim-service-type config =>
> -        (slim-configuration
> -          (inherit config)
> -          (startx (xorg-start-command
> -                   #:xserver-arguments '("-listen" "tcp"))))))))
> -@end example
> -
> -@deffn {Scheme Procedure} xorg-configuration-file @
> -  [#:modules %default-xorg-modules] @
> -  [#:fonts %default-xorg-fonts] @
> -  [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
> -Return a configuration file for the Xorg server containing search
> paths for -all the common drivers.
> -
> -@var{modules} must be a list of @dfn{module packages} loaded by the
> Xorg +@cindex Xorg, configuration
> +@deftp {Data Type} xorg-configuration
> +This data type represents the configuration of the Xorg graphical
> display +server.  Note that there is not Xorg service; instead, the X
                                       ^ typo
> server is started +by a ``display manager'' such as GDM, SDDM, and
> SLiM.  Thus, the configuration +of these display managers aggregates
> an @code{xorg-configuration} record. +
> +@table @asis
> +@item @code{modules} (default: @code{%default-xorg-modules})
> +This is a list of @dfn{module packages} loaded by the Xorg
>  server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard},
> and so on. -@var{fonts} must be a list of font directories to add to
> the server's -@dfn{font path}.
> -
> -@var{drivers} must be either the empty list, in which case Xorg
> chooses a -graphics driver automatically, or a list of driver names
> that will be tried in -this order---e.g., @code{("modesetting"
> "vesa")}. -
> -Likewise, when @var{resolutions} is the empty list, Xorg chooses an
> -appropriate screen resolution; otherwise, it must be a list of
> -resolutions---e.g., @code{((1024 768) (640 480))}.
> -
> -Last, @var{extra-config} is a list of strings or objects appended to
> the -configuration file.  It is used to pass extra text to be
> -added verbatim to the configuration file.
> -
> -@cindex keymap
> -@cindex keyboard layout
> -This procedure is especially useful to configure a different
> keyboard layout -than the default US keymap.  For instance, to use
> the ``bépo'' keymap by -default on the display manager:
> -
> -@example
> -(define bepo-evdev
> -  "Section \"InputClass\"
> -        Identifier \"evdev keyboard catchall\"
> -        Driver \"evdev\"
> -        MatchIsKeyboard \"on\"
> -        Option \"xkb_layout\" \"fr\"
> -        Option \"xkb_variant\" \"bepo\"
> -EndSection")
> -
> -(operating-system
> -  ...
> -  (services
> -    (modify-services %desktop-services
> -      (slim-service-type config =>
> -        (slim-configuration
> -          (inherit config)
> -          (startx (xorg-start-command
> -                   #:configuration-file
> -                   (xorg-configuration-file
> -                     #:extra-config
> -                     (list bepo-evdev)))))))))
> -@end example
> -
> -The @code{MatchIsKeyboard} line specifies that we only apply the
> configuration -to keyboards.  Without this line, other devices such
> as touchpad may not work -correctly because they will be attached to
> the wrong driver.  In this example, -the user typically used
> @code{setxkbmap fr bepo} to set their favorite keymap -once logged
> in.  The first argument corresponds to the layout, while the second
> -argument corresponds to the variant.  The @code{xkb_variant} line
> can be omitted -to select the default variant. +
> +@item @code{fonts} (default: @code{%default-xorg-fonts})
> +This is a list of font directories to add to the server's @dfn{font
> path}. +
> +@item @code{drivers} (default: @code{'()})
> +This must be either the empty list, in which case Xorg chooses a
> graphics +driver automatically, or a list of driver names that will
> be tried in this +order---e.g., @code{("modesetting" "vesa")}.
> +
> +@item @code{resolutions} (default: @code{'()})
> +When @code{resolutions} is the empty list, Xorg chooses an
> appropriate screen +resolution.  Otherwise, it must be a list of
> resolutions---e.g., @code{((1024 +768) (640 480))}.
> +
> +@item @code{extra-config} (default: @code{'()})
> +This is a list of strings or objects appended to the configuration
> file.  It +is used to pass extra text to be added verbatim to the
> configuration file. +
> +@item @code{server} (default: @code{xorg-server})
> +This is the package providing the Xorg server.
> +
> +@item @code{server-arguments} (default:
> @code{%default-xorg-server-arguments}) +This is the list of
> command-line arguments to pass to the X server.  The +default is
> @code{-nolisten tcp}. +@end table
> +@end deftp
> +
> +@deffn {Scheme Procedure} xorg-start-command [@var{config}]
> +Return a @code{startx} script in which the modules, fonts, etc.
> specified +in @var{config}, are available.  The result should be used
> in place of +@code{startx}.
> +
> +Usually the X server is started by a login manager.
>  @end deffn
>  
> +
>  @deffn {Scheme Procedure} screen-locker-service @var{package}
> [@var{program}] Add @var{package}, a package for a screen locker or
> screen saver whose command is @var{program}, to the set of setuid
> programs and add a PAM entry diff --git a/gnu/services/xorg.scm
> b/gnu/services/xorg.scm index 8381a7ed04..3c547c1303 100644
> --- a/gnu/services/xorg.scm
> +++ b/gnu/services/xorg.scm
> @@ -48,7 +48,16 @@
>    #:use-module (srfi srfi-9)
>    #:use-module (srfi srfi-26)
>    #:use-module (ice-9 match)
> -  #:export (xorg-configuration-file
> +  #:export (xorg-configuration
> +            xorg-configuration?
> +            xorg-configuration-modules
> +            xorg-configuration-fonts
> +            xorg-configuration-drivers
> +            xorg-configuration-resolutions
> +            xorg-configuration-extra-config
> +            xorg-configuration-server
> +            xorg-configuration-server-arguments
> +
>              %default-xorg-modules
>              %default-xorg-fonts
>              xorg-wrapper
> @@ -122,33 +131,36 @@
>                       "/share/fonts/X11/misc")
>          (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
>  
> -(define* (xorg-configuration-file #:key
> -                                  (modules %default-xorg-modules)
> -                                  (fonts %default-xorg-fonts)
> -                                  (drivers '()) (resolutions '())
> -                                  (extra-config '()))
> -  "Return a configuration file for the Xorg server containing search
> paths for -all the common drivers.
> +(define %default-xorg-server-arguments
> +  ;; Default command-line arguments for X.
> +  '("-nolisten" "tcp"))
>  
> -@var{modules} must be a list of @dfn{module packages} loaded by the
> Xorg -server---e.g., @code{xf86-video-vesa},
> @code{xf86-input-keyboard}, and so on. -@var{fonts} must be a list of
> font directories to add to the server's -@dfn{font path}.
> +;; Configuration of an Xorg server.
> +(define-record-type* <xorg-configuration>
> +  xorg-configuration make-xorg-configuration
> +  xorg-configuration?
> +  (modules          xorg-configuration-modules    ;list of packages
> +                    (default %default-xorg-modules))
> +  (fonts            xorg-configuration-fonts      ;list of packges
                                                              ^ typo
> +                    (default %default-xorg-fonts))
> +  (drivers          xorg-configuration-drivers    ;list of strings
> +                    (default '()))
> +  (resolutions      xorg-configuration-resolutions ;list of tuples
> +                    (default '()))
> +  (extra-config     xorg-configuration-extra-config ;list of strings
> +                    (default '()))
> +  (server           xorg-configuration-server     ;package
> +                    (default xorg-server))
> +  (server-arguments xorg-configuration-server-arguments ;list of
> strings
> +                    (default %default-xorg-server-arguments)))

The rest lgtm :)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration>.
  2019-03-20 23:04   ` [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration> Ludovic Courtès
@ 2019-03-24  9:50     ` Julien Lepiller
  0 siblings, 0 replies; 20+ messages in thread
From: Julien Lepiller @ 2019-03-24  9:50 UTC (permalink / raw)
  To: 34929

Le Thu, 21 Mar 2019 00:04:31 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :

> * gnu/services/xorg.scm (<xorg-configuration>)[keyboard-layout]: New
> field.
> (xorg-configuration->file)[input-class-section]: New procedure.
> Use it.
> * doc/guix.texi (X Window): Document 'keyboard-layout' field.
> 
> Co-authored-by: nee <nee-git@hidamari.blue>
> ---
>  doc/guix.texi         |  8 ++++++++
>  gnu/services/xorg.scm | 41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 6b73225697..5fa68d5e5a 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -13332,6 +13332,14 @@ When @code{resolutions} is the empty list,
> Xorg chooses an appropriate screen resolution.  Otherwise, it must be
> a list of resolutions---e.g., @code{((1024 768) (640 480))}.
>  
> +@cindex keyboard layout, for Xorg

Maybe add @cindex keymap, for Xorg

> +@item @code{keyboard-layout} (default: @code{#f})
> +If this is @code{#f}, Xorg uses the default keyboard
> layout---usually US +English (``qwerty'') for a 105-key PC keyboard.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration
  2019-03-20 22:32 [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Ludovic Courtès
  2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
@ 2019-03-24 10:03 ` Julien Lepiller
  2019-03-24 22:14   ` bug#34929: " Ludovic Courtès
  1 sibling, 1 reply; 20+ messages in thread
From: Julien Lepiller @ 2019-03-24 10:03 UTC (permalink / raw)
  To: 34929

Le Wed, 20 Mar 2019 23:32:29 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :

> Hello Guix!
> 
> This patch series attempts to address a longstanding issue in Guix:
> keyboard layout configuration.
> 
> The end result is that you can configure the layout for GRUB,
> the Linux console, and Xorg using a single <keyboard-layout> record,
> which directly corresponds to an XKB layout specification.
> 
> The three things still have to be configured separately.  Here’s an
> example where GRUB, Linux, and Xorg use the same layout:
> 
>   (operating-system
>     ;; ...
>     (keyboard-layout (keyboard-layout "tr"))  ;for the console
>     (bootloader (bootloader-configuration
>                   (bootloader grub-efi-bootloader)
>                   (target "/boot/efi")
>                   (keyboard-layout keyboard-layout))) ;for GRUB
>     (services (modify-services %desktop-services
>                 (slim-service-type config =>
>                   (slim-configuration
>                     (inherit config)
>                     (xorg-configuration
>                       (xorg-configuration             ;for Xorg
>                         (keyboard-layout keyboard-layout))))))))
> 
> Clearly the Xorg bit is suboptimal.  I don’t see any obvious way
> to simplify this part unfortunately because the <xorg-configuration>
> record is aggregated by ‘slim-configuration’ & co. (there’s no Xorg
> service that we could extend.)  That’s something we can still improve
> afterwards, though.
> 
> Potentially controversial issues:
> 
>   1. The Xorg API is changed in an incompatible way:
>      ‘xorg-start-command’ has a different prototype, the ‘startx’
>      field of ‘slim-configuration’ is gone, etc.  If you were using
>      these, your config will have to be adjusted to use the new
>      ‘xorg-configuration’ record. (But hey, we’re still pre-1.0!).
> 
>   2. Since both fields and the record constructor are called
>      ‘keyboard-layout’, you could easily have name clashes (it’s
>      more of an aesthetic consideration, not a showstopper.)
> 
> After that we should probably change the installer to generate
> the right incantations.
> 
> These patches fix <https://issues.guix.info/issue/25453> and
> <https://issues.guix.info/issue/26234>.
> 
> Feedback welcome!
> 
> And thanks to nee for the initial inspiration!
> 
> Ludo’.
> 
> Ludovic Courtès (12):
>   bootloader: Remove unused 'additional-configuration' field.
>   bootloader: Reindent record type definition.
>   Add (gnu system keyboard).
>   bootloader: Add a 'keyboard-layout' field.
>   services: xorg: Remove unused #:guile parameter.
>   services: xorg: Define and <xorg-configuration> record type.
>   services: sddm, slim, gdm: Take an <xorg-configuration> record.
>   services: xorg: Add a 'keyboard-layout' field in
> <xorg-configuration>. vm: 'virtualized-operating-system' inherits
> from the user's bootloader config.
>   gnu: Add loadkeys-static.
>   system: Initialize console keyboard layout in the initrd.
>   doc: Document keyboard layout.
> 
>  doc/guix.texi               | 305
> ++++++++++++++++++++++++------------ gnu.scm                     |
> 3 +- gnu/bootloader.scm          |  43 ++---
>  gnu/bootloader/grub.scm     |  35 +++++
>  gnu/build/linux-boot.scm    |  15 +-
>  gnu/local.mk                |   1 +
>  gnu/packages/linux.scm      |  37 +++++
>  gnu/services/sddm.scm       |  14 +-
>  gnu/services/xorg.scm       | 182 ++++++++++++---------
>  gnu/system.scm              |   7 +-
>  gnu/system/keyboard.scm     |  98 ++++++++++++
>  gnu/system/linux-initrd.scm |  26 ++-
>  gnu/system/vm.scm           |   1 +
>  13 files changed, 561 insertions(+), 206 deletions(-)
>  create mode 100644 gnu/system/keyboard.scm
> 

Apart from the minor comments I already sent to patches 4, 6 and 8,
LGTM! Thank you!

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field.
  2019-03-24  9:31     ` Julien Lepiller
@ 2019-03-24 21:18       ` Ludovic Courtès
  0 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-24 21:18 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: 34929

Hi!

Julien Lepiller <julien@lepiller.eu> skribis:

> Le Thu, 21 Mar 2019 00:04:27 +0100,
> Ludovic Courtès <ludo@gnu.org> a écrit :

[...]

>> +while the example below designates the bépo layout for French:
>> +
>> +@example
>> +(keyboard-layout "fr" "bepo")
>> +@end example
>
> I think these examples are a bit confusing, because they could be
> interpreted as:
>
> (bootloader (bootloader-configuration
>                 (target "/boot/efi")
>                 (bootloader grub-efi-bootloader)
>                 (keyboard-layout "fr" "bepo")))
>
> as well as:
>
> (bootloader (bootloader-configuration
>                 (target "/boot/efi")
>                 (bootloader grub-efi-bootloader)
>                 (keyboard-layout (keyboard-layout "fr" "bepo"))))
>
> and I think you mean the second one, but the first one is the one that
> comes immediately to mind when reading the manual. Maybe you could add
> the full example?

Good point.  Actually the last patch adds a new “Keyboard Layout”
section, which I think doesn’t have this problem and provides a complete
example.

>> +  (keyboard-layout
>> bootloader-configuration-keyboard-layout ;string | #f
>
> I think you mean "<keyboard-layout> | #f"

Good catch, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type.
  2019-03-24  9:46     ` Julien Lepiller
@ 2019-03-24 21:18       ` Ludovic Courtès
  0 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-24 21:18 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: 34929

Julien Lepiller <julien@lepiller.eu> skribis:

> I think there's a typo in the subject.

Oops, noted, thanks.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#34929: [PATCH 00/12] Provide uniform keyboard layout configuration
  2019-03-24 10:03 ` [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Julien Lepiller
@ 2019-03-24 22:14   ` Ludovic Courtès
  0 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2019-03-24 22:14 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: 34929-done

Hi Julien,

Julien Lepiller <julien@lepiller.eu> skribis:

> Apart from the minor comments I already sent to patches 4, 6 and 8,
> LGTM! Thank you!

I’ve made the changes you suggested and pushed as commit
2bbb4ead771fcb29266607b338b21c6dd97e3f69.

Thanks for your feedback!

Ludo’.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-03-24 22:15 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 22:32 [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Ludovic Courtès
2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 03/12] Add (gnu system keyboard) Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field Ludovic Courtès
2019-03-24  9:31     ` Julien Lepiller
2019-03-24 21:18       ` Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 05/12] services: xorg: Remove unused #:guile parameter Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type Ludovic Courtès
2019-03-24  9:46     ` Julien Lepiller
2019-03-24 21:18       ` Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 07/12] services: sddm, slim, gdm: Take an <xorg-configuration> record Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration> Ludovic Courtès
2019-03-24  9:50     ` Julien Lepiller
2019-03-20 23:04   ` [bug#34929] [PATCH 09/12] vm: 'virtualized-operating-system' inherits from the user's bootloader config Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 10/12] gnu: Add loadkeys-static Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 12/12] doc: Document keyboard layout Ludovic Courtès
2019-03-24 10:03 ` [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Julien Lepiller
2019-03-24 22:14   ` bug#34929: " Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.