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