Gnome is not picking this up (I can’t select it in the settings), but I can select this layout when using X11 by doing setxkbmap, but there is no way to do it in Wayland.
There are many posts regarding this, but none of them helped me. The most relevant was this:
The fix itself mentions this PR in GNOME:
This PR says that GNOME is looking for keyboard layouts here: “$XDG_CONFIG_ROOT/xkb” this evaluates to “.config/xkb” on my machine.
When I tried looking for the layout that is generated by nix I got few packages in /nix/store with echo /**/xkb/symbols/fck.
So I tried symlinking it to ~/.config. Something like ~/.config/xkb -> /nix/store/1jb6zf1x7xkcv0p3nfnprqhh32vhkrmn-xkeyboard-config-2.33/etc/X11/xkb/.
This worked and I can see my layout in the settings.
Now I need to generate that nix store path programmatically in my config.
I tried pkgs.xkeyboard_config.outPath, but that gives me a path to a different package that doesn’t have my custom layout.
One way to do this is simply to call your layout custom. I’m not sure which package it is, but there is a package that contains a database of keyboard layouts that has a special entry for us to use like that. It should show up in GNOME.
That is not a thing, the variable is named XKB_CONFIG_ROOT, which the extra-layouts module creates by default:
An it should contain a value like /nix/store/01qsglilnjzlczknw9zvh0gmf6h2slcp-xkeyboard-config-2.33/etc/X11/xkb.
~/.config sounds like you are confusing the variable with XDG_CONFIG_HOME (notice the prefix is named after X KeyBoard, not X Desktop Group, and the suffix is root, not home).
I would expect it to work unless there was a regression. Though it probably requires you to re-log in after you rebuild your system since it is not possible to change environment of running programs in general.
As I mentioned, the extra-layouts module already sets the variable, which is then picked up by libxkb & co.