mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-17 10:35:13 -05:00
102 lines
2.3 KiB
Nix
Executable file
102 lines
2.3 KiB
Nix
Executable file
{
|
|
flake,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (flake.config.people) user0;
|
|
inherit (flake.config.people.user.${user0}) domain email;
|
|
inherit (flake.config.system.device) server wildcard;
|
|
inherit (flake.config.service.instance.castopod) paths ports subdomain name sops ssl;
|
|
inherit (flake.config.service.instance) nginx;
|
|
localhost = wildcard.ip.address0;
|
|
host = "${subdomain}.${domain.url1}";
|
|
in {
|
|
services = {
|
|
castopod = {
|
|
enable = true;
|
|
localDomain = host;
|
|
configureNginx = false;
|
|
environmentFile = config.sops.secrets."${name}-smtp".path;
|
|
maxUploadSize = "1024M";
|
|
database = {
|
|
createLocally = true;
|
|
# passwordFile = config.sops.secrets."${name}-database".path;
|
|
};
|
|
poolSettings = {
|
|
pm = "dynamic";
|
|
"pm.max_children" = "32";
|
|
"pm.max_requests" = "500";
|
|
"pm.max_spare_servers" = "4";
|
|
"pm.min_spare_servers" = "2";
|
|
"pm.start_servers" = "2";
|
|
};
|
|
settings = {
|
|
"email.fromEmail" = email.address6;
|
|
"email.protocol" = "smtp";
|
|
"email.SMTPHost" = localhost;
|
|
"email.SMTPPort" = 587;
|
|
"email.SMTPUser" = "smtp.protonmail.ch";
|
|
};
|
|
};
|
|
|
|
nginx = {
|
|
enable = true;
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
};
|
|
};
|
|
};
|
|
|
|
caddy = {
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
extraConfig = ''
|
|
reverse_proxy ${localhost}:${toString ports.port0}
|
|
|
|
tls ${ssl.cert} ${ssl.key}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
sops = let
|
|
sopsSecrets = ["smtp" "database"];
|
|
sopsPath = secret: {
|
|
path = "${sops.path0}/${name}-${secret}";
|
|
owner = name;
|
|
mode = "600";
|
|
};
|
|
in {
|
|
secrets = builtins.listToAttrs (
|
|
map
|
|
(secret: {
|
|
name = "${name}-${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
sopsSecrets
|
|
);
|
|
};
|
|
|
|
fileSystems."/var/lib/${name}" = {
|
|
device = paths.path0;
|
|
fsType = "none";
|
|
options = ["bind"];
|
|
depends = [server.storage0.mount];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"Z ${paths.path0} 755 ${name} ${name} -"
|
|
"Z ${sops.path0} 755 ${name} ${name} -"
|
|
];
|
|
|
|
networking = {
|
|
firewall = {
|
|
allowedTCPPorts = [
|
|
ports.port0
|
|
nginx.ports.port0
|
|
];
|
|
};
|
|
};
|
|
users.groups.nginx = {};
|
|
}
|