at 23.05-pre 1.8 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.borgmatic; 7 settingsFormat = pkgs.formats.yaml { }; 8 cfgfile = settingsFormat.generate "config.yaml" cfg.settings; 9in { 10 options.services.borgmatic = { 11 enable = mkEnableOption (lib.mdDoc "borgmatic"); 12 13 settings = mkOption { 14 description = lib.mdDoc '' 15 See https://torsion.org/borgmatic/docs/reference/configuration/ 16 ''; 17 type = types.submodule { 18 freeformType = settingsFormat.type; 19 options.location = { 20 source_directories = mkOption { 21 type = types.listOf types.str; 22 description = lib.mdDoc '' 23 List of source directories to backup (required). Globs and 24 tildes are expanded. 25 ''; 26 example = [ "/home" "/etc" "/var/log/syslog*" ]; 27 }; 28 repositories = mkOption { 29 type = types.listOf types.str; 30 description = lib.mdDoc '' 31 Paths to local or remote repositories (required). Tildes are 32 expanded. Multiple repositories are backed up to in 33 sequence. Borg placeholders can be used. See the output of 34 "borg help placeholders" for details. See ssh_command for 35 SSH options like identity file or port. If systemd service 36 is used, then add local repository paths in the systemd 37 service file to the ReadWritePaths list. 38 ''; 39 example = [ 40 "user@backupserver:sourcehostname.borg" 41 "user@backupserver:{fqdn}" 42 ]; 43 }; 44 }; 45 }; 46 }; 47 }; 48 49 config = mkIf cfg.enable { 50 51 environment.systemPackages = [ pkgs.borgmatic ]; 52 53 environment.etc."borgmatic/config.yaml".source = cfgfile; 54 55 systemd.packages = [ pkgs.borgmatic ]; 56 57 }; 58}