nix/nixos/common/services/powertop.nix

13 lines
505 B
Nix
Raw Normal View History

2023-07-05 03:29:56 +02:00
{
powerManagement.powertop.enable = true;
systemd.services.powertop.postStart = ''
HIDDEVICES=$(ls /sys/bus/usb/drivers/usbhid | grep -oE '^[0-9]+-[0-9\.]+' | sort -u)
for i in $HIDDEVICES; do
echo -n "Enabling " | cat - /sys/bus/usb/devices/$i/product
echo 'on' > /sys/bus/usb/devices/$i/power/control
done
'';
# FIXME always coredumps on boot
systemd.services.powertop.serviceConfig.Restart = "on-failure";
systemd.services.powertop.serviceConfig.RestartSec = "2s";
}