os/modules/core/hibernation.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1 KiB
Nix
Raw Normal View History

2022-08-14 18:09:38 +00:00
{
2022-11-20 22:28:23 +00:00
config,
pkgs,
lib,
...
}:
2022-08-14 18:09:38 +00:00
with lib; let
cfg = config.pub-solar.core.hibernation;
2022-11-20 22:28:23 +00:00
in {
2022-08-14 18:09:38 +00:00
options.pub-solar.core.hibernation = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether the device can hibernate. This creates a swapfile at /swapfile.";
};
resumeDevice = mkOption {
2022-11-02 19:55:05 +00:00
type = types.nullOr types.str;
default = null;
2022-08-14 18:09:38 +00:00
description = "The location of the hibernation resume swap file.";
};
resumeOffset = mkOption {
type = types.nullOr types.int;
default = null;
description = "The swap file offset. Can be found by running `filefrag -v $swap_file_location`. See https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file";
};
};
config = {
boot = mkIf cfg.enable {
2022-11-02 19:55:05 +00:00
resumeDevice = mkIf (cfg.resumeDevice != null) cfg.resumeDevice;
2022-10-23 16:33:11 +00:00
kernelParams = mkIf (cfg.resumeOffset != null) ["resume_offset=${builtins.toString cfg.resumeOffset}"];
2022-08-14 18:09:38 +00:00
};
};
}