1
0
Fork 0

add(acme,nginx): add certificate generation and nginx for the services

This replaces caddy and the port exposure, this is more efficent and
easier to manage in the future.
This commit is contained in:
Philipp 2025-05-25 00:32:54 +02:00
parent 7dd87536aa
commit 5792e478af
Signed by: Philipp
GPG key ID: 9EBD8439AFBAB750
9 changed files with 244 additions and 74 deletions

View file

@ -20,28 +20,41 @@ in
default = pkgs.awesome-flake.ente-web-auth;
};
port = mkOption {
description = "The port to serve Ente-Auth on.";
type = types.nullOr types.int;
default = 1338;
domain = mkOption {
description = "The domain to serve ente-auth on.";
type = types.nullOr types.str;
default = "ente.stahl.sh";
};
nginx = {
enable = mkEnableOption {
description = "Enable nginx for this service.";
type = types.bool;
default = true;
};
};
};
config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [
cfg.port
networking.firewall.allowedTCPPorts = mkIf cfg.nginx.enable [
80
443
];
services.caddy = {
awesome-flake.services.acme.enable = mkIf cfg.nginx.enable true;
services.nginx = mkIf cfg.nginx.enable {
enable = true;
virtualHosts = {
":${builtins.toString cfg.port}" = {
extraConfig = ''
root * ${cfg.package}
file_server
'';
virtualHosts."${cfg.domain}" = {
forceSSL = true;
useACMEHost = "stahl.sh";
locations."/" = {
root = "${cfg.package}";
};
};
};
};
}