{ flake.modules.homeManager.borgmatic = { config , osConfig , pkgs , lib , ... }: let hostname = osConfig.networking.hostName; username = config.home.username; in { home.packages = with pkgs; [ libnotify borgmatic ]; programs.borgmatic = { enable = true; backups.default = { location = { repositories = [ { label = "duke"; path = "ssh://borg@duke.veltnet:2222/home/borg/backups/${hostname}-${username}"; } ]; excludeHomeManagerSymlinks = true; patterns = [ #TODO: home.homeDirectory might be usable here #TODO: should be user and machine specific "R /home/${username}" "+ /home/${username}/.ssh" "- /home/${username}/.*" "- **/node_modules" "- **/.cache" "- **/*build" "- **/target" "- **/.venv" "- **/venv" "- **/.gradle" "- **/out" "- **/dist" "- **/.pio" ]; extraConfig.exclude_if_present = [ ".borgignore" ]; }; retention.keepWeekly = 2; storage.extraConfig.ssh_command = "ssh -i /home/${username}/.ssh/id_ed25519_borg"; #FIXME: consistency checks!!! }; }; #TODO: there is a services.borgmatic systemd.user.services.borgmatic = { Unit.Description = "Create a backup using borgmatic"; Service.ExecStart = "${pkgs.borgmatic}/bin/borgmatic create --stats"; }; systemd.user.timers.borgmatic = { Unit.Description = "Create weekly backups using borgmatic"; Timer = { OnCalendar = "Weekly"; Persistent = true; }; Install.WantedBy = [ "timers.target" ]; }; }; }