NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.41k stars 13.63k forks source link

Keyboard layout defaults to QWERTY in display managers #38481

Closed va1entin closed 4 years ago

va1entin commented 6 years ago

Issue description

In spite of #32203 at least the following display managers still use the US keyboard layout by default, ignoring services.xserver.layout:

This means that one has to use the US keyboard layout during login and the one actually configured afterwards. (at least with Plasma)

Steps to reproduce

Set services.xserver.layout to a different keyboard layout than US. Use one of the display managers mentioned above.

Technical details

$ localectl status                 
   System Locale: LANG=en_US.UTF-8
       VC Keymap: de
      X11 Layout: de
       X11 Model: pc104
     X11 Options: terminate:ctrl_alt_bksp
$ more /etc/X11/xorg.conf.d/00-keyboard.conf 
Section "InputClass"
  Identifier "Keyboard catchall"
  MatchIsKeyboard "on"
  Option "XkbModel" "pc104"
  Option "XkbLayout" "de"
  Option "XkbOptions" "terminate:ctrl_alt_bksp"
  Option "XkbVariant" ""
EndSection
 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.15, NixOS, 18.03.131800.ac3437aa061 (Impala)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.0`
 - channels(root): `"nixos-18.03, old-17.09.3222.21693048d72, nixos-unstable-18.03pre130932.cc4677c36ee"`
 - channels(val): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`

Please run nix-shell -p nix-info --run "nix-info -m" and paste the results.

Mic92 commented 6 years ago

cc @jtojnar

jtojnar commented 6 years ago

It definitely works in GDM:

{ pkgs, config, ... }: {
  services.xserver = {
    enable = true;
    layout = "cz";
    xkbVariant = "qwerty";

    displayManager.gdm.enable = true;
    desktopManager.gnome3.enable = true;
  };

  users.extraUsers.j = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "";
  };

  virtualisation.memorySize = 2048;
  virtualisation.diskSize = 2048;
}

Not sure why would the other DMs not support it, when systemd picks it up correctly.

va1entin commented 6 years ago

I'll try if GDM behaves correctly on my machine later today

jtojnar commented 6 years ago

It works for me even in ligthdm:

screenshot from 2018-04-06 13-29-46

SLIM does not seem to support non-ASCII characters but the layout is still cz, not us.

SDDM showed only US flag when it started, but once I pressed any key, the flag was immediately replaced with the correct one:

screenshot from 2018-04-06 13-35-24

I nuked the VM drive each time; using nixpkgs 56fb68dcef494b7cdb3e09362d67836b8137019c.

va1entin commented 6 years ago

Huh that's interesting. I upgraded from 17.09 to 18.03 yesterday and had hoped the issue would be fixed for me with your PR being included in 18.03.

I already did a nix-collect-garbage -d after the upgrade. Do you know if there could be anything stuck here from 17.09?

The update was successful otherwise and all software I checked was upgraded correctly.

jtojnar commented 6 years ago

If localectl status detects the language correctly, it should work. Unless the DM stored the previous configuration somewhere but I do not see why they would do that. GNOME session stores it in GSettings but not GDM AFAIK.

va1entin commented 6 years ago

I was able to narrow this down a bit further.

When I use GDM/SLiM together with Gnome3, they use the correct keyboard layout. SDDM crashed and could not start Gnome3 but I assume that the login worked and it used the correct keyboard layout aswell because of that.

I switched back to SLiM + Plasma5 afterwards and the problem was there again. So it seems to have something to do with the desktop manager.

This is also interesting because Gnome3 itself used the US layout. I know that one has to configure the layout in Gnome3 settings, separately from services.xserver.layout.

@jtojnar did you do your tests with Gnome3 configured? If so, do you mind testing SLiM and SDDM with Plasma5? GDM didn't work with Plasma5 for me, dropped to a shell immediately.

jtojnar commented 6 years ago

I tested with the configuration listed above, using nixos-rebuild build-vm -I nixpkgs=$HOME/Projects/nixpkgs -I nixos-config=gdm-test.nix. I only changed the DM attribute each time. Deleted nixos.qcow2 file before each attempt so there should be no other configuration.

