From 70829a0af6e4eb428acfe112fe51a09da3ec3291 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 30 Aug 2024 17:57:55 +0530 Subject: common: hibernate on critical battery level --- os/common/configuration.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'os/common') diff --git a/os/common/configuration.nix b/os/common/configuration.nix index 047b153..8026b9f 100644 --- a/os/common/configuration.nix +++ b/os/common/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: let +{ config, pkgs, lib, ... }: let host = config.networking.hostName; in { disabledModules = [ @@ -23,6 +23,12 @@ in { size = 2048; # 2GB }]; + services.udev.extraRules = let + cmd = "${pkgs.systemd}/bin/systemctl hibernate"; + in '' + SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${cmd}" + ''; + sops = { defaultSopsFile = ../${host}/secrets.yaml; age.keyFile = "/var/secrets/${host}.sops"; -- cgit v1.2.3