aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2021 Mathieu Othacehe <othacehe@gnu.org>
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; 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 installer keymap)
  #:use-module (guix records)
  #:use-module (sxml match)
  #:use-module (sxml simple)
  #:use-module (ice-9 binary-ports)
  #:use-module (ice-9 ftw)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex)
  #:export (<x11-keymap-model>
            x11-keymap-model
            make-x11-keymap-model
            x11-keymap-model?
            x11-keymap-model-name
            x11-keymap-model-description

            <x11-keymap-layout>
            x11-keymap-layout
            make-x11-keymap-layout
            x11-keymap-layout?
            x11-keymap-layout-name
            x11-keymap-layout-synopsis
            x11-keymap-layout-description
            x11-keymap-layout-variants

            <x11-keymap-variant>
            x11-keymap-variant
            make-x11-keymap-variant
            x11-keymap-variant?
            x11-keymap-variant-name
            x11-keymap-variant-description

            default-keyboard-model
            xkb-rules->models+layouts
            kmscon-update-keymap))

(define-record-type* <x11-keymap-model>
  x11-keymap-model make-x11-keymap-model
  x11-keymap-model?
  (name            x11-keymap-model-name) ;string
  (description     x11-keymap-model-description)) ;string

(define-record-type* <x11-keymap-layout>
  x11-keymap-layout make-x11-keymap-layout
  x11-keymap-layout?
  (name            x11-keymap-layout-name) ;string
  (synopsis        x11-keymap-layout-synopsis)    ;string (e.g., "en")
  (description     x11-keymap-layout-description) ;string (a whole phrase)
  (variants        x11-keymap-layout-variants)) ;list of <x11-keymap-variant>

(define-record-type* <x11-keymap-variant>
  x11-keymap-variant make-x11-keymap-variant
  x11-keymap-variant?
  (name            x11-keymap-variant-name) ;string
  (description     x11-keymap-variant-description)) ;string

;; Assume all modern keyboards have this model.
(define default-keyboard-model (make-parameter "pc105"))

