# backups-option.nix cfg: let inherit (cfg.lib) mkOption types mkEnableOption attrNames; in mkOption { type = types.attrsOf ( types.submodule ( { name, config, ... } @ args: { options = { backend = mkOption { type = types.enum (attrNames cfg.backends); description = "The backup backend to use"; }; paths = mkOption { type = types.listOf types.str; default = []; description = "Paths to backup"; }; enable = mkOption { type = types.bool; default = true; description = "Whether to enable this backup job"; }; timerConfig = mkOption { type = with types; nullOr attrs; default = null; example = { OnCalendar = "00:05"; Persistent = true; RandomizedDelaySec = "5h"; }; description = '' When to run the backup. If null, inherits from backend's default timerConfig. Set to null to disable automatic scheduling. ''; }; backendOptions = mkOption { type = let backupConfig = config; backupName = name; in types.submodule ( {config, ...} @ args'': cfg.backends.${args.config.backend} (args'' // {inherit backupConfig backupName;}) ); default = {}; description = "Backend-specific options"; }; preBackupScript = mkOption { type = types.lines; default = ""; description = "Script to run before backing up"; }; postBackupScript = mkOption { type = types.lines; default = ""; description = '' Script to run after backing up. Runs even if the backup fails. ''; }; notifications = { failure = { enable = mkOption { type = types.bool; default = true; description = "Enable failure notifications"; }; }; success = { enable = mkOption { type = types.bool; default = false; description = "Enable success notifications"; }; }; }; }; } ) ); default = {}; description = "Backup job definitions"; }