ma backup/server: init backup server repo option

This commit is contained in:
makefu 2021-03-12 20:13:23 +01:00
parent e377be755f
commit ca37236a53
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -1,11 +1,19 @@
{lib, ... }:
{lib,config, ... }:
let
hosts = lib.mapAttrsToList (f: _: lib.removeSuffix ".pub" f) (builtins.readDir ./ssh );
in {
# TODO: for all enabled machines
services.borgbackup.repos = lib.genAttrs hosts (host: {
authorizedKeys = [ (builtins.readFile (./ssh + "/${host}.pub") ) ];
path = "/var/lib/borgbackup/${host}";
user = "borg-${host}";
}) ;
options = {
makefu.backup.server.repo = lib.mkOption {
type = lib.types.str;
default = "/var/lib/borgbackup";
};
};
config = {
services.borgbackup.repos = lib.genAttrs hosts (host: {
authorizedKeys = [ (builtins.readFile (./ssh + "/${host}.pub") ) ];
path = "${config.makefu.backup.server.repo}/${host}";
user = "borg-${host}";
}) ;
};
}