.dotfiles/modules/nixos/optional/hibernation.nix
2025-12-02 00:57:35 +01:00

30 lines
781 B
Nix

{ lib, config, ... }:
{
options.swarselsystems = {
hibernation = {
offset = lib.mkOption {
type = lib.types.int;
default = 0;
};
resumeDevice = lib.mkOption {
type = lib.types.str;
default = "/dev/disk/by-label/nixos";
};
};
};
config = {
boot = {
kernelParams = [
"resume_offset=${builtins.toString config.swarselsystems.hibernation.offset}"
# "mem_sleep_default=deep"
];
inherit (config.swarselsystems.hibernation) resumeDevice;
};
systemd.services."systemd-suspend-then-hibernate".aliases = [ "systemd-suspend.service" ];
powerManagement.enable = true;
systemd.sleep.extraConfig = ''
HibernateDelaySec=120m
SuspendState=freeze
'';
};
}