add borgstor

This commit is contained in:
Motiejus Jakštys 2023-09-11 15:51:33 +03:00
parent 377030d0c0
commit 866347b042
5 changed files with 43 additions and 2 deletions

View File

@ -10,6 +10,8 @@ rec {
# "upstream" user. We need a way to configure the uidgid, # "upstream" user. We need a way to configure the uidgid,
# so creating users explicitly. # so creating users explicitly.
node_exporter = 503; node_exporter = 503;
borgstor = 504;
}; };
ports = { ports = {

View File

@ -449,7 +449,6 @@
inotify = "yes"; inotify = "yes";
}; };
}; };
}; };
systemd.services = { systemd.services = {

View File

@ -20,7 +20,7 @@
boot.loader.grub.enable = false; boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true; boot.loader.generic-extlinux-compatible.enable = true;
boot.supportedFilesystems = [ "zfs" ]; boot.supportedFilesystems = ["zfs"];
boot.zfs.forceImportRoot = false; boot.zfs.forceImportRoot = false;
powerManagement.cpuFreqGovernor = "ondemand"; powerManagement.cpuFreqGovernor = "ondemand";
@ -62,6 +62,12 @@
services = { services = {
node_exporter.enable = true; node_exporter.enable = true;
borgstor = {
enable = true;
dataDir = "/data/borg";
sshKeys = [myData.hosts."vno1-oh2.servers.jakst".publicKey];
};
postfix = { postfix = {
enable = true; enable = true;
saslPasswdPath = config.age.secrets.sasl-passwd.path; saslPasswdPath = config.age.secrets.sasl-passwd.path;

View File

@ -0,0 +1,33 @@
{
config,
lib,
myData,
pkgs,
...
}: {
options.mj.services.borgstor = with lib.types; {
enable = lib.mkEnableOption "Enable borg storage user";
dataDir = lib.mkOption {type = path;};
sshKeys = lib.mkOption {type = listOf str;};
};
config = with config.mj.services.borgstor;
lib.mkIf enable {
users.users.borgstor = {
description = "Borg Storage";
home = dataDir;
useDefaultShell = true;
group = "borgstor";
isSystemUser = true;
createHome = false;
uid = myData.uidgid.borgstor;
openssh.authorizedKeys.keys =
map (
k: "command=\"${pkgs.borgbackup}/bin/borg serve --restrict-to-path ${dataDir}\",restrict ${k}"
)
sshKeys;
};
users.groups.borgstor.gid = myData.uidgid.borgstor;
};
}

View File

@ -5,6 +5,7 @@
... ...
}: { }: {
imports = [ imports = [
./borgstor
./deployerbot ./deployerbot
./friendlyport ./friendlyport
./gitea ./gitea