dotfiles/nixos/modules/services/upRootNutrition.nix
2024-12-20 00:34:07 -06:00

36 lines
951 B
Nix
Executable file

{flake, ...}: let
inherit (flake.config.machines.devices) server;
inherit (flake.config.services.instances) upRootNutrition web;
service = upRootNutrition;
localhost = web.localhost.address0;
host = web.domains.url3;
in {
services = {
caddy = {
virtualHosts = {
"${host}" = {
extraConfig = ''
root * /var/lib/website/dist/index.html
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}
'';
};
};
};
};
fileSystems."${service.paths.path0}" = {
device = service.paths.path0;
fsType = "none";
options = ["bind"];
depends = [server.storage0.mount];
};
systemd.tmpfiles.rules = [
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
];
}