parsoid service: update, use declarative configuration

Old configuration format is disabled now (it can still be used, but with
additional steps). This is a backwards incompatible change.

+31 -18
+9
nixos/doc/manual/release-notes/rl-1703.xml
··· 68 68 that may be in /etc. 69 69 </para> 70 70 </listitem> 71 + 72 + <listitem> 73 + <para> 74 + Parsoid service now uses YAML configuration format. 75 + <literal>service.parsoid.interwikis</literal> is now called 76 + <literal>service.parsoid.wikis</literal> and is a list of either API URLs 77 + or attribute sets as specified in parsoid's documentation. 78 + </para> 79 + </listitem> 71 80 </itemizedlist> 72 81 73 82
+3
nixos/modules/rename.nix
··· 144 144 # murmur 145 145 (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ]) 146 146 147 + # parsoid 148 + (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] [ "services" "parsoid" "wikis" ]) 149 + 147 150 # Options that are obsolete and have no replacement. 148 151 (mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "") 149 152 (mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
+19 -18
nixos/modules/services/misc/parsoid.nix
··· 6 6 7 7 cfg = config.services.parsoid; 8 8 9 - conf = '' 10 - exports.setup = function( parsoidConfig ) { 11 - ${toString (mapAttrsToList (name: str: "parsoidConfig.setInterwiki('${name}', '${str}');") cfg.interwikis)} 9 + confTree = { 10 + worker_heartbeat_timeout = 300000; 11 + logging = { level = "info"; }; 12 + services = [{ 13 + module = "lib/index.js"; 14 + entrypoint = "apiServiceWorker"; 15 + conf = { 16 + mwApis = map (x: if isAttrs x then x else { uri = x; }) cfg.wikis; 17 + serverInterface = cfg.interface; 18 + serverPort = cfg.port; 19 + }; 20 + }]; 21 + }; 12 22 13 - parsoidConfig.serverInterface = "${cfg.interface}"; 14 - parsoidConfig.serverPort = ${toString cfg.port}; 15 - 16 - parsoidConfig.useSelser = true; 17 - 18 - ${cfg.extraConfig} 19 - }; 20 - ''; 21 - 22 - confFile = builtins.toFile "localsettings.js" conf; 23 + confFile = pkgs.writeText "config.yml" (builtins.toJSON (recursiveUpdate confTree cfg.extraConfig)); 23 24 24 25 in 25 26 { ··· 38 39 ''; 39 40 }; 40 41 41 - interwikis = mkOption { 42 - type = types.attrsOf types.str; 43 - example = { localhost = "http://localhost/api.php"; }; 42 + wikis = mkOption { 43 + type = types.listOf (types.either types.str types.attrs); 44 + example = [ "http://localhost/api.php" ]; 44 45 description = '' 45 46 Used MediaWiki API endpoints. 46 47 ''; ··· 71 72 }; 72 73 73 74 extraConfig = mkOption { 74 - type = types.lines; 75 - default = ""; 75 + type = types.attrs; 76 + default = {}; 76 77 description = '' 77 78 Extra configuration to add to parsoid configuration. 78 79 '';