Loading nixos/modules/services/web-apps/mediawiki.nix +77 −29 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ let cfg = config.services.mediawiki; fpm = config.services.phpfpm.pools.mediawiki; user = "mediawiki"; group = config.services.httpd.group; group = if cfg.webserver == "apache" then "apache" else "mediawiki"; cacheDir = "/var/cache/mediawiki"; stateDir = "/var/lib/mediawiki"; Loading Loading @@ -73,7 +74,7 @@ let $wgScriptPath = ""; ## The protocol and server name to use in fully-qualified URLs $wgServer = "${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://${cfg.httpd.virtualHost.hostName}"; $wgServer = "${cfg.url}"; ## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath; Loading @@ -87,7 +88,7 @@ let $wgEnableEmail = true; $wgEnableUserEmail = true; # UPO $wgPasswordSender = "${if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr}"; $wgPasswordSender = "${cfg.passwordSender}"; $wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO Loading Loading @@ -196,6 +197,22 @@ in description = lib.mdDoc "Name of the wiki."; }; url = mkOption { type = types.str; default = if cfg.webserver == "apache" then "${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://${cfg.httpd.virtualHost.hostName}" else "http://localhost"; defaultText = literalExpression '' if cfg.webserver == "apache" then "''${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://''${cfg.httpd.virtualHost.hostName}" else "http://localhost"; ''; example = "https://wiki.example.org"; description = lib.mdDoc "URL of the wiki."; }; uploadsDir = mkOption { type = types.nullOr types.path; default = "${stateDir}/uploads"; Loading @@ -211,6 +228,24 @@ in example = "/run/keys/mediawiki-password"; }; passwordSender = mkOption { type = types.str; default = if cfg.webserver == "apache" then if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr else "root@localhost"; defaultText = literalExpression '' if cfg.webserver == "apache" then if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr else "root@localhost" ''; description = lib.mdDoc "Contact address for password reset."; }; skins = mkOption { default = {}; type = types.attrsOf types.path; Loading Loading @@ -240,6 +275,12 @@ in ''; }; webserver = mkOption { type = types.enum [ "apache" "none" ]; default = "apache"; description = lib.mdDoc "Webserver to use."; }; database = { type = mkOption { type = types.enum [ "mysql" "postgres" "sqlite" "mssql" "oracle" ]; Loading Loading @@ -415,16 +456,21 @@ in services.phpfpm.pools.mediawiki = { inherit user group; phpEnv.MEDIAWIKI_CONFIG = "${mediawikiConfig}"; settings = { settings = (if (cfg.webserver == "apache") then { "listen.owner" = config.services.httpd.user; "listen.group" = config.services.httpd.group; } // cfg.poolConfig; } else { "listen.owner" = user; "listen.group" = group; }) // cfg.poolConfig; }; services.httpd = { services.httpd = lib.mkIf (cfg.webserver == "apache") { enable = true; extraModules = [ "proxy_fcgi" ]; virtualHosts.${cfg.httpd.virtualHost.hostName} = mkMerge [ cfg.httpd.virtualHost { virtualHosts.${cfg.httpd.virtualHost.hostName} = mkMerge [ cfg.httpd.virtualHost { documentRoot = mkForce "${pkg}/share/mediawiki"; extraConfig = '' <Directory "${pkg}/share/mediawiki"> Loading @@ -444,7 +490,8 @@ in Require all granted </Directory> ''; } ]; } ]; }; systemd.tmpfiles.rules = [ Loading Loading @@ -492,13 +539,14 @@ in }; }; systemd.services.httpd.after = optional (cfg.database.createLocally && cfg.database.type == "mysql") "mysql.service" ++ optional (cfg.database.createLocally && cfg.database.type == "postgres") "postgresql.service"; systemd.services.httpd.after = optional (cfg.webserver == "apache" && cfg.database.createLocally && cfg.database.type == "mysql") "mysql.service" ++ optional (cfg.webserver == "apache" && cfg.database.createLocally && cfg.database.type == "postgres") "postgresql.service"; users.users.${user} = { group = group; isSystemUser = true; }; users.groups.${group} = {}; environment.systemPackages = [ mediawikiScripts ]; }; Loading nixos/tests/mediawiki.nix +11 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,15 @@ in assert "MediaWiki has been installed" in page ''; }; nohttpd = testLib.makeTest { name = "mediawiki-nohttpd"; nodes.machine = { services.mediawiki.webserver = "none"; }; testScript = '' start_all() machine.wait_for_unit("phpfpm-mediawiki.service") ''; }; } Loading
nixos/modules/services/web-apps/mediawiki.nix +77 −29 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ let cfg = config.services.mediawiki; fpm = config.services.phpfpm.pools.mediawiki; user = "mediawiki"; group = config.services.httpd.group; group = if cfg.webserver == "apache" then "apache" else "mediawiki"; cacheDir = "/var/cache/mediawiki"; stateDir = "/var/lib/mediawiki"; Loading Loading @@ -73,7 +74,7 @@ let $wgScriptPath = ""; ## The protocol and server name to use in fully-qualified URLs $wgServer = "${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://${cfg.httpd.virtualHost.hostName}"; $wgServer = "${cfg.url}"; ## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath; Loading @@ -87,7 +88,7 @@ let $wgEnableEmail = true; $wgEnableUserEmail = true; # UPO $wgPasswordSender = "${if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr}"; $wgPasswordSender = "${cfg.passwordSender}"; $wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO Loading Loading @@ -196,6 +197,22 @@ in description = lib.mdDoc "Name of the wiki."; }; url = mkOption { type = types.str; default = if cfg.webserver == "apache" then "${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://${cfg.httpd.virtualHost.hostName}" else "http://localhost"; defaultText = literalExpression '' if cfg.webserver == "apache" then "''${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://''${cfg.httpd.virtualHost.hostName}" else "http://localhost"; ''; example = "https://wiki.example.org"; description = lib.mdDoc "URL of the wiki."; }; uploadsDir = mkOption { type = types.nullOr types.path; default = "${stateDir}/uploads"; Loading @@ -211,6 +228,24 @@ in example = "/run/keys/mediawiki-password"; }; passwordSender = mkOption { type = types.str; default = if cfg.webserver == "apache" then if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr else "root@localhost"; defaultText = literalExpression '' if cfg.webserver == "apache" then if cfg.httpd.virtualHost.adminAddr != null then cfg.httpd.virtualHost.adminAddr else config.services.httpd.adminAddr else "root@localhost" ''; description = lib.mdDoc "Contact address for password reset."; }; skins = mkOption { default = {}; type = types.attrsOf types.path; Loading Loading @@ -240,6 +275,12 @@ in ''; }; webserver = mkOption { type = types.enum [ "apache" "none" ]; default = "apache"; description = lib.mdDoc "Webserver to use."; }; database = { type = mkOption { type = types.enum [ "mysql" "postgres" "sqlite" "mssql" "oracle" ]; Loading Loading @@ -415,16 +456,21 @@ in services.phpfpm.pools.mediawiki = { inherit user group; phpEnv.MEDIAWIKI_CONFIG = "${mediawikiConfig}"; settings = { settings = (if (cfg.webserver == "apache") then { "listen.owner" = config.services.httpd.user; "listen.group" = config.services.httpd.group; } // cfg.poolConfig; } else { "listen.owner" = user; "listen.group" = group; }) // cfg.poolConfig; }; services.httpd = { services.httpd = lib.mkIf (cfg.webserver == "apache") { enable = true; extraModules = [ "proxy_fcgi" ]; virtualHosts.${cfg.httpd.virtualHost.hostName} = mkMerge [ cfg.httpd.virtualHost { virtualHosts.${cfg.httpd.virtualHost.hostName} = mkMerge [ cfg.httpd.virtualHost { documentRoot = mkForce "${pkg}/share/mediawiki"; extraConfig = '' <Directory "${pkg}/share/mediawiki"> Loading @@ -444,7 +490,8 @@ in Require all granted </Directory> ''; } ]; } ]; }; systemd.tmpfiles.rules = [ Loading Loading @@ -492,13 +539,14 @@ in }; }; systemd.services.httpd.after = optional (cfg.database.createLocally && cfg.database.type == "mysql") "mysql.service" ++ optional (cfg.database.createLocally && cfg.database.type == "postgres") "postgresql.service"; systemd.services.httpd.after = optional (cfg.webserver == "apache" && cfg.database.createLocally && cfg.database.type == "mysql") "mysql.service" ++ optional (cfg.webserver == "apache" && cfg.database.createLocally && cfg.database.type == "postgres") "postgresql.service"; users.users.${user} = { group = group; isSystemUser = true; }; users.groups.${group} = {}; environment.systemPackages = [ mediawikiScripts ]; }; Loading
nixos/tests/mediawiki.nix +11 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,15 @@ in assert "MediaWiki has been installed" in page ''; }; nohttpd = testLib.makeTest { name = "mediawiki-nohttpd"; nodes.machine = { services.mediawiki.webserver = "none"; }; testScript = '' start_all() machine.wait_for_unit("phpfpm-mediawiki.service") ''; }; }