summaryrefslogtreecommitdiff
path: root/modules/notifications.linus.onl/default.nix
blob: 443853f469e019c4412dd2761391a422c1e9fb4b (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
{ pkgs, lib, config, ... }:

let
  inherit (lib) mkEnableOption mkOption types mkIf optional;

  domain = "notifications.linus.onl";

  # TODO: Make option internal-port.
  internal-port = 13082;

  cfg = config.my.modules."notifications.linus.onl";
in
{
  options.my.modules."notifications.linus.onl" = {
    enable = mkEnableOption "notifications.linus.onl static site";

    useACME = mkEnableOption "built-in HTTPS stuff";
  };

  config = mkIf cfg.enable {
    my.services.push-notification-api = {
      enable = true;
      # host = "notifications.linus.onl";
      host = "0.0.0.0";
      port = internal-port;
      openFirewall = false; # We're using NGINX reverse proxy.
    };

    # Register domain name.
    services.cloudflare-dyndns.domains = [ "notifications.linus.onl" ];

    # Serve the generated page using NGINX.
    services.nginx.virtualHosts."notifications.linus.onl" = {
      enableACME = cfg.useACME;
      forceSSL = cfg.useACME;
      locations."/" = {
        recommendedProxySettings = true;
        proxyPass = "http://127.0.0.1:${toString internal-port}";
      };
    };
  };
}