Created
April 19, 2016 11:43
-
-
Save binarin/380eda7b08a1c230abbc186887fc5823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
packageOverrides = super: { | |
xorg = super.xorg // rec { | |
xkeyboard_config_dvp = super.pkgs.lib.overrideDerivation super.xorg.xkeyboardconfig (old: { | |
patches = [ | |
(builtins.toFile "ru-dvp.patch" '' | |
--- xkeyboard-config-2.16-orig/symbols/ru 2014-12-11 01:56:38.000000000 +0300 | |
+++ xkeyboard-config-2.16/symbols/ru 2016-04-15 14:27:25.075214654 +0300 | |
@@ -719,3 +719,24 @@ | |
key <TLDE> { [ bracketright, bracketleft ] }; | |
key <BKSL> { [ Cyrillic_io, Cyrillic_IO ] }; | |
}; | |
+partial default alphanumeric_keys | |
+xkb_symbols "dvp" { | |
+ include "ru(common)" | |
+ | |
+ name[Group1]= "Russia"; | |
+ | |
+ key <AE01> { [ numerosign, percent ] }; | |
+ key <AE02> { [ quotedbl, 7 ] }; | |
+ key <AE03> { [ question, 5 ] }; | |
+ key <AE04> { [ slash, 3 ] }; | |
+ key <AE05> { [ parenleft, 1 ] }; | |
+ key <AE06> { [ equal, 9 ] }; | |
+ key <AE07> { [ asterisk, 0 ] }; | |
+ key <AE08> { [ parenright, 2 ] }; | |
+ key <AE09> { [ plus, 4 ] }; | |
+ key <AE10> { [ minus, 6 ] }; | |
+ key <AE11> { [ exclam, 8 ] }; | |
+ key <AE12> { [ semicolon, colon ] }; | |
+ key <AB10> { [ period, comma ] }; | |
+ key <BKSL> { [ backslash, bar ] }; | |
+}; | |
'') | |
]; | |
}); | |
xorgserver = super.pkgs.lib.overrideDerivation super.xorg.xorgserver (old: { | |
postInstall = '' | |
rm -fr $out/share/X11/xkb/compiled | |
ln -s /var/tmp $out/share/X11/xkb/compiled | |
wrapProgram $out/bin/Xephyr \ | |
--set XKB_BINDIR "${xkbcomp}/bin" \ | |
--add-flags "-xkbdir ${xkeyboard_config_dvp}/share/X11/xkb" | |
wrapProgram $out/bin/Xvfb \ | |
--set XKB_BINDIR "${xkbcomp}/bin" \ | |
--set XORG_DRI_DRIVER_PATH ${super.mesa}/lib/dri \ | |
--add-flags "-xkbdir ${xkeyboard_config_dvp}/share/X11/xkb" | |
( # assert() keeps runtime reference xorgserver-dev in xf86-video-intel and others | |
cd "$dev" | |
for f in include/xorg/*.h; do # */ | |
sed "1i#line 1 \"${old.name}/$f\"" -i "$f" | |
done | |
) | |
''; | |
}); | |
setxkbmap = super.pkgs.lib.overrideDerivation super.xorg.setxkbmap (old: { | |
postInstall = | |
'' | |
mkdir -p $out/share | |
ln -sfn ${xkeyboard_config_dvp}/etc/X11 $out/share/X11 | |
''; | |
}); | |
xkbcomp = super.pkgs.lib.overrideDerivation super.xorg.xkbcomp (old: { | |
configureFlags = "--with-xkb-config-root=${xkeyboard_config_dvp}/share/X11/xkb"; | |
}); | |
}; | |
}; | |
}; |
Yeah, I didn't care about recompilation that much, as I was usually doing this on a dedicated beefy machine. But nowadays I've gave up on idea of software-based custom layouts - too many programs that I need are handling it very badly. And there is hardly anything that you can do about it.
I actually found out that the XKB version in NixOS 21.11 supports loading keyboard layouts from users' home directories! I just had to add this to my configuration.nix
:
environment.sessionVariables = rec {
XDG_CONFIG_HOME = "\${HOME}/.config";
};
and create correct ~/.config/xkb/rules/evdev
, ~/.config/xkb/rules/evdev.xml
and ~/.config/kxb/symbols/*
files.
I have my customized Dvorak layout and two shortcuts with which I can activate either a standard layout or my custom one with one keypress.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where should I get the original
rules/ru
file from?Edit: Found it in
/nix/store/xifpfl33xirk2ysc740lckj7lf0z6k42-xkeyboard-config-2.33.tar.bz2
, but doing this kind of a modification seems to trigger re-compilation of Xorg and GNOME packages :(