diff options
author | Aaron Andersen <aaron@fosslib.net> | 2019-07-21 16:39:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-21 16:39:42 -0400 |
commit | 44565adda500eb36e21a7c8f7ff67b32b272cf11 (patch) | |
tree | c89a3527475297f28cb9ea17de6109bc0184f56c /nixos/modules/services | |
parent | bc418837d540822b4babece9fddf536c441fe1b1 (diff) | |
parent | 976928daa2bf3f33792eb6878569153c763a40d4 (diff) | |
download | nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar.gz nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar.bz2 nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar.lz nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar.xz nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.tar.zst nixlib-44565adda500eb36e21a7c8f7ff67b32b272cf11.zip |
Merge pull request #60436 from nbardiuk/master
nixos/tiddlywiki: init
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/misc/tiddlywiki.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/tiddlywiki.nix b/nixos/modules/services/misc/tiddlywiki.nix new file mode 100644 index 000000000000..2adc08f6cfed --- /dev/null +++ b/nixos/modules/services/misc/tiddlywiki.nix @@ -0,0 +1,52 @@ +{ 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 = { + + enable = mkEnableOption "TiddlyWiki nodejs server"; + + listenOptions = mkOption { + type = types.attrs; + default = {}; + example = { + credentials = "../credentials.csv"; + readers="(authenticated)"; + port = 3456; + }; + description = '' + Parameters passed to <literal>--listen</literal> command. + Refer to <link xlink:href="https://tiddlywiki.com/#WebServer"/> + 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}"; + }; + }; + }; + }; +} |