2023-05-18 17:14:24 +02:00
|
|
|
{ pkgs, lib, config, values, ... }: let
|
|
|
|
cfg = config.services.mediawiki;
|
|
|
|
|
|
|
|
# "mediawiki"
|
|
|
|
user = config.systemd.services.mediawiki-init.serviceConfig.User;
|
|
|
|
|
|
|
|
# "mediawiki"
|
|
|
|
group = config.users.users.${user}.group;
|
|
|
|
in {
|
2023-09-17 23:18:16 +02:00
|
|
|
sops.secrets = let
|
|
|
|
secret = opts: {
|
2023-05-18 17:14:24 +02:00
|
|
|
restartUnits = [ "mediawiki-init.service" "phpfpm-mediawiki.service" ];
|
|
|
|
owner = user;
|
|
|
|
group = group;
|
2023-09-17 23:18:16 +02:00
|
|
|
} // opts;
|
|
|
|
in {
|
|
|
|
"mediawiki/password" = secret { };
|
|
|
|
"mediawiki/database" = secret { };
|
|
|
|
"mediawiki/oidc/clientsecret" = secret { };
|
2023-01-29 01:51:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.mediawiki = {
|
|
|
|
enable = true;
|
2023-05-18 17:14:24 +02:00
|
|
|
name = "Programvareverkstedet";
|
2023-01-29 01:51:35 +01:00
|
|
|
passwordFile = config.sops.secrets."mediawiki/password".path;
|
2023-05-18 17:14:24 +02:00
|
|
|
passwordSender = "drift@pvv.ntnu.no";
|
2023-01-29 01:51:35 +01:00
|
|
|
|
|
|
|
database = {
|
2023-09-17 23:18:16 +02:00
|
|
|
type = "mysql";
|
|
|
|
host = "mysql.pvv.ntnu.no";
|
2023-05-18 17:14:24 +02:00
|
|
|
createLocally = false;
|
2023-09-17 23:18:16 +02:00
|
|
|
user = "bekkalokk_mediawiki_test";
|
|
|
|
name = "bekkalokk_mediawiki_test";
|
|
|
|
passwordFile = config.sops.secrets."mediawiki/database".path;
|
2023-01-29 01:51:35 +01:00
|
|
|
};
|
2023-05-18 17:14:24 +02:00
|
|
|
|
|
|
|
# Host through nginx
|
|
|
|
webserver = "none";
|
|
|
|
poolConfig = let
|
|
|
|
listenUser = config.services.nginx.user;
|
|
|
|
listenGroup = config.services.nginx.group;
|
|
|
|
in {
|
2023-09-17 23:18:16 +02:00
|
|
|
# Worker settings
|
2023-05-18 17:14:24 +02:00
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 32;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 2;
|
|
|
|
"pm.max_spare_servers" = 4;
|
2023-09-17 23:18:16 +02:00
|
|
|
|
|
|
|
# Socket settings
|
2023-05-18 17:14:24 +02:00
|
|
|
"listen.owner" = listenUser;
|
|
|
|
"listen.group" = listenGroup;
|
2023-09-17 23:18:16 +02:00
|
|
|
|
|
|
|
# Misc
|
2023-05-18 17:14:24 +02:00
|
|
|
"env[PATH]" = lib.makeBinPath [ pkgs.php ];
|
|
|
|
# to accept *.html file
|
|
|
|
"security.limit_extensions" = "";
|
2023-09-17 23:18:16 +02:00
|
|
|
inherit user group;
|
|
|
|
|
|
|
|
# Debug logging
|
|
|
|
"catch_workers_output" = "yes";
|
|
|
|
"php_flag[display_errors]" = "on";
|
|
|
|
"php_admin_value[error_log]" = "stderr";
|
|
|
|
"php_admin_flag[log_errors]" = "on";
|
2023-05-18 17:14:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extensions = {
|
|
|
|
DeleteBatch = pkgs.fetchzip {
|
2023-09-17 23:18:16 +02:00
|
|
|
url = "https://extdist.wmflabs.org/dist/extensions/DeleteBatch-REL1_40-6852fb7.tar.gz";
|
|
|
|
hash = "sha256-m6l8Cs6mFLu1qfovBFO2l8HhtYZXnpZkajWXNob2wbU=";
|
2023-05-18 17:14:24 +02:00
|
|
|
};
|
|
|
|
UserMerge = pkgs.fetchzip {
|
2023-09-17 23:18:16 +02:00
|
|
|
url = "https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_40-56f6dcf.tar.gz";
|
|
|
|
hash = "sha256-zO7ti7fZPlJp3TXSJbYrXPRyElwO57zoU+RH7LBwVGU=";
|
2023-05-18 17:14:24 +02:00
|
|
|
};
|
|
|
|
PluggableAuth = pkgs.fetchzip {
|
2023-09-17 23:18:16 +02:00
|
|
|
url = "https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_40-8104ed9.tar.gz";
|
|
|
|
hash = "sha256-fFz9+pJ/Ucdg340I/JWe4S/W05oVSfns9EF84rxN8yI=";
|
2023-05-18 17:14:24 +02:00
|
|
|
};
|
2023-09-17 23:18:16 +02:00
|
|
|
OpenIDConnect = pkgs.fetchzip {
|
|
|
|
url = "https://extdist.wmflabs.org/dist/extensions/OpenIDConnect-REL1_40-3edc735.tar.gz";
|
|
|
|
hash = "sha256-Osp4m2Sp9uGNt3QEmRsw0LA3KQCQzqJosgy3AFs11hY=";
|
2023-05-18 17:14:24 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-17 23:18:16 +02:00
|
|
|
extraConfig = ''
|
2023-05-18 17:14:24 +02:00
|
|
|
$wgServer = "https://bekkalokk.pvv.ntnu.no";
|
|
|
|
$wgLocaltimezone = "Europe/Oslo";
|
|
|
|
|
|
|
|
# Only allow login through SSO
|
|
|
|
$wgEnableEmail = false;
|
|
|
|
$wgEnableUserEmail = false;
|
|
|
|
$wgEmailAuthentication = false;
|
|
|
|
$wgGroupPermissions['*']['createaccount'] = false;
|
|
|
|
$wgGroupPermissions['*']['autocreateaccount'] = true;
|
2023-09-17 23:18:16 +02:00
|
|
|
$wgPluggableAuth_EnableAutoLogin = false;
|
|
|
|
|
|
|
|
# SSO config
|
|
|
|
$wgPluggableAuth_Config[] = [
|
|
|
|
'plugin' => 'OpenIDConnect',
|
|
|
|
'data' => [
|
|
|
|
'providerURL' => 'https://git.pvv.ntnu.no/login/oauth/authorize',
|
|
|
|
'clientID' => 'be86ec39-d89c-4973-a163-633339539db2',
|
|
|
|
'clientsecret' => file_get_contents('${config.sops.secrets."mediawiki/oidc/clientsecret".path}')
|
|
|
|
]
|
|
|
|
];
|
2023-05-18 17:14:24 +02:00
|
|
|
|
|
|
|
# Disable anonymous editing
|
|
|
|
$wgGroupPermissions['*']['edit'] = false;
|
|
|
|
|
|
|
|
# Styling
|
2023-09-17 23:18:16 +02:00
|
|
|
$wgLogos = [
|
|
|
|
'svg' => "${../../../assets/logo_blue_regular.svg}",
|
|
|
|
];
|
2023-05-18 17:14:24 +02:00
|
|
|
$wgDefaultSkin = "monobook";
|
|
|
|
|
2023-09-17 23:18:16 +02:00
|
|
|
# Enable debugging
|
|
|
|
error_reporting( -1 );
|
|
|
|
ini_set( 'display_errors', 1 );
|
|
|
|
|
2023-05-18 17:14:24 +02:00
|
|
|
# Misc
|
|
|
|
$wgEmergencyContact = "${cfg.passwordSender}";
|
|
|
|
$wgShowIPinHeader = false;
|
|
|
|
$wgUseTeX = false;
|
|
|
|
$wgLocalInterwiki = $wgSitename;
|
|
|
|
|
|
|
|
# Fix https://github.com/NixOS/nixpkgs/issues/183097
|
|
|
|
$wgDBserver = "${toString cfg.database.host}";
|
|
|
|
'';
|
2023-01-29 01:51:35 +01:00
|
|
|
};
|
2023-05-18 17:14:24 +02:00
|
|
|
|
2023-09-17 23:18:16 +02:00
|
|
|
# services.nginx.virtualHosts."wiki.pvv.ntnu.no" = {
|
|
|
|
services.nginx.virtualHosts."bekkalokk.pvv.ntnu.no" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
root = "${cfg.finalPackage}/share/mediawiki";
|
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
extraConfig = ''
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
fastcgi_index index.php;
|
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.mediawiki.socket};
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"/images".root = config.services.mediawiki.uploadsDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2023-01-29 01:51:35 +01:00
|
|
|
}
|