fix borg-server

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

View File

@ -6,6 +6,7 @@
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
../../modules/services/nextcloud-instance.nix ../../modules/services/nextcloud-instance.nix
../../modules/services/borg-server.nix
]; ];
# Secret management # Secret management
@ -53,7 +54,7 @@
services.nextcloud-instance.instanceFQDN = "nextcloud.jroeger.de"; services.nextcloud-instance.instanceFQDN = "nextcloud.jroeger.de";
services.borg-server.enable = true; services.borg-server.enable = true;
services.borg-server.repositories.comfy-station.ssh_public_key = builtins.readFile (../../static/keys/ + "borg-jonas@comfy-station.pub"); services.borg-server.repositories.comfy-station.ssh_public_key = builtins.readFile (../../static/keys + "/borg-jonas@comfy-station.pub");
# Allow unfree packages # Allow unfree packages
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;

View File

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