Signed-off-by: gwg313 <gwg313@pm.me>
This commit is contained in:
parent
4c0e29da8f
commit
bb2fe56082
40 changed files with 595 additions and 1144 deletions
|
|
@ -34,6 +34,8 @@
|
|||
./sysctl.nix
|
||||
./earlyoom.nix
|
||||
|
||||
./sleep.nix
|
||||
|
||||
# Or modules from other flakes (such as nixos-hardware):
|
||||
# inputs.hardware.nixosModules.common-cpu-amd
|
||||
# inputs.hardware.nixosModules.common-ssd
|
||||
|
|
|
|||
34
hosts/grymforge/sleep.nix
Normal file
34
hosts/grymforge/sleep.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
systemd.services.sleep-schedule = {
|
||||
description = "Suspend PC at 10PM and wake at 6:30AM using rtcwake";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = pkgs.writeShellScript "sleep-schedule" ''
|
||||
WAKE_TIME=$(${pkgs.coreutils}/bin/date +%s -d "tomorrow 06:30")
|
||||
exec ${pkgs.util-linux}/bin/rtcwake -m mem -t "$WAKE_TIME"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers.sleep-schedule = {
|
||||
description = "Timer to suspend PC at 10PM daily";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily 22:00";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "root" ];
|
||||
commands = [
|
||||
{
|
||||
command = "/run/current-system/sw/bin/rtcwake";
|
||||
options = [ "NOPASSWD" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue