fix borg-server

This commit is contained in:
2025-04-06 22:40:24 +02:00
parent 0f1eba14b6
commit 2f1b912aa3
2 changed files with 13 additions and 6 deletions

View File

@@ -8,6 +8,12 @@
in {
options.services.borg-server = {
enable = lib.mkEnableOption "Enable the borg server";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.borgbackup;
example = "pkgs.borgbackup";
description = "The borg package to use";
};
borg_user = lib.mkOption {
type = lib.types.str;
example = "borg";
@@ -25,6 +31,7 @@ in {
options = {
name = lib.mkOption {
type = lib.types.nullOr (lib.types.strMatching "^[a-zA-Z0-9._-]+$");
default = null;
example = "borg-repo";
description = "The name of the borg repository. If null, use key of attrset";
};
@@ -45,11 +52,10 @@ in {
home = cfg.repositories_path;
createHome = true;
extraGroups = ["borg"];
openSSH.authorizedKeys.keys = builtins.attrValues (
builtins.mapAttrs
(key: repo: "command=\"${pkgs.borg}/bin/borg serve --restrict-to-path=${cfg.repositories_path}/${repo.name or key}\", restrict ${repo.ssh_public_key}")
cfg.repositories
);
openssh.authorizedKeys.keys =
lib.attrsets.mapAttrsToList
(key: repo: "command=\"${cfg.package}/bin/borg serve --restrict-to-path=${cfg.repositories_path}/${lib.defaultTo key repo.name}\", restrict ${repo.ssh_public_key}")
cfg.repositories;
};
};
}