{ flake, config, ... }: let inherit (flake.config.people) user0; inherit (flake.config.people.users.${user0}) email; inherit (flake.config.services.instances) firefly web; inherit (flake.config.machines.devices) ceres; service = firefly; localhost = web.localhost.address0; host = service.domains.url0; in { services = { firefly-iii = { enable = true; virtualHost = host; settings = { APP_URL = host; APP_KEY_FILE = config.sops.secrets."${service.name}-key".path; SITE_OWNER = email.address0; # DB_PORT = 3306; DB_DATABASE = "firefly"; DB_USERNAME = "firefly"; DB_PASSWORD_FILE = config.sops.secrets."${service.name}-pass".path; }; }; 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}/${service.name}-${secret}"; owner = service.name; mode = "600"; }; in { secrets = builtins.listToAttrs ( map (secret: { name = "${service.name}-${secret}"; value = sopsPath secret; }) [ "key" "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} 755 ${service.name} ${service.name} -" "Z ${service.sops.path0} 755 ${service.name} ${service.name} -" ]; networking = { firewall = { allowedTCPPorts = [ service.ports.port0 ]; }; }; }