1{ pkgs, lib, config, ... }:
2
3with lib;
4
5let
6 cfg = config.services.gotify;
7in {
8 options = {
9 services.gotify = {
10 enable = mkEnableOption (lib.mdDoc "Gotify webserver");
11
12 port = mkOption {
13 type = types.port;
14 description = lib.mdDoc ''
15 Port the server listens to.
16 '';
17 };
18
19 stateDirectoryName = mkOption {
20 type = types.str;
21 default = "gotify-server";
22 description = lib.mdDoc ''
23 The name of the directory below {file}`/var/lib` where
24 gotify stores its runtime data.
25 '';
26 };
27 };
28 };
29
30 config = mkIf cfg.enable {
31 systemd.services.gotify-server = {
32 wantedBy = [ "multi-user.target" ];
33 after = [ "network.target" ];
34 description = "Simple server for sending and receiving messages";
35
36 environment = {
37 GOTIFY_SERVER_PORT = toString cfg.port;
38 };
39
40 serviceConfig = {
41 WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
42 StateDirectory = cfg.stateDirectoryName;
43 Restart = "always";
44 DynamicUser = "yes";
45 ExecStart = "${pkgs.gotify-server}/bin/server";
46 };
47 };
48 };
49}