aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 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."
                                (string-map (match-lambda
                                              (#\, #\-)
                                              (chr chr))
                                            (keyboard-layout-name layout)))
                 build))
vail'>...* gnu/packages/glib.scm (template-glib): New variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Giacomo Leidi 2019-07-31gnu: dbus-c++: Fix build with GCC 7....* gnu/packages/patches/dbus-c++-gcc-compat.patch, gnu/packages/patches/dbus-c++-threading-mutex.patch: New files. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/glib.scm (dbus-c++)[source](patches): New field. [arguments]: End phases on #t. Marius Bakke 2019-07-31gnu: glib: Update to 2.60.6....* gnu/packages/patches/glib-keyfile-arguments.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/glib.scm (glib): Update to 2.60.6. [source](patches): Remove obsolete patch. Marius Bakke 2019-07-12gnu: glib: Fix argument handling in keyfile backend....* gnu/packages/patches/glib-keyfile-arguments.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/glib.scm (glib)[source](patches): Add it. Marius Bakke 2019-07-09gnu: glib: Remove superfluous input....* gnu/packages/glib.scm (glib)[inputs]: Remove BASH. Marius Bakke 2019-07-09gnu: glib: Update to 2.60.5....* gnu/packages/glib.scm (glib): Update to 2.60.5. Marius Bakke 2019-07-07gnu: itstool: Update to 2.0.6....* gnu/packages/glib.scm (itstool): Update to 2.0.6. [inputs]: Change PYTHON2-LIBXML and PYTHON-2 to PYTHON-LIBXML and PYTHON. * gnu/packages/gnome.scm (totem)[inputs]: Change PYTHON-2 to PYTHON. Marius Bakke 2019-06-30build-system/meson: Do not inherit the 'bootstrap' phase....* guix/build/meson-build-system.scm (%standard-phases): Remove 'bootstrap'. * gnu/packages/glib.scm (glib)[arguments]: Adjust accordingly. Marius Bakke 2019-06-21gnu: glibmm: Update to 2.60.0....* gnu/packages/glib.scm (glibmm): Update to 2.60.0. [arguments]: Remove <#:configure-flags>. Marius Bakke 2019-06-21gnu: gobject-introspection: Build with Meson....The 1.60.x releases are the last ones to support Autotools. * gnu/packages/glib.scm (gobject-introspection)[build-system]: Change to MESON-BUILD-SYSTEM. [arguments]: Remove <#:parallel-build?> and <#:tests?>. [native-inputs]: Remove AUTOCONF and AUTOMAKE. Marius Bakke 2019-06-21gnu: gobject-introspection: Update to 1.60.2....* gnu/packages/glib.scm (gobject-introspection): Update to 1.60.2. Marius Bakke 2019-06-21gnu: glib: Update to 2.60.4....* gnu/packages/glib.scm (glib): Update to 2.60.4. [source](snippet): New field. [arguments]: Remove obsolete DETERMINISTIC_BUILD variable. Disable two tests, and override the 'check' phase. Remove <#:parallel-build?>. Marius Bakke 2019-06-20gnu: glib: Install m4 macros....* gnu/packages/glib.scm (glib)[native-inputs]: Add m4. Ricardo Wurmus 2019-06-20gnu: glibmm: Update to 2.58.0....* gnu/packages/glib.scm (glibmm): Update to 2.58.0. Ricardo Wurmus 2019-06-20gnu: gobject-introspection: Update to 1.58.1....* gnu/packages/glib.scm (gobject-introspection): Update to 1.58.1. [source]: Remove snippet. [arguments]: Add phase "do-not-use-/usr/bin/env". [inputs]: Replace python-2 with python-wrapper; add zlib. [native-inputs]: Add autoconf and automake to be able to keep using the gnu-build-system. * gnu/packages/patches/gobject-introspection-cc.patch: Update patch to apply to latest version. Ricardo Wurmus 2019-06-20gnu: glib: Update to 2.58.1....* gnu/packages/glib.scm (glib): Update to 2.58.1. [build-system]: Use meson-build-system. [outputs]: Remove "doc" as the documentation files are no longer included. [inputs]: Move libffi, util-linux, and zlib from here... [propagated-inputs]: ...to here; add libselinux. [arguments]: Remove key "disallowed-references" as it is not supported by the meson-build-system; delete "bootstrap" phase to prevent use of autotools; adjust "pre-build" phase; move "disable-failing-tests" phase after "unpack"; disable two more tests in "disable-failing-tests" phase; add phase "move-executables"; remove configure flags. Ricardo Wurmus 2019-06-20gnu: dbus: Update to 1.12.16....* gnu/packages/patches/dbus-CVE-2019-12749.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/glib.scm (dbus): Update to 1.12.16. [replacement]: Remove. (dbus/fixed): Remove variable. Marius Bakke 2019-06-20Merge branch 'staging' into core-updatesMarius Bakke 2019-06-20Merge branch 'master' into stagingMarius Bakke 2019-06-20gnu: dbus: Fix CVE-2019-12749....* gnu/packages/patches/dbus-CVE-2019-12749.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/glib.scm (dbus)[replacement]: New field. (dbus/fixed): New variable. Marius Bakke 2019-06-14gnu: libsigc++: Update to 2.10.2....* gnu/packages/glib.scm (libsigc++): Update to 2.10.2. Marius Bakke 2019-05-25gnu: dbus: Update to 1.12.14....* gnu/packages/glib.scm (dbus): Update to 1.12.14. Marius Bakke 2019-05-25Merge branch 'staging' into core-updatesMarius Bakke 2019-05-22gnu: dbus-c++: Fix typo "language"....* gnu/packages/glib (dbus-c++)[description]: Fix typo. Vagrant Cascadian