This commit is contained in:
Motiejus Jakštys 2023-09-23 22:56:23 +03:00
parent 70e5230611
commit 95c4f94a25
5 changed files with 53 additions and 14 deletions

View File

@ -14,6 +14,8 @@ rec {
borgstor = 504; borgstor = 504;
jakstpub = 505; jakstpub = 505;
certget = 506;
}; };
ports = { ports = {

View File

@ -72,6 +72,12 @@
silenceLogs = true; silenceLogs = true;
}; };
certget = {
enable = true;
uidgid = myData.uidgid.certget;
sshKeys = [myData.hosts."vno1-oh2.servers.jakst".publicKey];
};
borgstor = { borgstor = {
enable = true; enable = true;
dataDir = "/data/borg"; dataDir = "/data/borg";

View File

@ -0,0 +1,32 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.mj.services.certget;
in {
options.mj.services.certget = with lib.types; {
enable = lib.mkEnableOption "receive acme certs from somewhere";
uidgid = lib.mkOption {type = int;};
sshKeys = lib.mkOption {type = listOf str;};
};
config = lib.mkIf cfg.enable {
users.users.certget = {
description = "Cert Getter";
home = "/var/lib/certget";
shell = "/bin/sh";
group = "certget";
isSystemUser = true;
createHome = true;
uid = cfg.uidgid;
openssh.authorizedKeys.keys =
map (
k: "command=\"${pkgs.rrsync}/bin/rrsync /var/lib/certget\",restrict ${k}"
)
cfg.sshKeys;
};
users.groups.certget.gid = cfg.uidgid;
};
}

View File

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

View File

@ -118,20 +118,18 @@ in {
cfg = config.mj.services.deployerbot.follower; cfg = config.mj.services.deployerbot.follower;
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
users.users = { users.users.deployerbot-follower = {
deployerbot-follower = { description = "Deployerbot Follower";
description = "Deployerbot Follower"; home = "/var/lib/deployerbot-follower";
home = "/var/lib/deployerbot-follower"; shell = "/bin/sh";
shell = "/bin/sh"; group = "deployerbot-follower";
group = "deployerbot-follower"; extraGroups = ["wheel"];
extraGroups = ["wheel"]; isSystemUser = true;
isSystemUser = true; createHome = true;
createHome = true; uid = cfg.uidgid;
uid = cfg.uidgid; openssh.authorizedKeys.keys = let
openssh.authorizedKeys.keys = let restrictedPubKey = "from=\"${builtins.concatStringsSep "," cfg.sshAllowSubnets}\" " + cfg.publicKey;
restrictedPubKey = "from=\"${builtins.concatStringsSep "," cfg.sshAllowSubnets}\" " + cfg.publicKey; in [restrictedPubKey];
in [restrictedPubKey];
};
}; };
users.groups.deployerbot-follower.gid = cfg.uidgid; users.groups.deployerbot-follower.gid = cfg.uidgid;
nix.settings.trusted-users = ["deployerbot-follower"]; nix.settings.trusted-users = ["deployerbot-follower"];