diff --git a/module.nix b/module.nix index 153ae14..9fb1661 100644 --- a/module.nix +++ b/module.nix @@ -13,20 +13,46 @@ in hostName = mkOption { type = types.str; description = '' - Name for the nginx virtual host. + Name for the virtual host for the web server. ''; example = "example.org"; }; + + server = mkOption { + type = types.enum [ "nginx" "caddy" ]; + description = '' + The web server to be used for serving Financier. Either "nginx" + or "caddy". + ''; + default = "caddy"; + example = "example.org"; + }; }; config = mkIf cfg.enable { networking.firewall.allowedTCPPorts = [ 80 443 ]; - services.nginx.virtualHosts."${cfg.hostName}" = { - forceSSL = true; - enableACME = true; - root = financier-dist; - locations."/".tryFiles = "$uri $uri/ /index.html"; + services.nginx = mkIf (cfg.server == "nginx") { + enable = true; + + virtualHosts."${cfg.hostName}" = { + forceSSL = true; + enableACME = true; + root = financier-dist; + locations."/".tryFiles = "$uri $uri/ /index.html"; + }; + }; + + services.caddy = mkIf (cfg.server == "caddy") { + enable = true; + + config = '' + ${cfg.hostName} { + root * ${financier-dist} + file_server + try_files {path} {path}/ /index.html + } + ''; }; }; }