blob: 5f5a9f9f86bbc30cc2b2a0a0ad0470a6685725a9 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
{
pkgs,
lib,
config,
...
}:
let
cfg = config.services.gotify;
in
{
imports = [
(lib.mkRenamedOptionModule
[
"services"
"gotify"
"port"
]
[
"services"
"gotify"
"environment"
"GOTIFY_SERVER_PORT"
]
)
];
options.services.gotify = {
enable = lib.mkEnableOption "Gotify webserver";
package = lib.mkPackageOption pkgs "gotify-server" { };
environment = lib.mkOption {
type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.str
lib.types.int
]
);
default = { };
example = {
GOTIFY_SERVER_PORT = 8080;
GOTIFY_DATABASE_DIALECT = "sqlite3";
};
description = ''
Config environment variables for the gotify-server.
See https://gotify.net/docs/config for more details.
'';
};
environmentFiles = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [ ];
description = ''
Files containing additional config environment variables for gotify-server.
Secrets should be set in environmentFiles instead of environment.
'';
};
stateDirectoryName = lib.mkOption {
type = lib.types.str;
default = "gotify-server";
description = ''
The name of the directory below {file}`/var/lib` where
gotify stores its runtime data.
'';
};
};
config = lib.mkIf cfg.enable {
systemd.services.gotify-server = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "Simple server for sending and receiving messages";
environment = lib.mapAttrs (_: toString) cfg.environment;
serviceConfig = {
WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
StateDirectory = cfg.stateDirectoryName;
EnvironmentFile = cfg.environmentFiles;
Restart = "always";
DynamicUser = true;
ExecStart = lib.getExe cfg.package;
};
};
};
meta.maintainers = with lib.maintainers; [ DCsunset ];
}
|