New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/xserver: add option to install custom xkb layouts #47764
Conversation
This is great - I'm (hopefully) going to try this out over the weekend. Instead of overriding the various packages, can't we use a wrapper derivation instead that consists of vanilla upstream + whatever additional layouts you want? |
Update? I don't think it's possibile to do that because the file |
Dang this works! |
I tested it again with overlays and seems ok. I also added a comment to explain the situation. |
6ad81fe
to
f7d77d6
Compare
LGTM, but I'd like another pair of eyes to take a look too, the way only certain things get patched is very unorthodox |
Thank you for the review! I'm aware of that, unfortunately I don't know of any other way. |
An idea I have is to mark packages that use # Only the following packages are necessary to set
# a custom layout anyway: I'm wondering how you determined this list of packages, they're the ones we'd mark as essential. |
From the blog post, besides xkbcomp and xbkmap:
|
Okay so I tried this PR out myself, with the following config: {
services.xserver = {
exportConfiguration = true;
extraLayouts.cdvp = {
description = "Custom Programmer Dvorak";
languages = [ "eng" ];
layoutFile = builtins.toFile "layout.xkb" ''
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols {
include "pc+us(dvp)+inet(evdev)+capslock(backspace)"
key <LSGT> { [ Control_L ] };
key <RWIN> { [ Break ] };
modifier_map Control { <LSGT> };
};
xkb_geometry { include "pc(pc105)" };
};
'';
};
}; But no luck, after a bunch of compilations (and even restarting my display manager), it's as if nothing changed, there's no What am I missing here? |
I also tried {
layoutFile = builtins.toFile "layout" ''
xkb_symbols {
include "pc+us(dvp)+inet(evdev)+capslock(backspace)"
key <LSGT> { [ Control_L ] };
key <RWIN> { [ Break ] };
modifier_map Control { <LSGT> };
};
'';
} but no luck either, same result |
So, I fixed the issue left when renaming the attributes. |
Done. |
I also moved the patchable |
@GrahamcOfBorg eval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@infinisil Thank you for all the help! |
Yes, finally! Thank you guys! |
I'm not a gnome use so I've never tested this. What does
This is intended: this options installs a layout by placing a new file in the xkb source tree.
The description should be in there... this maybe be a bug. |
The result of localectl...
I'll get back when I build with Another thing... it is really needed to build all the gnome packages from source when using |
Hello I can confirm that with the following:
configuration in configuration.nix I can use "esrodk" as default in a tty terminal... but still does not work in gnome. localectl ouputs the following now:
Update: I fixed the human-friendly name issue in this commit... dasj19@87ec211 however I'm still trying to get it working in gnome. |
We are already trying to reduce the number of rebuilds by not overriding xkb directly, however xorgserver, setxkbmap, xkbcomp, ckbcomp and xkbvalidate must be overriden. It seems the problem is gdm and mutter depends on xorgserver.
Oh, right: that broke when xkb dropped intltool. Could you make a PR?
I'll try it too as soon as I have some spare time; I should also look into other DEs as well. I know it, at least, works in XFCE. |
Some developments...
and after
Note: the layout part of the 2 outputs. |
Did you try setting only one layout? I mean like |
I just tried... It looks like it uses the US layout ... This is what i have in configuration.nix:
After rebooting GDM uses US layout, same as the rest of Gnome, while TTY uses "esrodk". Some more info:
Output of localectl:
Next thing I'll try is to remove |
@dasj19 So, I have tested KDE Plasma, XFCE and GNOME. It seems to be a problem only in GNOME. I couldn't figure out much besides wht you already found. |
The GNOME issue was fixed in #76591. |
I'm pretty new to Nix and xkb but I've been trying to setup a keyboard layout using custom types. To actually use xkb types applied using this method it seems like we would need to update the |
I don't know how Anyway, If you need to replace an existing file in xkb, you could try to define another layout like:
This should override |
@rnhmjoj Thanks for the quick response. After looking at your comment I did some more research and I think your work on the rules file should cover what I was imagining. I'll give it a try when I'm back to a computer. |
the loading of user specific xkb files should be ready according to this: https://who-t.blogspot.com/2020/09/user-specific-xkb-configuration-putting.html not sure when these changes get/got into NixOS. |
@rnhmjoj I haven't been able to figure out how types are attached besides this post. But I was attempting to try your suggestion of overwriting the services.xserver.extraLayouts.complete = {
description = "Complete types override";
languages = [ "eng" ];
typesFile = ./keyboard/complete.xkb;
}; and I ran into this error: make[2]: Nothing to be done for 'install-exec-am'.
/nix/store/1c1r48qa0m23vr9jy8sm0dc04vv14dak-coreutils-8.32/bin/mkdir -p '/nix/store/xlqwv7waszd0f8xk651jfrml4fw2301b-xkeyboard-config-2.31/share/X11/xkb/compat'
/nix/store/1c1r48qa0m23vr9jy8sm0dc04vv14dak-coreutils-8.32/bin/install -c -m 644 complete accessx basic caps complete iso9995 japan ledcaps ledcompose lednum ledscroll level5 misc mousekeys olpc pc pc98 xfree86 xtest README '/nix/store/xlqwv7waszd0f8xk651jfrml4fw2301b-xkeyboard-config-2.31/share/X11/xkb/compat'
/nix/store/1c1r48qa0m23vr9jy8sm0dc04vv14dak-coreutils-8.32/bin/install: will not overwrite just-created '/nix/store/xlqwv7waszd0f8xk651jfrml4fw2301b-xkeyboard-config-2.31/share/X11/xkb/compat/complete' with 'complete' Should we reverse the check in this line nixpkgs/pkgs/servers/x11/xorg/overrides.nix Line 506 in a78925d
complete line in the _DATA section. Also should we only be adding files to the _DATA section if they were configured? I believe right now we'd be putting files in the _DATA section that don't exist.
|
Motivation for this change
I have found no way to add a custom keyboard layout to xkb declaratively from nixos configuration.
I wrote this module based on a blog post and it's working as intended so far. See also #31138.
The usage is as follows:
It works by patching various packages so I'm not sure if this is acceptable.
Things done