summaryrefslogtreecommitdiff
path: root/hosts/surtr/borg.nix
blob: b9fe53d75473bd38b4181e34d6a4127a8d4fea86 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ lib, config, ... }:

with lib;

{
  config = {
    services.borgsnap = {
      enable = true;
      target = "borg.vidhar:.";

      extraConfig = mkForce {
        daily = "31";
        monthly = "-1";
      };

      sshConfig = ''
        Include /etc/ssh/ssh_config

        ControlMaster auto
        ControlPath /var/lib/borg/.borgssh-master-%r@%n:%p
        ControlPersist yes

        Host borg.vidhar
          HostName vidhar.yggdrasil.li
          User borg
          IdentityFile ${config.sops.secrets."append.borg.vidhar".path}
          IdentitiesOnly yes

          BatchMode yes
          ServerAliveInterval 10
          ServerAliveCountMax 30
      '';
    };

    sops.secrets."append.borg.vidhar" = {
      format = "binary";
      sopsFile = ../vidhar/borg/jotnar/surtr;
      owner = "borg";
      group = "borg";
      mode = "0400";
    };

    users.users.borg = {
      useDefaultShell = true;
      isSystemUser = true;
      group = "borg";
    };
    users.groups.borg = {};
  };
}