2025-07-07 14:04:06 -05:00
|
|
|
{ config, flake, ... }:
|
2025-07-07 13:35:12 -05:00
|
|
|
let
|
|
|
|
inherit (flake.config.machines.devices) ceres;
|
|
|
|
inherit (flake.config.services.instances) opencloud web;
|
|
|
|
service = opencloud;
|
|
|
|
localhost = web.localhost.address1;
|
|
|
|
host = service.domains.url0;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services = {
|
|
|
|
opencloud = {
|
|
|
|
enable = true;
|
2025-07-07 14:39:12 -05:00
|
|
|
url = "https://${host}:${builtins.toString service.ports.port0}";
|
2025-07-07 13:42:03 -05:00
|
|
|
port = service.ports.port0;
|
2025-07-07 13:35:12 -05:00
|
|
|
address = localhost;
|
|
|
|
stateDir = "/var/lib/${service.name}";
|
|
|
|
environment = {
|
2025-07-07 14:39:12 -05:00
|
|
|
OC_INSECURE = "true";
|
2025-07-07 13:35:12 -05:00
|
|
|
};
|
2025-07-07 14:04:06 -05:00
|
|
|
environmentFile = config.sops.secrets."${service.name}-pass".path;
|
2025-07-07 13:35:12 -05:00
|
|
|
};
|
|
|
|
caddy = {
|
|
|
|
virtualHosts = {
|
|
|
|
"${host}" = {
|
|
|
|
extraConfig = ''
|
2025-07-07 14:35:03 -05:00
|
|
|
reverse_proxy ${localhost}:${toString service.ports.port0}
|
2025-07-07 13:35:12 -05:00
|
|
|
|
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2025-07-07 14:04:06 -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;
|
|
|
|
})
|
|
|
|
[
|
2025-07-07 14:09:12 -05:00
|
|
|
"pass"
|
2025-07-07 14:04:06 -05:00
|
|
|
]
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-07-07 13:35:12 -05:00
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
|
|
device = service.paths.path0;
|
|
|
|
fsType = "none";
|
|
|
|
options = [
|
|
|
|
"bind"
|
|
|
|
];
|
|
|
|
depends = [
|
|
|
|
ceres.storage0.mount
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
2025-07-07 14:18:07 -05:00
|
|
|
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
2025-07-07 13:35:12 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
service.ports.port0
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|