summaryrefslogtreecommitdiff
path: root/nixos/modules/homelab/core/restic.nix
blob: 7315632c9e7142ef9fed222c11bbd8562c6c69fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ config, lib, pkgs, ... }: let
  cfg = config.homelab.core.restic;
in {
  options.homelab.core.restic = {
    enable = lib.mkEnableOption "restic";
    passwordFile = lib.mkOption {
      description = "restic password file";
      type = lib.types.path;
    };
  };
  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ pkgs.restic ];
    services.restic.backups = let
      defaultPruneOpts = [
        "--keep-daily 7"
        "--keep-weekly 4"
        "--keep-monthly 6"
      ];
    in {
      syncthing = {
        initialize = true;
        paths = [
          "/home/server/Sync"
        ];
        repository = "/srv/backups/syncthing";
        pruneOpts = defaultPruneOpts;
        passwordFile = cfg.passwordFile;
      };
    };
  };
}