1 { config, lib, pkgs, ... }:
6 layouts = config.services.xserver.xkb.extraLayouts;
10 description = mkOption {
12 description = lib.mdDoc "A short description of the layout.";
15 languages = mkOption {
16 type = types.listOf types.str;
19 A list of languages provided by the layout.
20 (Use ISO 639-2 codes, for example: "eng" for english)
24 compatFile = mkOption {
25 type = types.nullOr types.path;
27 description = lib.mdDoc ''
28 The path to the xkb compat file.
29 This file sets the compatibility state, used to preserve
30 compatibility with xkb-unaware programs.
31 It must contain a `xkb_compat "name" { ... }` block.
35 geometryFile = mkOption {
36 type = types.nullOr types.path;
38 description = lib.mdDoc ''
39 The path to the xkb geometry file.
40 This (completely optional) file describes the physical layout of
41 keyboard, which maybe be used by programs to depict it.
42 It must contain a `xkb_geometry "name" { ... }` block.
46 keycodesFile = mkOption {
47 type = types.nullOr types.path;
49 description = lib.mdDoc ''
50 The path to the xkb keycodes file.
51 This file specifies the range and the interpretation of the raw
52 keycodes sent by the keyboard.
53 It must contain a `xkb_keycodes "name" { ... }` block.
57 symbolsFile = mkOption {
58 type = types.nullOr types.path;
60 description = lib.mdDoc ''
61 The path to the xkb symbols file.
62 This is the most important file: it defines which symbol or action
63 maps to each key and must contain a
64 `xkb_symbols "name" { ... }` block.
68 typesFile = mkOption {
69 type = types.nullOr types.path;
71 description = lib.mdDoc ''
72 The path to the xkb types file.
73 This file specifies the key types that can be associated with
74 the various keyboard keys.
75 It must contain a `xkb_types "name" { ... }` block.
82 xkb_patched = pkgs.xorg.xkeyboardconfig_custom {
83 layouts = config.services.xserver.xkb.extraLayouts;
91 (lib.mkRenamedOptionModuleWith {
93 from = [ "services" "xserver" "extraLayouts" ];
94 to = [ "services" "xserver" "xkb" "extraLayouts" ];
100 options.services.xserver.xkb = {
101 extraLayouts = mkOption {
102 type = types.attrsOf (types.submodule layoutOpts);
104 example = literalExpression
108 description = "My custom xkb layout.";
109 languages = [ "eng" ];
110 symbolsFile = /path/to/my/layout;
114 description = lib.mdDoc ''
115 Extra custom layouts that will be included in the xkb configuration.
116 Information on how to create a new layout can be found here:
117 <https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html#Defining_New_Layouts>.
118 For more examples see
119 <https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Basic_examples>
125 ###### implementation
127 config = mkIf (layouts != { }) {
129 environment.sessionVariables = {
130 # runtime override supported by multiple libraries e. g. libxkbcommon
131 # https://xkbcommon.org/doc/current/group__include-path.html
132 XKB_CONFIG_ROOT = config.services.xserver.xkb.dir;
136 xkb.dir = "${xkb_patched}/etc/X11/xkb";
137 exportConfiguration = config.services.xserver.displayManager.startx.enable
138 || config.services.xserver.displayManager.sx.enable;