summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/borg/default.nix')
-rw-r--r--hosts/vidhar/borg/default.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/hosts/vidhar/borg/default.nix b/hosts/vidhar/borg/default.nix
new file mode 100644
index 00000000..d338dfd6
--- /dev/null
+++ b/hosts/vidhar/borg/default.nix
@@ -0,0 +1,36 @@
1{ pkgs, lib, ... }:
2
3with lib;
4
5{
6 config = {
7 services.borgbackup.repos.borg = {
8 path = "/srv/backup/borg";
9 authorizedKeysAppendOnly = let
10 dir = ./authorized-keys;
11 toAuthKey = fname: ftype: if ftype != "regular" || !(hasSuffix ".pub" fname) then null else builtins.readFile (dir + "/${fname}");
12 in filter (v: v != null) (lib.mapAttrsToList toAuthKey (builtins.readDir dir));
13 };
14
15 boot.postBootCommands = mkBefore ''
16 ${pkgs.findutils}/bin/find /srv/backup/borg -maxdepth 1 -type d -empty -delete
17 '';
18
19 services.openssh.extraConfig = ''
20 Match User borg
21 ClientAliveInterval 10
22 ClientAliveCountMax 30
23
24 Match All
25 '';
26
27 sops.secrets.borg-passphrase = {
28 sopsFile = ./passphrase.yaml;
29 format = "yaml";
30 key = "borg";
31 owner = "borg";
32 group = "borg";
33 mode = "0440";
34 };
35 };
36}