nixfiles/hosts/hetzner-vm/containers/piped/profiles/piped.nix

78 lines
1.9 KiB
Nix
Raw Normal View History

{config, ...}: let
2023-09-18 03:56:58 +01:00
ports = import ../data/ports.nix;
pipedConfig = config.services.piped;
in {
2023-09-18 03:56:58 +01:00
services.piped = {
enable = true;
frontendDomain = "piped-fi.owo.monster";
backendDomain = "backend.piped-fi.owo.monster";
proxyDomain = "proxy.piped-fi.owo.monster";
2023-08-01 22:06:30 +01:00
2023-09-18 03:56:58 +01:00
disableRegistrations = true;
2023-09-18 03:56:58 +01:00
# TODO: change these creds to be read from file before opening DB to firewall
postgresDBName = "piped";
postgresDBUsername = "piped";
postgresDBPassword = "piped";
postgresDBHost = "127.0.0.1";
postgresDBPort = 26257;
databaseDialect = "org.hibernate.dialect.CockroachDialect";
disablePostgresDB = true;
2023-09-14 19:44:27 +01:00
nginxForceSSL = false;
nginxEnableACME = false;
2023-08-01 22:06:30 +01:00
# Do not set proxyNginxExtraConfig here as needs be set in outside of container
2023-09-18 03:56:58 +01:00
internalBackendPort = ports.internal-piped-backend;
internalProxyPort = ports.internal-piped-proxy;
};
2023-09-18 03:56:58 +01:00
systemd.tmpfiles.rules = [
"d /var/sockets - nginx nginx"
];
2023-09-18 03:56:58 +01:00
systemd.services.nginx = {
serviceConfig.ReadWritePaths = [
"/var/sockets"
];
};
2023-09-18 03:56:58 +01:00
systemd.services.piped-backend = {
after = ["cockroachdb.service"];
wants = ["cockroachdb.service"];
};
2023-09-18 03:56:58 +01:00
services.nginx.virtualHosts = let
componentPath = component: "/var/sockets/piped-${component}.sock";
in {
"${pipedConfig.frontendDomain}" = {
listen = [
{
addr = "127.0.0.1";
port = 8091;
}
];
extraConfig = "listen unix:${componentPath "frontend"};";
};
"${pipedConfig.backendDomain}" = {
extraConfig = "listen unix:${componentPath "backend"};";
listen = [
{
addr = "127.0.0.1";
port = 8092;
}
];
};
"${pipedConfig.proxyDomain}" = {
extraConfig = "listen unix:${componentPath "proxy"};";
listen = [
{
addr = "127.0.0.1";
port = 8093;
}
];
};
};
}