Xorg Libinput configuration seems to be ignored

I want to configure my touchpad setup to use taps, natural scrolling and other useful things, so I used this config in my /etc/nixos/configuration.nix:

 services.xserver = {
    // ...

    libinput = {
      enable = true;
      touchpad.tapping = true;
      touchpad.naturalScrolling = true;
      touchpad.scrollMethod = "twofinger";
      touchpad.disableWhileTyping = false;
      touchpad.clickMethod = "clickfinger";

but I don’t see any changes made to my xorg input config after rebuilding and rebooting.

I also tried this method of setting the config:

    # Set extra config to libinput devices
    extraConfig = ''
    Section "InputClass"
        Identifier "touchpad"
        Driver "libinput"
        MatchIsTouchpad "on"
    	Option "Tapping" "true"
	    Option "NaturalScrolling" "true"
	    Option "DisableWhileTyping" "false"
    	Option "ClickMethod" "clickfinger"

This also did not change anything.

In both cases, I only see a 40-libinput.conf file with the following contents:

# Match on all types of devices but joysticks
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
# Section "InputClass"
#   Identifier "something or other"
#   MatchDriver "libinput"
#   MatchIsTouchpad "on"
#   ... other Match directives ...
#   Option "someoption" "value"
# EndSection
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"

I don’t want to directly edit the xorg config files for this; is there a way to get the config specified in the nix config to stick?

I am experiencing the same issue as I just upgraded NixOS from 21.11 to 22.05.

I am facing the same problem on NixOS unstable. After upgrading the system, my touchpad stopped working. A bit of debugging with libinput showed that despite having this on my configuration.nix:

  services.xserver.libinput = {
    enable = true;
    touchpad = {
      sendEventsMode = "enabled";
      scrollMethod = "twofinger";
      naturalScrolling = true;
      tapping = true;

the options continue disabled:

# libinput list-devices
Device:           SynPS/2 Synaptics TouchPad
Kernel:           /dev/input/event0
Group:            9
Seat:             seat0, default
Size:             100x68mm
Capabilities:     pointer gesture
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   *two-finger edge
Click methods:    *button-areas clickfinger
Disable-w-typing: enabled
Disable-w-trackpointing: enabled
Accel profiles:   flat *adaptive
Rotation:         n/a

Did you make any progress fixing this issue?

Unfortunately not. I had intended to use nixos as a daily driver but this issue has prevented me from doing so.

Could your desktop environment be overriding your libinput config?

I suspect that @WarpspeedSPC is looking at the wrong configuration file because I had the same problem, and I solved it by removing the file ~/.config/touchpadxlibinputrc.

My /run/current-system/etc/X11/xorg.conf.d/40-libinput.conf like the one of @WarpspeedSPC, but everything is working fine as expected.

I had to set services.xserver.exportConfiguration = true;, and then the config was updated in /etc/X11/xorg.conf (but not in 40-libinput.conf, but I don’t think that matters much) - see Xorg libinput configuration is ignored · Issue #188046 · NixOS/nixpkgs · GitHub

Reviving this as I’m curious if those using Wayland have any options on configuring libinput? Using Gnome so don’t seem to have a native way of doing it. I can sudo libinput debug-events --set-scroll-method=button --set-scroll-button=BTN_MIDDLE and see my desired results, but haven’t had luck with services.xserver.libinput. By the option path alone, I realize the module seems to be xorg specific, but was hoping because libinput sits beneath x/wayland somehow it might still work. Trying to figure out other options now if others have ideas.

EDIT: of course, after hours of getting deep in the weeds, I find there is a dconf setting for those of use using trackballs and wanting the button scroll method:

    "org/gnome/desktop/peripherals/trackball" = {
      scroll-wheel-emulation-button = 2;