about summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2018-10-03 16:08:34 +0200
committerrnhmjoj <rnhmjoj@inventati.org>2019-07-26 18:08:04 +0200
commit171d5c92004c8a8fe65ff7dbf01d904b421edf1e (patch)
tree02dcf33e5b3998198491120441de82575411e456 /pkgs/servers
parente21cb9933be2dec8990b29ed388590067798dad6 (diff)
downloadnixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar.gz
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar.bz2
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar.lz
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar.xz
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.tar.zst
nixlib-171d5c92004c8a8fe65ff7dbf01d904b421edf1e.zip
nixos/xserver: add option to install custom xkb layouts
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix81
1 files changed, 80 insertions, 1 deletions
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 1da5c31c25f6..80b0addd6ec8 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -1,7 +1,7 @@
 { abiCompat ? null,
   stdenv, makeWrapper, fetchurl, fetchpatch, buildPackages,
   automake, autoconf, gettext, libiconv, libtool, intltool,
-  freetype, tradcpp, fontconfig, meson, ninja,
+  freetype, tradcpp, fontconfig, meson, ninja, ed,
   libGL, spice-protocol, zlib, libGLU, dbus, libunwind, libdrm,
   mesa, udev, bootstrap_cmds, bison, flex, clangStdenv, autoreconfHook,
   mcpp, epoxy, openssl, pkgconfig, llvm_6,
@@ -423,6 +423,85 @@ self: super:
     '';
   });
 
+  # xkeyboardconfig variant extensible with custom layouts.
+  # See nixos/modules/services/x11/extra-layouts.nix
+  xkeyboardconfig_custom = { layouts ? { } }:
+  let
+    patchIn = name: layout:
+    with layout;
+    with lib;
+    ''
+        # install layout files
+        ${optionalString (compatFile   != null) "cp '${compatFile}'   'compat/${name}'"}
+        ${optionalString (geometryFile != null) "cp '${geometryFile}' 'geometry/${name}'"}
+        ${optionalString (keycodesFile != null) "cp '${keycodesFile}' 'keycodes/${name}'"}
+        ${optionalString (symbolsFile  != null) "cp '${symbolsFile}'  'symbols/${name}'"}
+        ${optionalString (typesFile    != null) "cp '${typesFile}'    'types/${name}'"}
+
+        # patch makefiles
+        for type in compat geometry keycodes symbols types; do
+          if ! test -f "$type/${name}"; then
+            continue
+          fi
+          test "$type" = geometry && type_name=geom || type_name=$type
+          ${ed}/bin/ed -v $type/Makefile.am <<EOF
+        /''${type_name}_DATA =
+        a
+        ${name} \\
+        .
+        w
+        EOF
+          ${ed}/bin/ed -v $type/Makefile.in <<EOF
+        /''${type_name}_DATA =
+        a
+        ${name} \\
+        .
+        w
+        EOF
+        done
+
+        # add model description
+        ${ed}/bin/ed -v rules/base.xml <<EOF
+        /<\/modelList>
+        -
+        a
+        <model>
+          <configItem>
+            <name>${name}</name>
+            <_description>${layout.description}</_description>
+            <vendor>${layout.description}</vendor>
+          </configItem>
+        </model>
+        .
+        w
+        EOF
+
+        # add layout description
+        ${ed}/bin/ed -v rules/base.xml <<EOF
+        /<\/layoutList>
+        -
+        a
+        <layout>
+          <configItem>
+            <name>${name}</name>
+            <_shortDescription>${name}</_shortDescription>
+            <_description>${layout.description}</_description>
+            <languageList>
+              ${concatMapStrings (lang: "<iso639Id>${lang}</iso639Id>\n") layout.languages}
+            </languageList>
+          </configItem>
+          <variantList/>
+        </layout>
+        .
+        w
+        EOF
+    '';
+  in
+    self.xkeyboardconfig.overrideAttrs (old: {
+      buildInputs = old.buildInputs ++ [ automake ];
+      postPatch   = with lib; concatStrings (mapAttrsToList patchIn layouts);
+    });
+
   xload = super.xload.overrideAttrs (attrs: {
     nativeBuildInputs = attrs.nativeBuildInputs ++ [ gettext ];
   });