3

I have following layout 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
  };
};

which is loaded in $HOME/xinitrc like this

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

How to move all this to configuration.nix?


I have made first part of this happen by adding

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

to my configuration.nix, but I don't know how to add this part and make it system wide

// 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
    my first thought is that your swap-Ralt-Lctrl portion is a fairly simple new option to create. the swap-in-us-layout is less so. if altering the system xkb database on nixos is like most linuxes, here's how to make a new option: askubuntu.com/a/969232/669043 ... but i suspect it's a little more like implementing that sort of change as a local patch to a source package that then gets compiled for your particular system, and that's beyond my experience. if you can figure that out, you'd just add your new option to your xkbOptions line like any other option. – quixotic Oct 29 '17 at 13:04
  • 1
    the swap-in-us-layout probably would need to be added as a separate variant (theoretically it could simply include us and then do your replace key -- without the cyrillic symbols -- see /usr/share/X11/xkb/symbols/us for examples). then instead of layout = "us,ru" you'd specify layout = "us-myvariant,ru". – quixotic Oct 29 '17 at 13:09
1

This is a temporary issue. A fix is in systemd, but the version of systemd isn't in NixOS yet:

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

I know what you're saying! "That's not an answer!" and I agree! Luckily, we have the option services.udev.extraHwdb, where we can add our own udev rules in configuartion.nix.

Here's the final fix that I have working now:

services.udev.extraHwdb = ''
  evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:pvr*
    KEYBOARD_KEY_56=backslash
''
0
      sessionCommands = ''
        ${xorg.xkbcomp}/bin/xkbcomp ${layout} $DISPLAY &
      '';
    };

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.