Wrong keyboard layout on X (setting services.xserver.layout ignored?)


I’m having an issue where my keyboard layout is reset to “us” whenever I restart the xserver. I have set this in my configuration.nix, but it seems the setting is getting overriden somehow:

services.xserver.layout = "es";

I’ve also set console.keyMap = "es", and that seems to work (on a tty, I get the correct layout) so this points to an Xserver related issue.

I’ve taken extra care to check that the setting was not overriden in any other .nix config file, the only reference to the property services.xserver.layout in my config is the one I’m posting.

Note that I can change my layout with setxkbmap "es" and that works, but that setting is lost when the X server restarts. It may be also worth mentioning that I’m on the US locale: i18n.defaultLocale = "en_US.UTF-8";.

Any tips on how to start debugging this?

Welcome setzer22! I too have a non-US keyboard (Irish). I have the following in my configuration:

  console = {
    font = "Lat2-Terminus16";
    keyMap = "uk";
  i18n = {
    defaultLocale = "en_IE.UTF-8";

But I don’t have services.xserver.layout set to anything. You might try taking out the services.xserver.layout = "es"; line, and see if the problem goes away.

I had a similar issue, but it wasn’t actually related to the X server or any setting affecting it, it was something in KDE that caused the problem. After I finally managed to switch my WM to something else, the issue went away.

I did not dig any further into setting up KDE properly after realising what the issue was, as I never actually wanted to use it.