2022-03-10 21:52:12 +01:00
|
|
|
{
|
2023-02-22 10:02:55 +01:00
|
|
|
config,
|
2022-03-10 21:52:12 +01:00
|
|
|
pkgs,
|
|
|
|
|
lib,
|
|
|
|
|
...
|
|
|
|
|
}: let
|
2023-02-22 10:02:55 +01:00
|
|
|
niveumLib = import ../../lib;
|
2022-01-18 23:28:53 +01:00
|
|
|
inherit (niveumLib) retiolumAddresses restic;
|
2022-01-18 21:29:30 +01:00
|
|
|
firewall = niveumLib.firewall lib;
|
2022-01-19 10:58:44 +01:00
|
|
|
dataDir = "/backup/restic";
|
2022-03-10 21:52:12 +01:00
|
|
|
in {
|
2022-01-18 21:29:30 +01:00
|
|
|
services.restic.server = {
|
|
|
|
|
enable = true;
|
|
|
|
|
appendOnly = true;
|
2022-01-19 10:58:44 +01:00
|
|
|
inherit dataDir;
|
2022-01-18 21:29:30 +01:00
|
|
|
prometheus = true;
|
2022-03-10 21:52:12 +01:00
|
|
|
extraFlags = ["--no-auth"]; # auth is done via firewall
|
2022-01-18 23:28:53 +01:00
|
|
|
listenAddress = ":${toString restic.port}";
|
2022-01-18 21:29:30 +01:00
|
|
|
};
|
|
|
|
|
|
2022-01-19 10:58:44 +01:00
|
|
|
environment.systemPackages = [
|
|
|
|
|
(pkgs.writers.writeDashBin "restic-niveum" ''
|
2023-02-22 10:02:55 +01:00
|
|
|
exec ${pkgs.util-linux}/bin/runuser -u restic -g restic -- ${pkgs.restic}/bin/restic -r ${toString dataDir} -p ${config.age.secrets.restic.path} "$@"
|
2022-01-19 10:58:44 +01:00
|
|
|
'')
|
|
|
|
|
];
|
|
|
|
|
|
2022-01-23 16:46:32 +01:00
|
|
|
fileSystems."/backup" = {
|
|
|
|
|
device = "/dev/disk/by-id/ata-ST500LM021-1KJ152_W626LS9M";
|
|
|
|
|
fsType = "ext4";
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
networking.firewall = let
|
2022-01-18 23:28:53 +01:00
|
|
|
dport = restic.port;
|
2022-01-18 21:29:30 +01:00
|
|
|
protocol = "tcp";
|
|
|
|
|
rules = [
|
2022-03-10 21:52:12 +01:00
|
|
|
(firewall.accept {
|
|
|
|
|
inherit dport protocol;
|
|
|
|
|
source = retiolumAddresses.kabsa.ipv4;
|
|
|
|
|
})
|
|
|
|
|
(firewall.accept {
|
|
|
|
|
inherit dport protocol;
|
|
|
|
|
source = retiolumAddresses.manakish.ipv4;
|
|
|
|
|
})
|
|
|
|
|
(firewall.accept {
|
|
|
|
|
inherit dport protocol;
|
|
|
|
|
source = retiolumAddresses.makanek.ipv4;
|
|
|
|
|
})
|
2024-04-02 22:03:03 +02:00
|
|
|
(firewall.accept {
|
|
|
|
|
inherit dport protocol;
|
|
|
|
|
source = retiolumAddresses.fatteh.ipv4;
|
|
|
|
|
})
|
2023-02-16 08:52:54 +01:00
|
|
|
(firewall.accept {
|
|
|
|
|
inherit dport protocol;
|
|
|
|
|
source = retiolumAddresses.ful.ipv4;
|
|
|
|
|
})
|
2022-01-18 21:29:30 +01:00
|
|
|
];
|
|
|
|
|
in {
|
|
|
|
|
extraCommands = firewall.addRules rules;
|
|
|
|
|
extraStopCommands = firewall.removeRules rules;
|
|
|
|
|
};
|
|
|
|
|
}
|