dotfiles/modules/nixos/services/restic/default.nix

81 lines
1.8 KiB
Nix
Raw Normal View History

2025-11-22 03:14:50 -06:00
{
config,
flake,
pkgs,
...
}:
let
inherit (flake.config.services) instances;
inherit (flake.config.people) user0;
envFile = "backblaze/env";
repoFile = "backblaze/repo";
passFile = "restic-pass";
in
{
services.restic = {
backups = {
remote = {
environmentFile = config.sops.secrets.${envFile}.path;
initialize = true;
passwordFile = config.sops.secrets.${passFile}.path;
repositoryFile = config.sops.secrets.${repoFile}.path;
timerConfig = {
OnCalendar = "0/4:00";
Persistent = true;
};
2025-11-26 22:34:04 -06:00
paths =
let
instanceHelper = instance: instances.${instance}.mntPaths.path0;
in
[
"/home/${user0}/.ssh"
(instanceHelper "firefly-iii")
(instanceHelper "forgejo")
(instanceHelper "mastodon")
(instanceHelper "opencloud")
(instanceHelper "minecraft0")
(instanceHelper "minecraft1")
(instanceHelper "vaultwarden")
((instanceHelper "jellyfin") + "/cache")
((instanceHelper "jellyfin") + "/data")
((instanceHelper "jellyfin") + "/media/music")
];
2025-11-22 03:14:50 -06:00
};
};
};
sops = {
secrets = builtins.listToAttrs (
map
(secret: {
name = secret;
value = {
path = "/run/secrets/${secret}";
owner = "root";
group = "root";
mode = "0600";
};
})
[
envFile
repoFile
passFile
]
);
};
environment = {
variables = {
# AWS_ACCESS_KEY_ID = "";
# AWS_SECRET_ACCESS_KEY = "";
# RESTIC_PASSWORD_FILE = "pass.txt";
# RESTIC_REPOSITORY = "";
};
systemPackages = builtins.attrValues {
inherit (pkgs)
restic
;
};
};
}