2025-10-01 19:51:55 -05:00
|
|
|
{ config, flake, ... }:
|
|
|
|
|
let
|
2025-10-25 05:16:26 -05:00
|
|
|
inherit (flake.config.services.instances) opencloud web caddy;
|
2025-10-01 19:51:55 -05:00
|
|
|
service = opencloud;
|
2025-10-25 05:16:26 -05:00
|
|
|
localhost = web.localhost.address1;
|
2025-10-01 19:51:55 -05:00
|
|
|
host = service.domains.url0;
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
services = {
|
|
|
|
|
opencloud = {
|
|
|
|
|
enable = true;
|
2025-10-25 05:16:26 -05:00
|
|
|
url = "http://${localhost}:${toString service.ports.port0}";
|
2025-10-01 19:51:55 -05:00
|
|
|
port = service.ports.port0;
|
|
|
|
|
address = localhost;
|
|
|
|
|
stateDir = "/var/lib/${service.name}";
|
|
|
|
|
environmentFile = config.sops.secrets."${service.name}/env".path;
|
|
|
|
|
};
|
|
|
|
|
caddy = {
|
|
|
|
|
virtualHosts = {
|
2025-10-25 05:16:26 -05:00
|
|
|
":${toString caddy.ports.port4}" = {
|
2025-10-01 19:51:55 -05:00
|
|
|
extraConfig = ''
|
2025-10-25 05:16:26 -05:00
|
|
|
reverse_proxy http://${localhost}:${toString service.ports.port0}
|
2025-10-01 19:51:55 -05:00
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
sops =
|
|
|
|
|
let
|
|
|
|
|
sopsPath = secret: {
|
|
|
|
|
path = "${service.sops.path0}/${service.name}-${secret}";
|
|
|
|
|
owner = service.name;
|
|
|
|
|
mode = "600";
|
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
secrets = builtins.listToAttrs (
|
|
|
|
|
map
|
|
|
|
|
(secret: {
|
|
|
|
|
name = "${service.name}/${secret}";
|
|
|
|
|
value = sopsPath secret;
|
|
|
|
|
})
|
|
|
|
|
[
|
|
|
|
|
"env"
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-25 05:16:26 -05:00
|
|
|
systemd = {
|
|
|
|
|
tmpfiles.rules = [
|
|
|
|
|
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-01 19:51:55 -05:00
|
|
|
networking = {
|
|
|
|
|
firewall = {
|
|
|
|
|
allowedTCPPorts = [
|
|
|
|
|
service.ports.port0
|
2025-10-25 05:16:26 -05:00
|
|
|
caddy.ports.port4
|
2025-10-01 19:51:55 -05:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|