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;
|
2023-09-23 22:46:14 +03:00
|
|
|
shell = "/bin/sh";
|
2023-09-11 15:51:33 +03:00
|
|
|
group = "borgstor";
|
|
|
|
isSystemUser = true;
|
2024-12-06 07:44:33 +02:00
|
|
|
createHome = true;
|
2023-09-11 15:51:33 +03:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|