diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..153ae14 --- /dev/null +++ b/module.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, system, ... }: +with lib; +let + cfg = config.services.financier; + financier-dist = import ./dist.nix { inherit pkgs system; }; +in +{ + imports = []; + + options.services.financier = { + enable = mkEnableOption "Financier"; + + hostName = mkOption { + type = types.str; + description = '' + Name for the nginx virtual host. + ''; + 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"; + }; + }; +}