Volume control doesn't stop auto-repeating

The volume control keys on my integrated keyboard (volume up and volume down) sometimes fail to stop auto-repeating, causing the volume to be continuously increasing/decreasing. All other keys behave as expected. This bug has been present since installation.

For now, I’ve remapped my volume control keys to pgup and pgdown, but it would be nice if this bug could be resolved.

I have already tried disabling repeating keys: For some reason, this only slowed the rate at which the volume decreased/increased when holding down the volume control keys, yet did not solve the bug. Holding down pgup or pgdown would also increase the volume at the same, slowed pace (but unlike the actual volume control keys, they stop auto-repeating when released). All other keys completely stop auto-repeating (except for brightness controls which are completely unaffected for some reason, but other than that these keys behave as expected).

While I primarily use Plasma KDE, the same issue was present on Gnome, suggesting the bug is not desktop environment related. I dual boot with windows, and on windows it works fine, so it’s probably not a hardware issue either.

System information:
Lenovo Thinkbook 14 2-in-1 Gen 5 IAU
NixOS version 25.11 with KDE Plasma
Kernel version 6.12.74 (I have already tried downgrading to 6.1 without avail)
BIOS is up to date

If it matters, the sound related configuration on my configuration.nix:

services.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

Plus I have services.xserver enabled, if that matters.

When using sudo evtest and press and release the volume control key, I get the following result:

Event: time 1772726624.246487, type 4 (EV_MSC), code 4 (MSC_SCAN), value b0
Event: time 1772726624.246487, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 2
Event: time 1772726624.246487, -------------- SYN_REPORT ------------ 

(for clarification: when releasing the volume control keys, it does not send any new messages, indicating that the system does realize the key is released at some point. The issue is that the value is not set to 0, but remains on 2 = auto-repeat).

Although note that this bug is not consistent. Sometimes after releasing the volume control keys, it does set the value to 0 (as is the expected behavior).

Event: time 1772726705.570678, type 4 (EV_MSC), code 4 (MSC_SCAN), value b0
Event: time 1772726705.570678, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 1772726705.570678, -------------- SYN_REPORT ------------

Anyone got any ideas of what I could try to resolve this issue? I’m relatively new to NixOS, so it is possible that I may have overlooked something simple.

A friend of mine was able to come up with a solution after doing some further research. For anyone with a similar problem, this might be worth a try:

Add the following to configuration.nix

services.udev.extraHwdb = ''
    # Fix volume buttons
    evdev:atkbd:dmi:bvn*:bvr*:bd*:br*:svn*:pn*:pvr*
     KEYBOARD_KEY_ae=!volumedown
     KEYBOARD_KEY_b0=!volumeup
  '';

Original

Change evdev:atkbd:dmi:bvn*:bvr*:bd*:br*:svn*:pn*:pvr* (or more specifically the part after evdev:atkbd:) with the contents of /sys/class/dmi/id/modalias, i.e.

cat /sys/class/dmi/id/modalias

Note: This solution assumes you are using the atkbd driver