{ config, lib, ... }: let cfg = config.nomarchy.system.hibernation; in { config = lib.mkIf cfg.enable { # Wait this long after suspend before hibernating, and use the same # delay as the idle-action timeout so the two paths agree. # nixpkgs 26.05 replaced systemd.sleep.extraConfig with the RFC42-style # `settings` attrset. systemd.sleep.settings.Sleep.HibernateDelaySec = cfg.idleMinutes * 60; services.logind = { settings.Login = { HandleLidSwitch = lib.mkDefault "suspend-then-hibernate"; HandleLidSwitchExternalPower = lib.mkDefault "suspend"; HandlePowerKey = lib.mkDefault "hibernate"; IdleAction = lib.mkDefault "suspend-then-hibernate"; IdleActionSec = lib.mkDefault (toString (cfg.idleMinutes * 60)); }; }; }; }