2022-09-06 17:11:05 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2023-06-12 23:36:57 +02:00
|
|
|
let
|
2023-08-22 16:55:03 +02:00
|
|
|
domain = "wiki.ifsr.de";
|
2023-06-12 23:36:57 +02:00
|
|
|
listenPort = 8080;
|
|
|
|
in
|
2022-09-06 17:11:05 +02:00
|
|
|
{
|
2022-09-06 20:29:31 +02:00
|
|
|
sops.secrets = {
|
|
|
|
"mediawiki/initial_admin".owner = config.users.users.mediawiki.name;
|
2023-06-16 15:55:15 +02:00
|
|
|
"mediawiki/oidc_secret".owner = config.users.users.mediawiki.name;
|
2022-09-06 20:29:31 +02:00
|
|
|
};
|
2022-11-18 17:51:09 +01:00
|
|
|
|
2023-07-26 17:02:34 +02:00
|
|
|
systemd.services.mediawiki-init.after = [ "postgresql.service" ];
|
2022-09-06 17:16:31 +02:00
|
|
|
services = {
|
|
|
|
mediawiki = {
|
|
|
|
enable = true;
|
2022-09-06 20:29:31 +02:00
|
|
|
passwordFile = config.sops.secrets."mediawiki/initial_admin".path;
|
2023-06-12 23:36:57 +02:00
|
|
|
database.type = "postgres";
|
|
|
|
url = "https://${domain}";
|
2022-11-18 17:51:09 +01:00
|
|
|
|
2023-05-25 22:58:14 +02:00
|
|
|
httpd.virtualHost = {
|
2022-11-18 17:51:09 +01:00
|
|
|
adminAddr = "root@ifsr.de";
|
2023-06-12 23:36:57 +02:00
|
|
|
listen = [{
|
2022-11-18 17:51:09 +01:00
|
|
|
ip = "127.0.0.1";
|
2023-06-12 23:36:57 +02:00
|
|
|
port = listenPort;
|
2022-11-18 17:51:09 +01:00
|
|
|
ssl = false;
|
2023-06-12 23:36:57 +02:00
|
|
|
}];
|
2023-08-09 23:02:20 +02:00
|
|
|
# Short url support (e.g. https://wiki.ifsr.de/Page instead of .../index.php?title=Page)
|
|
|
|
# Recommended config taken from https://www.mediawiki.org/wiki/Manual:Short_URL/Apache
|
|
|
|
# See paragraph "If you are using a root url ..."
|
2023-06-12 23:36:57 +02:00
|
|
|
extraConfig = ''
|
|
|
|
RewriteEngine On
|
|
|
|
RewriteCond %{REQUEST_URI} !^/rest\.php
|
|
|
|
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
|
|
|
|
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
|
|
|
|
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
|
|
|
|
'';
|
|
|
|
};
|
2022-09-06 20:29:31 +02:00
|
|
|
|
|
|
|
extraConfig = ''
|
2023-06-12 23:36:57 +02:00
|
|
|
$wgSitename = "FSR Wiki";
|
|
|
|
$wgArticlePath = '/$1';
|
2022-09-06 20:29:31 +02:00
|
|
|
|
2023-06-12 23:36:57 +02:00
|
|
|
// $wgLogo = "https://www.c3d2.de/images/ck.png";
|
|
|
|
$wgLanguageCode = "de";
|
2022-09-06 20:29:31 +02:00
|
|
|
|
2023-06-16 15:55:15 +02:00
|
|
|
$wgGroupPermissions['*']['read'] = false;
|
2023-06-12 23:36:57 +02:00
|
|
|
$wgGroupPermissions['*']['edit'] = false;
|
2023-06-16 15:55:15 +02:00
|
|
|
$wgGroupPermissions['*']['createaccount'] = false;
|
|
|
|
$wgGroupPermissions['*']['autocreateaccount'] = true;
|
2023-06-12 23:36:57 +02:00
|
|
|
$wgGroupPermissions['sysop']['userrights'] = true;
|
|
|
|
$wgGroupPermissions['sysop']['deletelogentry'] = true;
|
|
|
|
$wgGroupPermissions['sysop']['deleterevision'] = true;
|
2022-09-06 20:29:31 +02:00
|
|
|
|
2023-06-12 23:36:57 +02:00
|
|
|
$wgEnableAPI = true;
|
|
|
|
$wgAllowUserCss = true;
|
|
|
|
$wgUseAjax = true;
|
|
|
|
$wgEnableMWSuggest = true;
|
2023-08-23 15:26:58 +02:00
|
|
|
$wgDefaultSkin = 'timeless';
|
2022-09-06 20:29:31 +02:00
|
|
|
|
2023-06-12 23:36:57 +02:00
|
|
|
//TODO what about $wgUpgradeKey ?
|
2022-09-06 20:29:31 +02:00
|
|
|
|
2023-06-16 15:55:15 +02:00
|
|
|
# Auth
|
2023-08-09 23:02:20 +02:00
|
|
|
# https://www.mediawiki.org/wiki/Extension:PluggableAuth
|
|
|
|
# https://www.mediawiki.org/wiki/Extension:OpenID_Connect
|
2023-06-12 23:36:57 +02:00
|
|
|
$wgPluggableAuth_EnableLocalLogin = true;
|
2023-06-16 15:55:15 +02:00
|
|
|
$wgPluggableAuth_Config["iFSR Login"] = [
|
|
|
|
"plugin" => "OpenIDConnect",
|
|
|
|
"data" => [
|
|
|
|
"providerURL" => "${config.services.portunus.domain}/dex",
|
|
|
|
"clientID" => "wiki",
|
|
|
|
"clientsecret" => file_get_contents('${config.sops.secrets."mediawiki/oidc_secret".path}'),
|
|
|
|
],
|
|
|
|
];
|
2022-09-06 20:29:31 +02:00
|
|
|
'';
|
2023-06-12 23:36:57 +02:00
|
|
|
|
2022-09-06 20:35:26 +02:00
|
|
|
extensions = {
|
|
|
|
PluggableAuth = pkgs.fetchzip {
|
2023-06-16 15:55:15 +02:00
|
|
|
url = "https://web.archive.org/web/20230615112924/https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_39-068be5d.tar.gz";
|
|
|
|
hash = "sha256-kmdSPMQNaO0qgEzb8j0+eLlsNQLmfJfo0Ls4yvYgOFI=";
|
2022-09-06 20:35:26 +02:00
|
|
|
};
|
2023-06-16 15:55:15 +02:00
|
|
|
OpenIDConnect = pkgs.fetchzip {
|
|
|
|
url = "https://web.archive.org/web/20230615113527/https://extdist.wmflabs.org/dist/extensions/OpenIDConnect-REL1_39-42e4d75.tar.gz";
|
|
|
|
hash = "sha256-VN0G0Crjlx0DTLeDvaSFtMmYsfB7VzgYkSNDS+nkIyQ=";
|
2022-09-06 20:35:26 +02:00
|
|
|
};
|
2023-07-23 23:57:29 +02:00
|
|
|
VisualEditor = pkgs.fetchzip {
|
|
|
|
url = "https://web.archive.org/web/20230723212424/https://extdist.wmflabs.org/dist/extensions/VisualEditor-REL1_39-b1204c9.tar.gz";
|
|
|
|
hash = "sha256-g/ATW3xkecHynwbwLbmYgawNW+LCVTth0ZlhY7A3N5U=";
|
|
|
|
};
|
2022-09-06 20:35:26 +02:00
|
|
|
};
|
2022-09-06 17:11:05 +02:00
|
|
|
};
|
2023-06-12 23:36:57 +02:00
|
|
|
|
2023-06-16 15:55:15 +02:00
|
|
|
portunus.dex.oidcClients = [{
|
|
|
|
id = "wiki";
|
|
|
|
callbackURL = "https://${domain}/Spezial:PluggableAuthLogin";
|
|
|
|
}];
|
|
|
|
|
2022-09-07 12:42:14 +02:00
|
|
|
nginx = {
|
|
|
|
recommendedProxySettings = true;
|
2023-06-12 23:36:57 +02:00
|
|
|
virtualHosts.${domain} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString listenPort}";
|
|
|
|
proxyWebsockets = true;
|
2022-09-07 12:42:14 +02:00
|
|
|
};
|
2023-08-22 16:29:09 +02:00
|
|
|
locations."~ ^/ese/([^\\n|\\r]*)$".return = "301 https://wiki.ese.ifsr.de/$1";
|
|
|
|
locations."~ ^/fsr/([^\\n|\\r]*)$".return = "301 https://wiki.ifsr.de/$1";
|
2022-09-07 12:42:14 +02:00
|
|
|
};
|
|
|
|
};
|
2022-09-06 17:16:31 +02:00
|
|
|
};
|
|
|
|
}
|