NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

hardware.trackpoint.sensitivity setting being ignored (but hardware.trackpoint.speed set correctly!) #299468

Open lowercasename opened 7 months ago

lowercasename commented 7 months ago

Describe the bug

I've got the following rules in configuration.nix:

  hardware.trackpoint = {
    enable = true;
    speed = 60;
    sensitivity = 128;
  };

After running nixos-rebuild switch, I see the following rule added in /run/current-system/etc/udev/rules.d/99-local.rules:

ACTION=="add|change", SUBSYSTEM=="input", ATTR{name}=="TPPS/2 IBM TrackPoint", ATTR{device/speed}="60", ATTR{device/sensitivity}="128"

On reboot, I can see the following values:

$ cat /sys/devices/platform/i8042/serio1/serio2/sensitivity 
200
$ cat /sys/devices/platform/i8042/serio1/serio2/speed
60

If I remove the rules from configuration.nix and restart, I've got the following values:

$cat /sys/devices/platform/i8042/serio1/serio2/sensitivity 
200
$ cat /sys/devices/platform/i8042/serio1/serio2/speed 
97

It looks like speed is being set as expected and returns to defaults otherwise, but sensitivity stays locked at 200.

Expected behavior

With the above rules, I expect speed to be set to 60 and sensitivity to be set to 128.

Additional context

I'm using a ThinkPad X220 running NixOS unstable, and Wayland. There's a previous bug report here but I'm not sure how relevant it is now: https://github.com/NixOS/nixos-hardware/issues/56

Notify maintainers

@thillux @nikstur

Metadata

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

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.22, NixOS, 24.05 (Uakari), 24.05pre601756.44d0940ea560`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"home-manager, nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

lowercasename commented 7 months ago

A bit of an update: I uncommented my rules and ran nixos-rebuild switch:

building Nix...
building the system configuration...
these 3 derivations will be built:
  /nix/store/62rbzslp455f3awllxclbp1973bwswpq-system-units.drv
  /nix/store/f5qciizlrj9sa3ly5ni8c3kkv1awqgf0-etc.drv
  /nix/store/q8dmpspjl2273z038gp5kyk1flb90i6z-nixos-system-chortik-24.05pre601756.44d0940ea560.drv
building '/nix/store/62rbzslp455f3awllxclbp1973bwswpq-system-units.drv'...
building '/nix/store/f5qciizlrj9sa3ly5ni8c3kkv1awqgf0-etc.drv'...
building '/nix/store/q8dmpspjl2273z038gp5kyk1flb90i6z-nixos-system-chortik-24.05pre601756.44d0940ea560.drv'...
updating GRUB 2 menu...
stopping the following units: systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service
activating the configuration...
setting up /etc...
reloading user units for username...
restarting sysinit-reactivation.target
starting the following units: systemd-udevd-control.socket, systemd-udevd-kernel.socket
the following new units were started: trackpoint.service

...and both sensitivity and speed are now set for my trackpoint, without restarting. I wonder if sensitivity is set to 200 at some stage during startup, but after NixOS's udev rule kicks in?

teu5us commented 1 month ago

It seems that sensitivity get set from hwdb. Invoking udevadm test /sys/class/input/event<n> shows POINTINGSTICK_SENSITIVITY=200. I get my sensitivity=255 after boot on my T450s with the following in config:

services.udev.extraHwdb = ''
  evdev:name:TPPS/2 IBM TrackPoint:dmi:*:svnLENOVO:*:pvrThinkPadT450s:*
   POINTINGSTICK_SENSITIVITY=255
'';
teu5us commented 1 month ago

@lowercasename Could you test if the following works for you?

{ config, lib, ... }:

{
  services.udev.extraHwdb =
    let
      c = config.hardware.trackpoint;
    in
    lib.optionalString c.enable ''
      evdev:name:${c.device}:dmi:*:svnLENOVO:*:pvrThinkPad*:*
       POINTINGSTICK_SENSITIVITY=${builtins.toString c.sensitivity}
    '';
}