{ config, lib, ... }: let cfg = config.custom.hibernate; in { options.custom.hibernate.enable = lib.mkOption { type = lib.types.bool; default = false; }; config = lib.mkIf cfg.enable { swapDevices = [ { device = "/var/lib/swapfile"; size = 16 * 1024; } ]; boot = { resumeDevice = lib.mkDefault "/dev/mapper/nixos"; }; }; }