1 { config, lib, pkgs, ... }:
4 cfg = config.services.parsoid;
6 parsoid = pkgs.nodePackages.parsoid;
9 worker_heartbeat_timeout = 300000;
10 logging = { level = "info"; };
12 module = "lib/index.js";
13 entrypoint = "apiServiceWorker";
15 mwApis = map (x: if lib.isAttrs x then x else { uri = x; }) cfg.wikis;
16 serverInterface = cfg.interface;
17 serverPort = cfg.port;
22 confFile = pkgs.writeText "config.yml" (builtins.toJSON (lib.recursiveUpdate confTree cfg.extraConfig));
27 (lib.mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] "Use services.parsoid.wikis instead")
36 enable = lib.mkOption {
37 type = lib.types.bool;
40 Whether to enable Parsoid -- bidirectional
45 wikis = lib.mkOption {
46 type = lib.types.listOf (lib.types.either lib.types.str lib.types.attrs);
47 example = [ "http://localhost/api.php" ];
49 Used MediaWiki API endpoints.
53 workers = lib.mkOption {
57 Number of Parsoid workers.
61 interface = lib.mkOption {
63 default = "127.0.0.1";
65 Interface to listen on.
70 type = lib.types.port;
77 extraConfig = lib.mkOption {
78 type = lib.types.attrs;
81 Extra configuration to add to parsoid configuration.
91 config = lib.mkIf cfg.enable {
93 systemd.services.parsoid = {
94 description = "Bidirectional wikitext parser";
95 wantedBy = [ "multi-user.target" ];
96 after = [ "network.target" ];
98 ExecStart = "${parsoid}/lib/node_modules/parsoid/bin/server.js -c ${confFile} -n ${toString cfg.workers}";
104 CapabilityBoundingSet = "";
105 NoNewPrivileges = true;
106 ProtectSystem = "strict";
109 PrivateDevices = true;
110 ProtectHostname = true;
111 ProtectKernelTunables = true;
112 ProtectKernelModules = true;
113 ProtectControlGroups = true;
114 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
115 RestrictNamespaces = true;
116 LockPersonality = true;
117 #MemoryDenyWriteExecute = true;
118 RestrictRealtime = true;
119 RestrictSUIDSGID = true;