os/hosts/giggles/tang-container.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.2 KiB
Nix
Raw Normal View History

{
pkgs,
config,
...
}: let
2023-01-28 21:30:37 +00:00
containerStateDir = "/data";
hostStateDir = "/opt/tangd";
servicePort = 8081;
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;
};
config = {
config,
pkgs,
...
}: {
2023-01-28 21:30:37 +00:00
networking.firewall.enable = false;
users.groups."_tang" = {};
2023-01-28 21:30:37 +00:00
users.users."_tang" = {
group = "_tang";
isSystemUser = true;
};
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;
listenStreams = ["${toString servicePort}"];
wantedBy = ["sockets.target"];
2023-01-28 21:30:37 +00:00
socketConfig = {
Accept = true;
};
};
system.stateVersion = "22.11";
};
};
}