nix-infra/common/fragments/restic.nix

79 lines
2.2 KiB
Nix
Raw Normal View History

2023-10-04 12:58:29 +00:00
{ config, pkgs, ... }: {
nixpkgs.overlays = [
(final: prev: {
restic = let
version = "18f305243f885609c0b7994450aa83ebb8a14975";
src = pkgs.fetchFromGitHub {
owner = "AgathaSorceress";
repo = "restic";
rev = version;
hash = "sha256-gfbLbQy6CfoSlcycKOySLq7NwxvAAsTj01wfgJ+CA18=";
};
in prev.restic.override {
buildGoModule = args:
pkgs.buildGoModule (args // {
inherit src version;
vendorHash = "sha256-dILlGc4BzJQi/F7lNAnQHVC6TXRs/3POVvSeJzD4uLg=";
patches = [ ];
postPatch = "";
doCheck = false;
});
};
})
];
environment.systemPackages = [ pkgs.restic ];
services.restic.backups.${config.networking.hostName} = {
initialize = true;
repository = "rest:http://10.20.1.2:8000/${config.networking.hostName}/";
passwordFile = "/var/lib/secrets/restic-password";
environmentFile = "/var/lib/secrets/restic-env";
timerConfig = {
OnCalendar = "*-*-* 20:00"; # Daily at 20:00
Persistent = true;
};
paths = [ "/home/agatha" "/mnt/hdd" ];
exclude = [
".Trash*"
".gradle"
"/home/agatha/.XCompose"
"/home/agatha/.Xresources"
"/home/agatha/.cache"
"/home/agatha/.cargo"
"/home/agatha/.config"
"!/home/agatha/.config/gzdoom"
"/home/agatha/.gnupg"
"/home/agatha/.gtkrc-2.0"
"/home/agatha/.java"
"/home/agatha/.local"
"!/home/agatha/.local/share/PrismLauncher"
"/home/agatha/.manpath"
"/home/agatha/.minecraft"
"/home/agatha/.nix-defexpr"
"/home/agatha/.nix-profile"
"/home/agatha/.themes"
"/home/agatha/Desktop"
"/home/agatha/etc/deadname destruction"
"/home/agatha/go"
"/home/agatha/mount"
"/home/agatha/projects/java/**/build"
"/home/agatha/projects/mastodon"
"/home/agatha/projects/rust/**/target"
"/home/agatha/projects/rust/helix/runtime"
"/home/agatha/projects/snek/**/venv"
"__pycache__"
"lost+found"
];
pruneOpts = [ "--keep-daily 7" "--keep-weekly 5" "--keep-yearly 12" ];
};
systemd.timers."restic-backups-${config.networking.hostName}".after =
[ "network-online.target" ];
}