nixos/modules/services/snapper.nix

30 lines
923 B
Nix
Raw Normal View History

2023-10-01 16:24:40 +08:00
inputs:
{
options.nixos.services.snapper = let inherit (inputs.lib) mkOption types; in
{
enable = mkOption { type = types.bool; default = false; };
2023-11-19 17:29:15 +08:00
configs = mkOption { type = types.attrsOf types.nonEmptyStr; default.persistent = "/nix/persistent"; };
2023-10-01 16:24:40 +08:00
};
2024-07-29 22:44:40 +08:00
config = let inherit (inputs.config.nixos.services) snapper; in inputs.lib.mkIf snapper.enable
{
services.snapper.configs = builtins.listToAttrs (builtins.map
(config:
{
inherit (config) name;
value =
{
SUBVOLUME = config.value;
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_MIN_AGE = 1800;
TIMELINE_LIMIT_HOURLY = 10;
TIMELINE_LIMIT_DAILY = 7;
TIMELINE_LIMIT_WEEKLY = 1;
TIMELINE_LIMIT_MONTHLY = 0;
TIMELINE_LIMIT_YEARLY = 0;
};
})
(inputs.localLib.attrsToList snapper.configs));
};
2023-10-01 16:24:40 +08:00
}