如何在 nixos 中设置自定义 xkb_keymap

如何在 nixos 中设置自定义 xkb_keymap

我有以下布局layouts/en_ru

xkb_keymap {
  xkb_keycodes      { include "evdev+aliases(qwerty)" };
  xkb_geometry      { include "pc(pc104)" };
  xkb_types         { include "complete" };
  xkb_compat        { include "complete" };

  xkb_symbols {
    include "pc+us+ru:2+inet(evdev)"
    include "group(rctrl_rshift_toggle)"
    include "capslock(swapescape)"

    // swap right alt and left control
    replace key <RALT> { [ Control_L ] };
    modifier_map Control { <RALT> };

    // swap ; and : only in us layout
    replace key <AC10> { [ colon, semicolon ],
                        [ Cyrillic_zhe, Cyrillic_ZHE ] };

    // helpers //
    // xinput list
    // xinput test 16
    // xkbcomp $DISPLAY out.xkb
    // cat /usr/share/X11/xkb/rules/base.lst
  };
};

这是加载在 $HOME/xinitrc像这样

xkbcomp $HOME/.config/layouts/en_ru $DISPLAY

如何把这一切搬到configuration.nix


我通过添加实现了第一部分

xserver = {
  enable = true;
  layout = "us,ru";
  xkbOptions = "caps:swapescape,grp:rctrl_rshift_toggle";
};

到我的configuration.nix,但我不知道如何添加这部分并使其在系统范围内

// swap right alt and left control
replace key <RALT> { [ Control_L ] };
modifier_map Control { <RALT> };

// swap ; and : only in us layout
replace key <AC10> { [ colon, semicolon ],
                    [ Cyrillic_zhe, Cyrillic_ZHE ] };

答案1

这是一个暂时的问题。 systemd 中有修复,但 NixOS 中尚未包含 systemd 的版本:

https://github.com/systemd/systemd/commit/5016eb56352a7ea1f61ea106fa4f5639fbf6ddd8

我知道你在说什么! “这不是答案!”并且我同意!幸运的是,我们可以选择services.udev.extraHwdb在 中添加我们自己的 udev 规则configuartion.nix

这是我现在正在进行的最终修复:

services.udev.extraHwdb = ''
  evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:pvr*
    KEYBOARD_KEY_56=backslash
''

答案2

      sessionCommands = ''
        ${xorg.xkbcomp}/bin/xkbcomp ${layout} $DISPLAY &
      '';
    };

https://github.com/srghma/dotfiles/blob/0054e4586183e0dcf1bdecc9507bde937c365f30/nixos/root/services/default.nix#L116

相关内容