{ config, lib, pkgs, ... }: let cfg = config.my_btrbk; inherit (lib) mkEnableOption mkIf mkOption; types = lib.types; in { options.my_btrbk = { enable = mkEnableOption "Btrbk backups"; sshKeyFile = mkOption { type = types.nonEmptyStr; }; sshUser = mkOption { type = types.nonEmptyStr; default = "btrbk"; }; }; config = mkIf cfg.enable { services.btrbk.instances."remote_falcon" = { onCalendar = "daily"; settings = { ssh_identity = cfg.sshKeyFile; ssh_user = cfg.sshUser; incremental = "yes"; stream_compress = "zstd"; stream_compress_level = "3"; target_preserve_min = "no"; target_preserve = "5d 4w 6m"; subvolume = { "/" = { snapshot_name = "root"; }; "/home" = { snapshot_name = "home"; }; }; snapshot_dir = "/.btrbk_snapshots"; target = "send-receive ssh://10.0.0.5/zpool-backup/backups/${config.networking.hostName}"; }; }; }; }