jtojnar commented 6 years ago

I do not have enough hard drive space to test with Plasma but it works with xterm:

{ pkgs, config, ... }: {
  services.xserver = {
    enable = true;
    layout = "cz";
    xkbVariant = "qwerty";

    displayManager.lightdm.enable = true;
    desktopManager.xterm.enable = true;
  };

  users.extraUsers.j = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "";
  };

  virtualisation.memorySize = 2048;
  virtualisation.diskSize = 2048;
}

screenshot from 2018-04-06 16-40-53

va1entin commented 6 years ago

Alright, I've tested several configurations, including the one from the system with this issue in VMs and couldn't reproduce it a single time. So there seems to be something else at work here, that does not have to do with the configuration itself.

If you or anyone else reading this has any other hints or ideas what to look at, I'd be grateful! The next test would be to reinstall NixOS entirely on the system, but the issue is not really annoying enough for that yet ;-)

cx405 commented 6 years ago

Well, for whats worth, SDDM does not respect the locale setting at all and uses en_US locale.

My locale settings in configuration.nix:

environment.systemPackages = with pkgs; [
...
kdeFrameworks.ki18n
...
];
...
i18n.consoleFont = "Lat2-Terminus16";
i18n.consoleKeyMap = "de";
  ##^ was "us"
i18n.defaultLocale = "ru_RU.UTF-8";
  ##^ was "en_US.UTF-8";
i18n.supportedLocales = [ "en_US.UTF-8/UTF-8" "ru_RU.UTF-8/UTF-8" "de_DE.UTF-8/UTF-8" ];
time.timeZone = "Europe/Berlin";
# localectl status
   System Locale: LANG=ru_RU.UTF-8
       VC Keymap: de
      X11 Layout: gb,de,ru
       X11 Model: pc104
     X11 Options: eurosign:e,variant:de
jtojnar commented 6 years ago

@cx405 SDDM respects locale for me, it only shows an incorrect flag until I press any key.

cx405 commented 6 years ago

@jtojnar Do you have anything special in configuration.nix? Perhaps there is something wrong with my settings... :(

I have commented the i18n.supportedLocales out, because it should default to "all", rebuilt, switched, rebooted - no change.

jtojnar commented 6 years ago

@cx405 I used the following configuration, built with nixos-rebuild build-vm -I nixpkgs=$HOME/Projects/nixpkgs -I nixos-config=gdm-test.nix on nixpkgs 56fb68d.

{ pkgs, config, ... }: {
  services.xserver = {
    enable = true;
    layout = "cz";
    xkbVariant = "qwerty";

    displayManager.sddm.enable = true;
    desktopManager.xterm.enable = true;
  };

  users.extraUsers.j = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "py2";
  };

  virtualisation.memorySize = 2048;
  virtualisation.diskSize = 2048;
}
cx405 commented 6 years ago

@jtojnar I think we are misunderstanding each other. :) I was referring to the language of the GUI, its always English for me (untranslated), but keyboard works fine.

jtojnar commented 6 years ago

@cx405 Oh, right sorry. There is $out/share/sddm/translations/ru.qm so that should work. I have no idea how QT searches for translations, perhaps sddm needs to be wrapped with --prefix XDG_DATA_DIRS : "$out/share".

cx405 commented 6 years ago

@jtojnar Thanks for your suggestion, unfortunately I am still learning. I would patch it immediately, if only I could - I still learn nix. Please don't see it as a call for action, I can actually live with it until I learn myself how to fix it. I'll crosslink your suggestion to sddm bugreport with this problem though #37741.

Keyboard works fine for me in sddm, so I guess I am not affected by this exact bug.

va1entin commented 4 years ago

I have no idea what really did the trick but after I upgraded to NixOS 19.09 today, LightDM suddenly uses the correct layout (QWERTZ / German in my case). I literally didn't change anything in my config before so at some point between 19.03.173575.0e0ee084d6d and 19.09.716.88bbb3c8096 at least for LightDM this seems to be fixed. I'm closing this now since my initial issue is resolved, even though I don't why/how exactly.