From b8ff16e98a7fa3f840ff3d9bb7345060c701d829 Mon Sep 17 00:00:00 2001 From: Martin Puppe Date: Tue, 15 Sep 2020 11:13:24 +0200 Subject: [PATCH] Add NixOS module This module adds the necessary configuration for hosting Financier with nginx. --- module.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 module.nix 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"; + }; + }; +}