From 171d5c92004c8a8fe65ff7dbf01d904b421edf1e Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 3 Oct 2018 16:08:34 +0200 Subject: nixos/xserver: add option to install custom xkb layouts --- pkgs/servers/x11/xorg/overrides.nix | 81 ++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'pkgs/servers') 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 < + - + a + + + ${name} + <_description>${layout.description} + ${layout.description} + + + . + w + EOF + + # add layout description + ${ed}/bin/ed -v rules/base.xml < + - + a + + + ${name} + <_shortDescription>${name} + <_description>${layout.description} + + ${concatMapStrings (lang: "${lang}\n") layout.languages} + + + + + . + 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 ]; }); -- cgit 1.4.1