Xkb extraLayout not set at startup


I’m following the instructions from the Custom XKB layouts chapter of the manual.

I’m using a xkb_symbols definition that I’ve made based on an existing one (“eu” aka EurKEY). It works fine when I try it with

setxkbmap -I/etc/nixos/xkb_layouts eurcode | xkbcomp -I/etc/nixos/xkb_layouts - $DISPLAY

or simply

setxkbmap eurcode

but I’m not succeeding to get the layout set at startup.

My configuration:

  services = {
    xserver = {
      enable = true;
      displayManager= {
        sddm.enable = true;
      desktopManager.plasma5.enable = true;
      layout = "eurcode";
      extraLayouts.eurcode = {
        description = "eurcode";
        languages = [ "eng" ];
        symbolsFile = /etc/nixos/xkb_layouts/symbols/eurcode;

I’ve tried putting a few variations of setxkbmap in services.xserver.displayManager.sessionCommands, but the outcome is the same.

I’m using NixOS 21.11.337040.a62ce97f92b (Porcupine).

Any idea why it’s not working or what I could try to troubleshoot?

It seems my KDE layout configuration from earlier was overriding the custom one, I should have checked in the login screen and/or without a desktopManager.

What fixed it for me was to remove all “configured layouts” from the KDE system settings (unchecking “configure layout” wasn’t enough).

This is what my changes did to KDE’s config files:

diff --git a/kxkbrc b/kxkbrc
index ad88782..abd7451 100644
--- a/kxkbrc
+++ b/kxkbrc
@@ -3,10 +3,10 @@ update_info=kxkb_variants.upd:split-variants

Then after re-logging, my custom layout shows in KDE’s settings and I can add another (non-custom) layout without losing mine. I wanted to be able to easily switch so I’m glad that works.