mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-07-04 18:45:00 -05:00
77 lines
1.7 KiB
Nix
77 lines
1.7 KiB
Nix
{ config, flake, ... }:
|
|
let
|
|
inherit (flake.config.services.instances) podgrab web;
|
|
inherit (flake.config.machines.devices) ceres;
|
|
service = podgrab;
|
|
localhost = web.localhost.address0;
|
|
host = service.domains.url0;
|
|
in
|
|
{
|
|
services = {
|
|
podgrab = {
|
|
enable = true;
|
|
port = service.ports.port0;
|
|
passwordFile = config.sops.secrets."${service.name}-pass".path;
|
|
dataDirectory = service.paths.path0;
|
|
};
|
|
caddy = {
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
extraConfig = ''
|
|
redir /.well-known/carddav /remote.php/dav/ 301
|
|
redir /.well-known/caldav /remote.php/dav/ 301
|
|
|
|
reverse_proxy ${localhost}:${toString service.ports.port0}
|
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
sops =
|
|
let
|
|
sopsPath = secret: {
|
|
path = "${service.sops.path0}/password.env";
|
|
owner = service.name;
|
|
mode = "600";
|
|
};
|
|
in
|
|
{
|
|
secrets = builtins.listToAttrs (
|
|
map
|
|
(secret: {
|
|
name = "${service.name}-${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
[
|
|
"pass"
|
|
]
|
|
);
|
|
};
|
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
device = service.paths.path0;
|
|
fsType = "none";
|
|
options = [
|
|
"bind"
|
|
];
|
|
depends = [
|
|
ceres.storage0.mount
|
|
];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"Z ${service.paths.path0} 0755 ${service.name} ${service.name} -"
|
|
"Z ${service.sops.path0} 0755 ${service.name} ${service.name} -"
|
|
];
|
|
|
|
networking = {
|
|
firewall = {
|
|
allowedTCPPorts = [
|
|
service.ports.port0
|
|
];
|
|
};
|
|
};
|
|
}
|