and I also have something like this, in wayland.windowManager.sway.extraConfig:
input type:keyboard {
xkb_layout bsk
}
Basically, I just want to have a custom layout and use it with my WM. It used to work, until I updated my system. Now, on nixos-rebuild switch, it complains that:
error: builder for '/nix/store/xq9h502wnqwxpgc3zx8zh19q1ysvj1dv-sway.conf.drv' failed with exit code 1;
last 25 log lines:
> Fontconfig error: No writable cache directories
> Fontconfig error: No writable cache directories
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] Couldn't find file "symbols/bsk" in include paths
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] 1 include paths searched:
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] /nix/store/4d6p2fvack9fzcfp78xw9g45wz6m0pri-xkeyboard-config-2.41/etc/X11/xkb
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] 3 include paths could not be added:
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] /homeless-shelter/.config/xkb
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] /homeless-shelter/.xkb
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-338] /etc/xkb
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] [XKB-769] Abandoning symbols file "(unnamed)"
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] Failed to compile xkb_symbols
> 00:00:00.048 [sway/input/keyboard.c:732] [xkbcommon] Failed to compile keymap
> 00:00:00.048 [sway/config.c:872] Error on line 37 'xkb_layout bsk': Failed to compile keymap: [XKB-338] Couldn't find file "symbols/bsk" in include paths (/nix/store/h5g6096x1ri7s1g4yz5cy2xgwzds87sf-sway.conf)
> 00:00:00.057 [sway/config.c:435] Error(s) loading config!
For full logs, run 'nix log /nix/store/xq9h502wnqwxpgc3zx8zh19q1ysvj1dv-sway.conf.drv'
error: 1 dependencies of derivation '/nix/store/s64hkvjq5g4jc6fhk4f41fkcmclwv0bc-activation-script.drv' failed to build
...
My understanding of this error is that it tries to validate the configuration file at build time, but fails to resolve the keyboard layouts, because it doesn’t refer to the correct derivation of xkb, the one that does contain my custom layouts.
Ok, I’ve found it here.
The solution is to take into account XKB_CONFIG_ROOT.
If home-manager is installed as a NixOS module that command could pick it up from config.environment.sessionVariables. For example, here’s how the xserver module validates its layout option:
When using home-manager standalone, I don’t think it’s possible because that check is performed at build time and there’s now way to know what the environment will look like at run time. Possible solutions could be:
Add an option in the vein of networking.nftables.preCheckRuleset to remove config lines that can’t be checked reliably
It seems that option 2. already exists, at wayland.windowManager.sway.checkConfig. I’ve used it as a workaround. I’ll notify the HM maintainers of this issue, eventually.