summaryrefslogtreecommitdiffstats
path: root/usecases/server/gotify-server.nix
blob: 5445827625e82cc2b91a57791488c53fa9bb6fea (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
inputs:

{ config, ... }:

{
  services.gotify = {
    enable = true;
    port = 8082;
  };

  # TODO: add proper boot notification

  /*
  systemd.services.gotify-notify-boot = {
    after = [ "gotify-server.service" ];
    wantedBy = [ "multi-user.target" ];

    restartIfChanged = false;

    serviceConfig = {
      Type = "oneshot";

      # Priority is needed because there is no configuration, hence no default
      # priority to fallback to
      ExecStart = let params = lib.cli.toGNUCommandLineShell { } {
          url = "http://localhost:${toString config.services.gotify.port}";
          token = "$GOTIFY_TOKEN";
          priority = 0;
        };
        in "${pkgs.gotify-cli}/bin/gotify push ${params} 'The system has booted'";

      RemainAfterExit = "yes";
      # Adds lots of security options
      DynamicUser = "yes";
      EnvironmentFile = "/etc/nixos/res/gotify-config.env";

      Restart = "on-failure";
      RestartSec = "3s";
    };
  };
  */

  networking.firewall.interfaces.${config.topology.mainVpn.interfaceName}.allowedTCPPorts = [
    config.services.gotify.port
  ];
}