config/modules/services/borgstor/default.nix

34 lines
820 B
Nix
Raw Permalink Normal View History

2023-09-11 15:51:33 +03:00
{
config,
lib,
myData,
pkgs,
...
2024-07-29 15:39:54 +03:00
}:
{
2023-09-11 15:51:33 +03:00
options.mj.services.borgstor = with lib.types; {
enable = lib.mkEnableOption "Enable borg storage user";
2024-07-29 15:39:54 +03:00
dataDir = lib.mkOption { type = path; };
sshKeys = lib.mkOption { type = listOf str; };
2023-09-11 15:51:33 +03:00
};
2024-07-29 15:39:54 +03:00
config =
with config.mj.services.borgstor;
2023-09-11 15:51:33 +03:00
lib.mkIf enable {
users.users.borgstor = {
description = "Borg Storage";
home = dataDir;
shell = "/bin/sh";
2023-09-11 15:51:33 +03:00
group = "borgstor";
isSystemUser = true;
createHome = false;
uid = myData.uidgid.borgstor;
2024-07-29 15:39:54 +03:00
openssh.authorizedKeys.keys = map (
k: ''command="${pkgs.borgbackup}/bin/borg serve --restrict-to-path ${dataDir}",restrict ${k}''
) sshKeys;
2023-09-11 15:51:33 +03:00
};
users.groups.borgstor.gid = myData.uidgid.borgstor;
};
}