services.xserver.libinput.mouse.accelProfile="flat" not applied

I create a configuration with this option on my laptop and used the same configuration to install my desktop computer (except hardware-configuration.nix). The mouse acceleration under KDE/Plasma is not applied. It did work on the laptop but on the desktop it remains “adaptive”.

This is the xserver section

services.xserver = {                                                                                                  
    # Enable the X11 windowing system and configure the keymap in X11.                                                 
    enable = true;                                                                                                    
    layout = "de";                                                                                                     
    xkbVariant = "";                                                                                                    
                                                                                                                      
    # Enable the KDE Plasma Desktop Environment.                                                                      
    displayManager.sddm.enable = true;                                                                                
    desktopManager.plasma5.enable = true;                                                                             
                                                                                                                      
    # Set Wayland as default                                                                                           
    displayManager.defaultSession = "plasmawayland";                                                                  
                                                                                                                       
    libinput.mouse.accelProfile = "flat";                                                                             
  }; 

but the dialog in KDE looks like this:

Also, not sure if this relevant but I have four input devices in this dialog, but only one mouse connected and my keyboard is also neither from Logitech nor Holtek. I don’t understand what is going on here.

Screenshot_20231021_193316

How can I debug this and found out why the acceleration profile is not applied?

I’m also seeing this. Did you figure something out?

I’m not 100% sure but I suspect these settings aren’t what is used when using Wayland. They probably only configure it for X11.

Are you using Wayland? I’ve tried to figure out how to utilize Wayland in place of X11, but to no avail.

What configuration have you set that causes Wayland to be listed as the windowing system in KDE’s about section?

For KDE this is just based on which session you choose in SDDM. In Plasma 5, it will be called “Plasma (Wayland)”.

Ya, that’s what everyone says online, but it’s not what happens for me. I really should open a new thread for this.

Yeah, seems like they are only for X11 (at least if you check the source code, you will see that it just creates some X11 config files). According to https://www.reddit.com/r/NixOS/comments/ouv3lc/enabling_and_configuring_mouse_acceleration_on/ you may want to configure it via sway or alike.

1 Like

Soooooo, get this. I’m running Wayland now… I took your advice @tobiasBora and took a look at Wayland logs with journalctl -b|grep -i 'wayland.*]: ' and saw stuff related to Tmux.

The bellow code that launches tmux with tmuxp was in my zsh profile:

# Launch tmux when:
#     it's installed,
#     not already in a tmux session, and
#     in an interactive shell.
if command -v tmux &> /dev/null && [ $(expr "$TERM" : ".*screen") ] && [ -z "$TMUX" ]; then
  if command -v tmuxp &> /dev/null; then
    exec tmuxp load ~/.config/NixOS/users/reedclanton/home/config/tmuxp/Default.yaml
  fi
fi

So I Changed it to only do so when the current session is tty:

# Launch tmux when:
#     it's installed,
#     current session is a tty,
#     not already in a tmux session, and
#     in an interactive shell.
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [ $(expr "$TERM" : ".*screen") ] && [ -z "$TMUX" ]; then
  if command -v tmuxp &> /dev/null; then
    exec tmuxp load ~/.config/NixOS/users/reedclanton/home/config/tmuxp/Default.yaml
  fi
fi

and now Wayland works!

Of course, now I’m confused as to why X11 worked…

Edit: To be clear, setting services.xserver.displayManager.defaultSession to plasmawayland or gnome works to force the usage of Wayland. However, after fixing the tmux issue, I don’t need to set that value at all.

Glad it helped!

Actually, it uses by default the last session kind you chose I think, maybe explaining why it boots wayland by default now.

I tested it, and services.xserver.displayManager.gdm.wayland does directly determine if X11 or Wayland is used… most of the time. In my case, that didn’t work until I fixed the TMUX issue. I’ve also seen people online say that Wayland won’t be enabled if not supported by hardware.

Anyways, point is, I tested switching that value from true to false and back again, and it did change from Wayland to X11 and back.

My understanding is that setting this value will only configure gdm with WaylandEnable=XXX, and, if my understanding of https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop is correct, setting this value to false will kind of remove the wayland line from the list of available options to boot. So if you set it to false, you cannot boot wayland indeed as this option/line is disabled from gdm. But if you set it to true, then you should be able to boot both X11 and wayland. Then, according to https://github.com/NixOS/nixpkgs/blob/6832d0d99649db3d65a0e15fa51471537b2c56a6/nixos/modules/services/x11/display-managers/default.nix#L277-L320 if you set the services.xserver.displayManager.defaultSession, it will pick that session by default, including for auto login. If you do NOT specify this option, then according to https://github.com/NixOS/nixpkgs/blob/6832d0d99649db3d65a0e15fa51471537b2c56a6/nixos/modules/services/x11/display-managers/default.nix#L289C1-L290 the autologin will be made with the first element of the sessionNames. You can check the actual value, for instance if you use flake, you can do:

$ nix repl
Welcome to Nix 2.13.2. Type :? for help.

nix-repl> :lf /etc/nixos
warning: Git tree '/etc/nixos' is dirty
Added 10 variables.

nix-repl> nixosConfigurations.YOURHOSTNAME.config.services.xserver.displayManager.sessionData.sessionNames
[ "plasma" "plasmawayland" ]

nix-repl> nixosConfigurations.YOURHOSTNAME.config.services.xserver.displayManager.defaultSession          
"plasma"

nix-repl> nixosConfigurations.YOURHOSTNAME.config.services.xserver.displayManager.sessionData.autologinSession
"plasma"

Now, it seems that GDM has a way to save previous session (see ShowLastSession in Configuration), but it is not 100% clear to me when it is using the last session and when it is using the default session.

That is correct. The option should really be renamed to waylandEnabled or waylandAllowed.

Disregarding the failover condition (if gnome session uses Wayland and crashes on login, it will retry with gnome-xorg session), GDM will always pre-select the previous session used by the user as stored by AccountsService. But when you explicitly set defaultSession NixOS option, we will override the AccountService value.

That page looks severely outdated. ShowLastSession has been removed in 2007.

Thanks a lot for the clarification, it helps a lot!

:rofl: I was also surprised not to find anything related to this in nixpkgs