summary refs log tree commit diff
path: root/nixos/modules/services/web-apps/gotify-server.nix
blob: 03e01f46a94413d77483132e4598d405e8d6396b (plain) (blame)
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
47
48
49
{ pkgs, lib, config, ... }:

with lib;

let
  cfg = config.services.gotify;
in {
  options = {
    services.gotify = {
      enable = mkEnableOption "Gotify webserver";

      port = mkOption {
        type = types.port;
        description = ''
          Port the server listens to.
        '';
      };

      stateDirectoryName = mkOption {
        type = types.str;
        default = "gotify-server";
        description = ''
          The name of the directory below <filename>/var/lib</filename> where
          gotify stores its runtime data.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.services.gotify-server = {
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];
      description = "Simple server for sending and receiving messages";

      environment = {
        GOTIFY_SERVER_PORT = toString cfg.port;
      };

      serviceConfig = {
        WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
        StateDirectory = cfg.stateDirectoryName;
        Restart = "always";
        DynamicUser = "yes";
        ExecStart = "${pkgs.gotify-server}/bin/server";
      };
    };
  };
}