2021-01-26 22:59:57 +01:00
|
|
|
{
|
2022-03-10 21:52:12 +01:00
|
|
|
pkgs,
|
|
|
|
|
config,
|
|
|
|
|
...
|
2025-12-27 22:22:54 +01:00
|
|
|
}:
|
|
|
|
|
let
|
2022-03-10 21:52:12 +01:00
|
|
|
suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend";
|
2025-12-27 22:22:54 +01:00
|
|
|
in
|
|
|
|
|
{
|
2023-03-26 19:24:38 +02:00
|
|
|
services.power-action = {
|
2021-01-26 22:59:57 +01:00
|
|
|
enable = true;
|
|
|
|
|
plans.suspend = {
|
2021-02-02 09:08:29 +01:00
|
|
|
upperLimit = 7;
|
2021-01-26 22:59:57 +01:00
|
|
|
lowerLimit = 0;
|
|
|
|
|
charging = false;
|
2023-02-22 10:02:55 +01:00
|
|
|
action = pkgs.writers.writeDash "suspend-wrapper" ''
|
2021-01-26 22:59:57 +01:00
|
|
|
/run/wrappers/bin/sudo ${suspend}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
user = config.users.users.me.name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
security.sudo.extraConfig = ''
|
2023-03-26 19:24:38 +02:00
|
|
|
${config.services.power-action.user} ALL= (root) NOPASSWD: ${suspend}
|
2021-01-26 22:59:57 +01:00
|
|
|
'';
|
|
|
|
|
}
|