nixos/modules/restic-server/default.nix

41 lines
890 B
Nix
Raw Normal View History

2022-02-21 11:36:12 +01:00
{ inputs, custom, pkgs, ... }:
2022-01-27 19:32:05 +01:00
let
repository = "/mnt/restic-server";
2022-01-27 19:32:05 +01:00
in
{
environment.systemPackages = with pkgs; [
restic
];
2022-06-07 23:50:33 +02:00
fileSystems."${repository}" = {
device = "10.7.89.108:restic-server";
fsType = "nfs";
2022-06-14 20:44:21 +02:00
options = [ "noatime" "hard" "nfsvers=4.0" ];
};
2022-01-27 19:32:05 +01:00
services.restic.server = {
enable = true;
dataDir = repository;
extraFlags = [ "--no-auth" ];
};
2022-01-27 20:08:09 +01:00
networking.firewall.allowedTCPPorts = [ 8000 ];
2022-02-28 15:10:58 +01:00
2022-02-28 17:16:23 +01:00
systemd.services.restic-prune = {
2022-02-28 17:33:18 +01:00
serviceConfig = {
Type = "oneshot";
User = "restic";
};
2022-02-28 15:10:58 +01:00
script = ''
${pkgs.restic}/bin/restic \
--repo ${repository} \
2022-02-28 18:24:51 +01:00
--password-file "/etc/restic/restic.key" \
prune \
2022-02-28 15:10:58 +01:00
'';
};
2022-02-28 17:16:23 +01:00
systemd.timers.restic-prune = {
2022-02-28 15:10:58 +01:00
wantedBy = [ "timers.target" ];
2022-02-28 17:16:23 +01:00
partOf = [ "restic-prune.service" ];
2022-02-28 15:10:58 +01:00
timerConfig.OnCalendar = [ "*-*-* 12:00:00" ];
};
2022-01-27 19:32:05 +01:00
}