aboutsummaryrefslogtreecommitdiff
path: root/modules/nixos/services/web/status/default.nix
blob: b5a949fc3c0356bf3c5485893fae1fbf4bc25232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ options, config, lib, pkgs, namespace, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.services.web.status;
  impermanence = config.${namespace}.system.impermanence;
in {
  options.${namespace}.services.web.status = with types; {
    enable = mkEnableOption "status webserver";
  };

  config = mkIf cfg.enable {
    cxl.services.web.enable = true;

    environment.persistence.${impermanence.location} = {
      directories = [
        "/srv/web/status"
      ];
    };

    networking.firewall.allowedTCPPorts = [ 80 443 ];
    
    services.nginx = {
      enable = true;
      virtualHosts = {
        "status.cxl.sh" = {
          addSSL = true;
          enableACME = true;

          locations."/" = {
            recommendedProxySettings = true;
            proxyPass = "http://127.0.0.1:6969/";
          };
        };
      };
    };

    systemd.services."cxl.web.status" = {
      enable = true;
      wantedBy = [ "multi-user.target" ];

      serviceConfig = {
        ExecStart = "${pkgs.cxl.status}/bin/status 6969 /srv/web/status/auth";
      };
    };
  };
}