NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.9k stars 13.95k forks source link

setting xorg keyboard layout doesn't work anymore with linux latest kernel 5.12 #126423

Open alarsyo opened 3 years ago

alarsyo commented 3 years ago

Describe the bug

Alright so this one is a bit weird. I just bisected the issue in my personal configuration to this commit, so I'm pretty sure it's indeed some kernel behavior that's changed in between the 5.10 LTS and 5.12 (the commit switches my configuration to 5.12).

Basically setting services.xserver.layout doesn't take effect anymore. Typing setxkbmap -query or setxkbmap -print does show the layout I've picked, but it's evident when typing that my current keyboard is still in default QWERTY US layout.

Honestly I don't think this is a NixOS bug, just a weird interaction between more recent kernels and the Xorg device layout settings, but I had no idea of where to complain about this other than here.

I'm guessing the problem has to do with the keyboard being loaded as a device later, after the layout configuration has already been set; I've often had problems with keyboards that were just plugged in and defaulted to the qwerty us layout even though all other keyboards on the machine were set to another layout.

Any clue on how I might bisect the Linux kernel to the exact commit that changed this behavior on my NixOS config?

To Reproduce

Steps to reproduce the behavior:

  1. set boot.kernelPackages = pkgs.linuxPackages_latest;
  2. reboot
  3. use your keyboard, it defaults to QWERTY US even with services.xserver.layout = "fr"; set for example
  4. typing setxkbmap -query does show the correct layout selected though:
    rules:      evdev
    model:      pc104
    layout:     fr
    options:    terminate:ctrl_alt_bksp

Expected behavior

The keyboard uses the selected layout

Additional context

I'm using sddm and i3wm, though I could also reproduce the problem with the default gdm.

Metadata

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

 - system: `"x86_64-linux"`
 - host os: `Linux 5.12.4, NixOS, 21.05.20210604.aa57635 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210601_5985b8b`
 - channels(root): `"nixos-21.05beta555.d25ea6a0d2a"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
alarsyo commented 3 years ago

Testing on pkgs.linuxPackages_5_11: can't reproduce, so the problem appeared somewhere in 5.12.

I'm suspecting this is also related to the keyboard I'm using, a Keyboardio.

Indeed, here's the output of xinput list on 5.10 and 5.11:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01                       id=8    [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01 Consumer Control      id=11   [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01 Mouse                 id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ Keyboardio Model 01 System Control        id=9    [slave  keyboard (3)]
    ↳ Keyboardio Model 01 Keyboard              id=10   [slave  keyboard (3)]
    ↳ Keyboardio Model 01                       id=13   [slave  keyboard (3)]
    ↳ ASRock LED Controller                     id=14   [slave  keyboard (3)]

And on 5.12:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01                       id=8    [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01 Keyboard              id=10   [slave  pointer  (2)]
⎜   ↳ Keyboardio Model 01 Mouse                 id=11   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ Keyboardio Model 01 System Control        id=9    [slave  keyboard (3)]
    ↳ Keyboardio Model 01                       id=12   [slave  keyboard (3)]
    ↳ ASRock LED Controller                     id=13   [slave  keyboard (3)]

Notice how the Keyboardio Model 01 Consumer Control line disappears, and the Keyboardio Model 01 Keyboard line moves from Virtual core keyboard to Virtual core pointer.

alarsyo commented 3 years ago

So this issue definitely doesn't have anything to do with NixOS, except that it allowed me to bisect the root cause efficiently :D. Feel free to close if needed.

If anyone has tips on how to bisect individual kernel commits on my flakes setup, I'm all ears!

MikiVanousek commented 2 years ago

I seem to have the same issue #151462