Simplify the diff, by moving the (mkIf ...) for the keyboard.autosuspend.enable option to within the associated services.udev.extraRules attr-set

This commit is contained in:
mexisme 2024-08-09 23:59:14 +12:00 committed by mergify[bot]
parent 6f38f8576c
commit 569b23fd82

View file

@ -29,7 +29,8 @@ in {
# enables it for kernel 6.9.x onwards. # enables it for kernel 6.9.x onwards.
# #
# Note: the device name is "ASUS N-KEY Device". # Note: the device name is "ASUS N-KEY Device".
keyboard.autosuspend.enable = (mkEnableOption "Enable auto-suspend on the internal USB keyboard (ASUS N-KEY Device) on Zephyrus GA402X" keyboard.autosuspend.enable = (
mkEnableOption "Enable auto-suspend on the internal USB keyboard (ASUS N-KEY Device) on Zephyrus GA402X"
) // { default = defaultAutosuspendEnable; }; ) // { default = defaultAutosuspendEnable; };
}; };
@ -58,19 +59,14 @@ in {
evdev:name:*:dmi:bvn*:bvr*:bd*:svnASUS*:pn*:* evdev:name:*:dmi:bvn*:bvr*:bd*:svnASUS*:pn*:*
KEYBOARD_KEY_ff31007c=f20 KEYBOARD_KEY_ff31007c=f20
''; '';
}; extraRules = mkIf (! cfg.keyboard.autosuspend.enable) ''
};
}
(mkIf (! cfg.keyboard.autosuspend.enable) {
services.udev = {
extraRules = ''
# Disable auto-suspend for the ASUS N-KEY Device, i.e. USB Keyboard # Disable auto-suspend for the ASUS N-KEY Device, i.e. USB Keyboard
# Otherwise on certain kernel-versions, it will tend to take 1-2 key-presses to wake-up after the device suspends # Otherwise on certain kernel-versions, it will tend to take 1-2 key-presses to wake-up after the device suspends
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend", ATTR{idVendor}=="0b05", ATTR{idProduct}=="19b6", ATTR{power/autosuspend}="-1" ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend", ATTR{idVendor}=="0b05", ATTR{idProduct}=="19b6", ATTR{power/autosuspend}="-1"
''; '';
};
}; };
}) }
(mkIf (versionOlder version "23.11") { (mkIf (versionOlder version "23.11") {
# See https://asus-linux.org/wiki/nixos/ for info about some problems # See https://asus-linux.org/wiki/nixos/ for info about some problems