2023-10-01 20:23:58 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2023-01-28 21:30:37 +00:00
|
|
|
containerStateDir = "/data";
|
|
|
|
hostStateDir = "/opt/tangd";
|
|
|
|
servicePort = 8081;
|
2023-10-01 20:23:58 +00:00
|
|
|
in {
|
|
|
|
networking.firewall.allowedTCPPorts = [servicePort];
|
2023-01-28 21:30:37 +00:00
|
|
|
|
|
|
|
containers."tang" = {
|
|
|
|
autoStart = true;
|
|
|
|
ephemeral = true;
|
|
|
|
bindMounts."${containerStateDir}" = {
|
|
|
|
hostPath = hostStateDir;
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
|
2023-10-01 20:23:58 +00:00
|
|
|
config = {
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
2023-01-28 21:30:37 +00:00
|
|
|
networking.firewall.enable = false;
|
|
|
|
|
2023-10-01 20:23:58 +00:00
|
|
|
users.groups."_tang" = {};
|
2023-01-28 21:30:37 +00:00
|
|
|
|
|
|
|
users.users."_tang" = {
|
|
|
|
group = "_tang";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
|
2023-10-01 20:23:58 +00:00
|
|
|
environment.systemPackages = with pkgs; [jose tang];
|
2023-01-28 21:30:37 +00:00
|
|
|
|
|
|
|
systemd.services."tangd@" = {
|
|
|
|
enable = true;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStartPre = "${pkgs.bash}/bin/bash -c \"mkdir -p ${containerStateDir}/tang-db\"";
|
|
|
|
ExecStart = "${pkgs.tang}/libexec/tangd ${containerStateDir}/tang-db";
|
|
|
|
User = "_tang";
|
|
|
|
Group = "_tang";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.sockets."tangd" = {
|
|
|
|
enable = true;
|
2023-10-01 20:23:58 +00:00
|
|
|
listenStreams = ["${toString servicePort}"];
|
|
|
|
wantedBy = ["sockets.target"];
|
2023-01-28 21:30:37 +00:00
|
|
|
socketConfig = {
|
|
|
|
Accept = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
system.stateVersion = "22.11";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|