add(nixos): mouse-wakeup

This commit is contained in:
kenji
2026-03-21 19:08:49 -05:00
parent ba09321f6b
commit 7bf2c6fea2
4 changed files with 25 additions and 20 deletions
+1
View File
@@ -11,6 +11,7 @@
./kernel.nix
./nix.nix
./power.nix # TODO: this one has to be optional
./mouse-wakeup.nix
./programs.nix
./security.nix
./services.nix
+14
View File
@@ -0,0 +1,14 @@
{ lib, myConfig, ... }:
with lib;
let
cfg = myConfig.wakeup.mouse or {};
in
{
config = mkIf (cfg.disable or false && cfg.vendor != null && cfg.product != null) {
services.udev.extraRules = ''
# Disable wakeup for mouse configured in config.nix
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="${cfg.vendor}", ATTRS{idProduct}=="${cfg.product}", ATTR{power/wakeup}="disabled"
'';
};
}
+3 -20
View File
@@ -1,21 +1,4 @@
{pkgs, ...}: {
# USB wakeup configuration
# Disabling USB wakeups to prevent accidental wakeups from mouse/keyboard/bluetooth
systemd.services.disable-usb-wakeups = {
description = "Disable USB wakeup triggers";
wantedBy = ["multi-user.target" "post-resume.target"];
after = ["post-resume.target"];
serviceConfig = {
Type = "oneshot";
ExecStart = pkgs.writeShellScript "disable-usb-wakeups" ''
for device in XHC0 XHC1 XHC2 XH00 GPP0 GPP7; do
if grep -q "$device.*enabled" /proc/acpi/wakeup; then
echo "Disabling wakeup for $device"
echo "$device" > /proc/acpi/wakeup
fi
done
'';
RemainAfterExit = true;
};
};
{
# This file is intentionally left blank.
# USB wakeup is now handled by modules/nixos/mouse-wakeup.nix
}