blob: 2f43bce4d962227576f49c9982c0a0810ee92ffd (
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
47
48
49
50
51
52
53
54
55
56
57
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tiddlywiki;
listenParams = lib.concatStrings (
lib.mapAttrsToList (n: v: " '${n}=${toString v}' ") cfg.listenOptions
);
exe = lib.getExe pkgs.tiddlywiki;
name = "tiddlywiki";
dataDir = "/var/lib/" + name;
in
{
options.services.tiddlywiki = {
enable = lib.mkEnableOption "TiddlyWiki nodejs server";
listenOptions = lib.mkOption {
type = lib.types.attrs;
default = { };
example = {
credentials = "../credentials.csv";
readers = "(authenticated)";
port = 3456;
};
description = ''
Parameters passed to `--listen` command.
Refer to <https://tiddlywiki.com/#WebServer>
for details on supported values.
'';
};
};
config = lib.mkIf cfg.enable {
systemd = {
services.tiddlywiki = {
description = "TiddlyWiki nodejs server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Restart = "on-failure";
DynamicUser = true;
StateDirectory = name;
ExecStartPre = "-${exe} ${dataDir} --init server";
ExecStart = "${exe} ${dataDir} --listen ${listenParams}";
};
};
};
};
}
|