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
|
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
|
2025-12-25 14:00:03 +01:00
|
|
|
listenAddress = toString pkgs.lib.niveum.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" = {
|
2024-04-25 08:45:08 +02:00
|
|
|
device = "/dev/disk/by-id/ata-WDC_WD10JPVX-22JC3T0_WD-WXD1E5510MKW";
|
2022-01-23 16:46:32 +01:00
|
|
|
fsType = "ext4";
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
networking.firewall = let
|
2025-12-25 14:00:03 +01:00
|
|
|
dport = pkgs.lib.niveum.restic.port;
|
2022-01-18 21:29:30 +01:00
|
|
|
protocol = "tcp";
|
|
|
|
|
rules = [
|
2025-12-25 14:00:03 +01:00
|
|
|
(pkgs.lib.niveum.firewall.accept {
|
2022-03-10 21:52:12 +01:00
|
|
|
inherit dport protocol;
|
2025-12-25 14:00:03 +01:00
|
|
|
source = pkgs.lib.niveum.retiolumAddresses.kabsa.ipv4;
|
2022-03-10 21:52:12 +01:00
|
|
|
})
|
2025-12-25 14:00:03 +01:00
|
|
|
(pkgs.lib.niveum.firewall.accept {
|
2022-03-10 21:52:12 +01:00
|
|
|
inherit dport protocol;
|
2025-12-25 14:00:03 +01:00
|
|
|
source = pkgs.lib.niveum.retiolumAddresses.manakish.ipv4;
|
2022-03-10 21:52:12 +01:00
|
|
|
})
|
2025-12-25 14:00:03 +01:00
|
|
|
(pkgs.lib.niveum.firewall.accept {
|
2022-03-10 21:52:12 +01:00
|
|
|
inherit dport protocol;
|
2025-12-25 14:00:03 +01:00
|
|
|
source = pkgs.lib.niveum.retiolumAddresses.makanek.ipv4;
|
2022-03-10 21:52:12 +01:00
|
|
|
})
|
2025-12-25 14:00:03 +01:00
|
|
|
(pkgs.lib.niveum.firewall.accept {
|
2024-04-02 22:03:03 +02:00
|
|
|
inherit dport protocol;
|
2025-12-25 14:00:03 +01:00
|
|
|
source = pkgs.lib.niveum.retiolumAddresses.fatteh.ipv4;
|
2024-04-02 22:03:03 +02:00
|
|
|
})
|
2025-12-25 14:00:03 +01:00
|
|
|
(pkgs.lib.niveum.firewall.accept {
|
2023-02-16 08:52:54 +01:00
|
|
|
inherit dport protocol;
|
2025-12-25 14:00:03 +01:00
|
|
|
source = pkgs.lib.niveum.retiolumAddresses.ful.ipv4;
|
2023-02-16 08:52:54 +01:00
|
|
|
})
|
2022-01-18 21:29:30 +01:00
|
|
|
];
|
|
|
|
|
in {
|
2025-12-25 14:00:03 +01:00
|
|
|
extraCommands = pkgs.lib.niveum.firewall.addRules rules;
|
|
|
|
|
extraStopCommands = pkgs.lib.niveum.firewall.removeRules rules;
|
2022-01-18 21:29:30 +01:00
|
|
|
};
|
|
|
|
|
}
|