(define (xkb-rules->models+layouts file)
  "Parse FILE and return two values, the list of supported X11-KEYMAP-MODEL
and X11-KEYMAP-LAYOUT records. FILE is an XML file from the X Keyboard
Configuration Database, describing possible XKB configurations."
  (define maybe-empty
    (match-lambda
      ((x) x)
      (#f "")))

  (define (model m)
    (sxml-match m
                [(model
                  (configItem
                   (name ,name)
                   (description ,description)
                   . ,rest))
                 (x11-keymap-model
                  (name name)
                  (description description))]))

  (define (variant v)
    (sxml-match v
                [(variant
                  ;; According to xbd-rules DTD, the definition of a
                  ;; configItem is: <!ELEMENT configItem
                  ;; (name,shortDescription*,description*,vendor?,
                  ;; countryList?,languageList?,hwList?)>
                  ;;
                  ;; shortDescription and description are optional elements
                  ;; but sxml-match does not support default values for
                  ;; elements (only attributes). So to avoid writing as many
                  ;; patterns as existing possibilities, gather all the
                  ;; remaining elements but name in REST-VARIANT.
                  (configItem
                   (name ,name)
                   . ,rest-variant))
                 (x11-keymap-variant
                  (name name)
                  (description (maybe-empty
                                (assoc-ref rest-variant 'description))))]))

  (define (layout l)
    (sxml-match l
                [(layout
                  (configItem
                   (name ,name)
                   . ,rest-layout)
                  (variantList ,[variant -> v] ...))
                 (x11-keymap-layout
                  (name name)
                  (synopsis (maybe-empty
                             (assoc-ref rest-layout 'shortDescription)))
                  (description (maybe-empty
                                (assoc-ref rest-layout 'description)))
                  (variants (list v ...)))]
                [(layout
                  (configItem
                   (name ,name)
                   . ,rest-layout))
                 (x11-keymap-layout
                  (name name)
                  (synopsis (maybe-empty
                             (assoc-ref rest-layout 'shortDescription)))
                  (description (maybe-empty
                                (assoc-ref rest-layout 'description)))
                  (variants '()))]))

  (let ((sxml (call-with-input-file file
                (lambda (port)
                  (xml->sxml port #:trim-whitespace? #t)))))
    (match
        (sxml-match sxml
                    [(*TOP*
                      ,pi
                      (xkbConfigRegistry
                       (@ . ,ignored)
                       (modelList ,[model -> m] ...)
                       (layoutList ,[layout -> l] ...)
                       . ,rest))
                     (list
                      (list m ...)
                      (list l ...))])
      ((models layouts)
       (values models layouts)))))

(define (kmscon-update-keymap model layout variant options)
  "Update kmscon keymap with the provided MODEL, LAYOUT, VARIANT and OPTIONS."
  (and=>
   (getenv "KEYMAP_UPDATE")
   (lambda (keymap-file)
     (unless (file-exists? keymap-file)
       (error "Unable to locate keymap update file"))

     ;; See file gnu/packages/patches/kmscon-runtime-keymap-switch.patch.
     ;; This dirty hack makes possible to update kmscon keymap at runtime by
     ;; writing an X11 keyboard model, layout and variant to a named pipe
     ;; referred by KEYMAP_UPDATE environment variable.
     (call-with-output-file keymap-file
       (lambda (port)
         (format port model)
         (put-u8 port 0)

         (format port layout)
         (put-u8 port 0)

         (format port (or variant ""))
         (put-u8 port 0)

         (format port (or options ""))
         (put-u8 port 0))))))
.This brings the on disk size of the kernel from 164 MiB to 144 MiB, or about 12%. * gnu/packages/linux.scm (default-extra-linux-options) [version>=5.13]: Enable CONFIG_MODULE_COMPRESS_ZSTD, else CONFIG_MODULE_COMPRESS_GZIP. (make-linux-libre*) [phases] {set-environment}: Set ZSTD_CLEVEL environment variable to 19. [native-inputs]: Add zstd. * gnu/build/linux-modules.scm (module-regex): Add .zst to regexp. Update doc. (modinfo-section-contents): Extend support to Zstd compressed module. (dot-ko): Register the 'zstd compression type. (ensure-dot-ko, file-name->module-name, load-linux-module*) (module-name->file-name/guess, write-module-name-database) (write-module-alias-database, write-module-device-database): Update doc. (module-name-lookup): Also consider zstd-compressed modules. * gnu/installer.scm (installer-program): Add guile-zstd extension to gexp. * gnu/system/linux-initrd.scm (flat-linux-module-directory): Likewise. Decompress zstd-compressed modules for use in initrd. * guix/profiles.scm (linux-module-database): Add guile-zstd extension to gexp. Change-Id: Ide899dc5c58ea5033583b1a91a92c025fc8d901a Maxim Cournoyer 2024-03-27linux-modules: Ignore nonexistent module files on boot....This is a follow-up to 8f8ec56052766aa5105d672b77ad9eaca5c1ab3c, which only covers building initrd, while the booting code still tries to load nonexistent files for builtin modules. * gnu/build/linux-modules.scm (load-linux-modules-from-directory): Ignore nonexistent module files. Change-Id: I09ef207e82397e915e671c8464b92bcf90f03dcf Hilton Chain 2024-02-19services: activation: Ensure /run existence....* gnu/build/activation.scm (activation-script): Ensure /var/run existence. * gnu/build/install.scm (evaluate-populate-directive) [directives]: Remove directory /run. Change-Id: I19ca8e7605c0cff598ab89077a94e20390ba27b0 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Nicolas Graves 2024-02-19services: activation: Ensure /var/run existence....* gnu/services.scm (activation-script): Ensure /var/run existence. * gnu/build/install.scm (evaluate-populate-directive) [directives]: Remove directory /var/run. Change-Id: I5fb93d33b6b1f045f1e5ba206b9b0b74b5184260 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Nicolas Graves 2024-02-19file-systems: Recognize “none” as a valid device spec....* gnu/build/file-systems (canonicalize-device-name): Fallback to tmpfs if spec is "none". Change-Id: Ia55c715d04c7611ba8c979f23f1ad4a8ed2e75b6 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Nicolas Graves 2024-02-10marionette: Add #:peek? to ‘wait-for-tcp-port?’....* gnu/build/marionette.scm (wait-for-tcp-port): Add #:peek? parameter and honor it. Change-Id: Ie7515a5223299390ab8af6fe5aa3cf63ba5c8078 Ludovic Courtès 2024-02-10services: secret-service: Make the endpoint configurable....Until now, the secret service had a hard-coded TCP endpoint on port 1004. This change lets users specify arbitrary socket addresses. * gnu/build/secret-service.scm (socket-address->string): New procedure, taken from Shepherd. (secret-service-send-secrets): Replace ‘port’ by ‘address’ and adjust accordingly. (secret-service-receive-secrets): Likewise. * gnu/services/virtualization.scm (secret-service-shepherd-services): Likewise. (secret-service-operating-system): Add optional ‘address’ parameter and honor it. Adjust ‘start’ method accordingly. Change-Id: I87a9514f1c170dca756ce76083d7182c6ebf6578 Ludovic Courtès 2023-12-27chromium-extension: Compute json at argument evaluation time....* gnu/build/chromium-extension.scm (make-chromium-extension): Make use of the make-signing-key procedure inside the argument field, making sure that it is not evaluated at file-load time. This would otherwise try to resolve gnutls when we can't guarantee it's defined because of dependency cycles. Change-Id: Ia7b13acfbca475c2df073e9a88fc8bb9264dd968 Josselin Poiret 2023-12-22shepherd: Remove ‘make-forkexec-constructor/container’....This was superseded by ‘least-authority-wrapper’. * gnu/build/shepherd.scm (read-pid-file/container) (make-forkexec-constructor/container): Remove. Change-Id: I6acccdff2609a35807608f865a4d381146113a88 Ludovic Courtès 2023-12-11gnu: cross-toolchain: Add set-cross-path for AVR....* gnu/build/cross-toolchain.scm (set-cross-path/avr): New procedure. (cross-gcc-build-phases) [string-prefix? "avr"]: Return set-cross-path/avr procedure. Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech> Change-Id: I00bd39236ac2e31fef02164a7fffc8b56a166f0d Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Jean-Pierre De Jesus DIAZ 2023-12-11gnu: cross-gcc: Enable multilib for AVR....* gnu/build/cross-toolchain.scm (patch-multilib-shebang): New procedure. * gnu/packages/avr.scm (make-avr-gcc): Remove uneeded phases and flags for multilib. * gnu/packages/cross-base (cross-gcc-arguments) <#:configure-flags> [target-avr?]: Remove --disable-multilib and add --enable-multilib. Change-Id: Id68d803057ac898f0a670f10487b08bf0891ab0b Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Jean-Pierre De Jesus DIAZ 2023-12-10gnu: ‘make-icecat-extension’ inherits package location....This is an improvement for the purposes of ‘guix edit’ & co. * gnu/build/icecat-extension.scm (make-icecat-extension): Add ‘location’ field. Change-Id: I896ae6823b3fe4ea013fa74e2c536f45664d8042 Ludovic Courtès 2023-11-19linux-boot: Don't create /root before it's used....* gnu/build/linux-boot.scm (boot-system): Postpone the MKDIR of /root. Change-Id: I589316a5ddf41cada02173ed4dd5b7df09b795e8 Tobias Geerinckx-Rice 2023-10-23gnu: icecat: Support Guix packaged extensions and native manifests....* gnu/build/icecat-extension.scm: New file with a MAKE-ICECAT-EXTENSION procedure that makes sure the add-on directory is a symlink, so that Icecat can normalize it into a package store path. * gnu/local.mk (dist_patch_DATA): Register it, as well as new patches. * gnu/packages/browser-extensions.scm (ublock-origin)[properties]: Store the add-on ID so that it is accessible in MAKE-ICECAT-EXTENSION. [arguments]: Use the add-on ID as root directory. (ublock-origin/icecat): New procedure. * gnu/packages/gnuzilla.scm (icecat-minimal)[arguments]: Rewrite the unused 'apply-guix-specific-patches' phase so that it applies the following two patches. [native-search-paths]: New field. * gnu/packages/patches/icecat-compare-paths.patch: New patch that compares add-on paths (which are package store paths) to detect package changes. * gnu/packages/patches/icecat-use-system-wide-dir.patch: New patch that replaces "/usr/lib/mozilla" (the system-wide directory for extensions and native manifests) with "$ICECAT_SYSTEM_DIR". Clément Lassieur 2023-10-15linux-modules: Fix module dependency loading....* gnu/build/linux-modules.scm (dot-ko): Make COMPRESSION optional, as expected by callers RECURSIVE-MODULE-DEPENDENCIES and LOAD-LINUX-MODULE*. Tobias Geerinckx-Rice 2023-10-12accounts: Fix typo in comment....* gnu/build/accounts.scm (passwd->shadow): Fix typo in comment. Ludovic Courtès 2023-10-08accounts: Ensure ‘last-change’ field of shadow entries is never zero....* gnu/build/accounts.scm (passwd->shadow): Add ‘max’ call so NOW is greater than or equal to 1. Ludovic Courtès 2023-10-01secret-service: Increase default handshake timeout....* gnu/build/secret-service.scm (secret-service-send-secrets): Increase #:handshake-timeout. Ludovic Courtès 2023-10-01hurd-boot: Setup/dev/hdX, /dev/hdXsY IDE device node translators....The gnumach builtin IDE hd devices are still used, unless booting with "noide". * gnu/build/hurd-boot.scm (set-hurd-device-translators): Create /dev/hd{0..3}, /dev/hd{0..3}s{0..3}. Janneke Nieuwenhuizen