clanModules/borgbackup: make backup directory configurable

This is useful if your have external storage for it.
This commit is contained in:
Jörg Thalheim
2024-12-19 20:13:32 +01:00
parent ab44967490
commit b9e47844d9

View File

@@ -22,6 +22,15 @@ let
) [ ] instances; ) [ ] instances;
in in
{ {
options = {
clan.borgbackup.directory = lib.mkOption {
type = lib.types.str;
default = "/var/lib/borgbackup";
description = ''
The directory where the borgbackup repositories are stored.
'';
};
};
config.services.borgbackup.repos = config.services.borgbackup.repos =
let let
borgbackupIpMachinePath = machines: machineDir + machines + "/facts/borgbackup.ssh.pub"; borgbackupIpMachinePath = machines: machineDir + machines + "/facts/borgbackup.ssh.pub";
@@ -44,7 +53,7 @@ in
hosts = builtins.map (machine: { hosts = builtins.map (machine: {
name = machine; name = machine;
value = { value = {
path = "/var/lib/borgbackup/${machine}"; path = "${config.clan.borgbackup.directory}/${machine}";
authorizedKeys = [ (builtins.readFile (borgbackupIpMachinePath machine)) ]; authorizedKeys = [ (builtins.readFile (borgbackupIpMachinePath machine)) ];
}; };
}) machinesWithKey; }) machinesWithKey;