2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.tiddlywiki;
|
|
|
|
listenParams = concatStrings (mapAttrsToList (n: v: " '${n}=${toString v}' ") cfg.listenOptions);
|
|
|
|
exe = "${pkgs.nodePackages.tiddlywiki}/lib/node_modules/.bin/tiddlywiki";
|
|
|
|
name = "tiddlywiki";
|
|
|
|
dataDir = "/var/lib/" + name;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.tiddlywiki = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "TiddlyWiki nodejs server");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
listenOptions = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
credentials = "../credentials.csv";
|
|
|
|
readers="(authenticated)";
|
|
|
|
port = 3456;
|
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Parameters passed to `--listen` command.
|
|
|
|
Refer to <https://tiddlywiki.com/#WebServer>
|
2020-04-24 23:36:52 +00:00
|
|
|
for details on supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = 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}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|