dotfiles/modules/nixos/hardware/sleep.nix

21 lines
841 B
Nix
Raw Normal View History

2022-12-21 21:18:03 +00:00
{ config, pkgs, lib, ... }: {
2022-12-21 21:18:03 +00:00
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
# Prevent wake from keyboard
powerManagement.powerDownCommands = ''
2023-02-23 04:46:24 +00:00
# for power in /sys/bus/usb/devices/*/power; do echo disabled > ''${power}/wakeup; done
# AMD issue: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Instantaneous_wakeups_from_suspend
for power in /sys/bus/i2c/devices/i2c-*/device/power; do echo disabled > ''${power}/wakeup; done
2022-12-21 21:18:03 +00:00
'';
2023-02-23 04:46:24 +00:00
# From here: https://www.reddit.com/r/NixOS/comments/wcu34f/how_would_i_do_this_in_nix/
# services.udev.extraRules = ''
# ACTION=="add", SUBSYSTEM=="i2c", ATTRS{idVendor}=="<vendor>", ATTRS{idProduct}=="<product>" RUN+="${pkgs.bash}/bin/bash -c 'echo disabled > /sys/bus/i2c/devices/i2c-*/power/wakeup'"
# '';
2022-12-21 21:18:03 +00:00
};
}