nix-config/modules/restic/default.nix
2026-03-10 19:58:21 +01:00

54 lines
1.3 KiB
Nix

{ inputs, ... }:
{
flake.modules.nixos.restic =
{
pkgs,
config,
lib,
...
}:
{
options.restic = {
repository = lib.mkOption {
type = lib.types.str;
description = "The repository name to back up to";
};
backupPaths = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "List of paths to back up";
};
};
# Root SSH for storage box
programs.ssh = {
extraConfig = ''
Host dnsc-storage
AddKeysToAgent yes
Hostname u295965.your-storagebox.de
User u295965
IdentityFile /root/.ssh/id_ed25519
IdentitiesOnly yes
Port 23
'';
};
services.restic.backups = {
"dnsc-storage" = {
initialize = true;
passwordFile = config.age.secrets."restic/password".path;
repository = config.restic.repository;
createWrapper = true;
paths = config.restic.backupPaths;
pruneOpts = [
"--keep-last 3"
];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
RandomizedDelaySec = "5h";
};
};
};
};
}