2023-10-30 00:22:34 +00:00
|
|
|
{
|
|
|
|
flake,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
localSettingsPHP = pkgs.writeScript "LocalSettings.php" ''
|
|
|
|
<?php
|
|
|
|
# Protect against web entry
|
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# error_reporting( -1 );
|
|
|
|
# ini_set( 'display_errors', 1 );
|
|
|
|
# $wgShowExceptionDetails = true;
|
2024-01-07 15:44:21 +00:00
|
|
|
# $wgDBerrorLog = '/dev/stderr';
|
|
|
|
# $wgDebugLogFile = "/dev/stderr";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgSitename = "pub.solar wiki";
|
|
|
|
$wgMetaNamespace = false;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## The URL base path to the directory containing the wiki;
|
|
|
|
## defaults for all runtime URL paths are based off of this.
|
|
|
|
## For more information on customizing the URLs
|
|
|
|
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
|
|
|
|
## https://www.mediawiki.org/wiki/Manual:Short_URL
|
2024-05-08 17:47:47 +00:00
|
|
|
$wgScriptPath = "https://wiki.${config.pub-solar-os.networking.domain}";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## https://www.mediawiki.org/wiki/Manual:Short_URL
|
|
|
|
## https://www.mediawiki.org/wiki/Extension:OpenID_Connect#Known_issues
|
|
|
|
$wgArticlePath = "/index.php/$1";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## The protocol and server name to use in fully-qualified URLs
|
2024-05-08 17:47:47 +00:00
|
|
|
$wgServer = "https://wiki.${config.pub-solar-os.networking.domain}";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## The URL path to static resources (images, scripts, etc.)
|
|
|
|
$wgResourceBasePath = $wgScriptPath;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## The URL path to the logo. Make sure you change this from the default,
|
|
|
|
## or else you'll overwrite your logo when you upgrade!
|
2024-01-08 13:35:43 +00:00
|
|
|
$wgLogo = "https://pub.solar/assets/pubsolar.svg";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## UPO means: this is also a user preference option
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgEnableEmail = true;
|
|
|
|
$wgEnableUserEmail = true; # UPO
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgPasswordSender = "admins@pub.solar";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgEnotifUserTalk = false; # UPO
|
|
|
|
$wgEnotifWatchlist = false; # UPO
|
|
|
|
$wgEmailAuthentication = true;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## Database settings
|
|
|
|
$wgDBtype = "postgres";
|
|
|
|
$wgDBserver = "host.docker.internal";
|
|
|
|
$wgDBport = "5432";
|
|
|
|
$wgDBname = "mediawiki";
|
|
|
|
$wgDBuser = "mediawiki";
|
|
|
|
$wgDBpassword = trim(file_get_contents("/run/mediawiki/database-password"));
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## Shared memory settings
|
|
|
|
$wgMainCacheType = CACHE_NONE;
|
|
|
|
$wgMemCachedServers = [];
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgEnableUploads = true;
|
|
|
|
$wgUploadDirectory = "/var/www/html/uploads";
|
2024-01-07 16:18:43 +00:00
|
|
|
$wgUploadPath = $wgScriptPath . "/uploads";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgUseImageMagick = true;
|
|
|
|
$wgImageMagickConvertCommand = "/usr/bin/convert";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
|
2024-01-08 16:42:57 +00:00
|
|
|
$wgUseInstantCommons = true;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Periodically send a pingback to https://www.mediawiki.org/ with basic data
|
|
|
|
# about this MediaWiki instance. The Wikimedia Foundation shares this data
|
|
|
|
# with MediaWiki developers to help guide future development efforts.
|
|
|
|
$wgPingback = true;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## If you use ImageMagick (or any other shell command) on a
|
|
|
|
## Linux server, this will need to be set to the name of an
|
|
|
|
## available UTF-8 locale
|
|
|
|
$wgShellLocale = "C.UTF-8";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Site language code, should be one of the list in ./languages/data/Names.php
|
|
|
|
$wgLanguageCode = "en";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgSecretKey = trim(file_get_contents("/run/mediawiki/secret-key"));
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Changing this will log out all existing sessions.
|
|
|
|
$wgAuthenticationTokenVersion = "";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
## For attaching licensing metadata to pages, and displaying an
|
|
|
|
## appropriate copyright notice / icon. GNU Free Documentation
|
|
|
|
## License and Creative Commons licenses are supported so far.
|
|
|
|
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
|
|
|
|
$wgRightsUrl = "";
|
|
|
|
$wgRightsText = "";
|
|
|
|
$wgRightsIcon = "";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Path to the GNU diff3 utility. Used for conflict resolution.
|
|
|
|
$wgDiff = "/usr/bin/diff";
|
|
|
|
$wgDiff3 = "/usr/bin/diff3";
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Enabled skins.
|
|
|
|
wfLoadSkin('MonoBook');
|
|
|
|
wfLoadSkin('Timeless');
|
|
|
|
wfLoadSkin('Vector');
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# Enabled extensions.
|
|
|
|
wfLoadExtension('OpenIDConnect');
|
|
|
|
wfLoadExtension('PluggableAuth');
|
|
|
|
wfLoadExtension('VisualEditor');
|
2024-01-08 13:14:34 +00:00
|
|
|
wfLoadExtension('TemplateStyles');
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
# End of automatically generated settings.
|
|
|
|
# Add more configuration options below.
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgLogos = [
|
|
|
|
'svg' => "https://pub.solar/assets/pubsolar.svg",
|
|
|
|
'icon' => "https://pub.solar/assets/pubsolar.svg",
|
|
|
|
'wordmark' => [
|
|
|
|
'src'=> "https://pub.solar/assets/pubsolar.svg",
|
|
|
|
'width'=> 0,
|
|
|
|
'height'=> 0,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
$wgFavicon = 'https://pub.solar/assets/pubsolar.svg';
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
$wgDefaultSkin = 'vector-2022';
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
// https://www.mediawiki.org/wiki/Extension:PluggableAuth#Installation
|
|
|
|
$wgGroupPermissions['*']['autocreateaccount'] = true;
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
// https://www.mediawiki.org/wiki/Extension:PluggableAuth#Configuration
|
|
|
|
$wgPluggableAuth_EnableAutoLogin = false;
|
|
|
|
$wgPluggableAuth_ButtonLabel = 'Login with pub.solar ID';
|
2024-01-27 19:29:30 +00:00
|
|
|
|
2023-10-30 00:22:34 +00:00
|
|
|
// https://www.mediawiki.org/wiki/Extension:OpenID_Connect#Keycloak
|
|
|
|
$wgPluggableAuth_Config[] = [
|
|
|
|
'plugin' => 'OpenIDConnect',
|
|
|
|
'data' => [
|
2024-05-08 17:47:47 +00:00
|
|
|
'providerURL' => 'https://auth.${config.pub-solar-os.networking.domain}/realms/${config.pub-solar-os.auth.realm}',
|
2023-10-30 00:22:34 +00:00
|
|
|
'clientID' => 'mediawiki',
|
|
|
|
'clientsecret' => trim(file_get_contents('/run/mediawiki/oidc-client-secret'))
|
|
|
|
]
|
|
|
|
];
|
|
|
|
$wgOpenIDConnect_SingleLogout = true;
|
|
|
|
$wgOpenIDConnect_MigrateUsersByEmail = true;
|
|
|
|
'';
|
|
|
|
|
|
|
|
uid = 986;
|
|
|
|
gid = 984;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
age.secrets.mediawiki-database-password = {
|
|
|
|
file = "${flake.self}/secrets/mediawiki-database-password.age";
|
|
|
|
path = "/run/mediawiki/database-password";
|
|
|
|
symlink = false;
|
|
|
|
mode = "440";
|
|
|
|
owner = "mediawiki";
|
|
|
|
group = "mediawiki";
|
|
|
|
};
|
|
|
|
|
|
|
|
age.secrets.mediawiki-oidc-client-secret = {
|
|
|
|
file = "${flake.self}/secrets/mediawiki-oidc-client-secret.age";
|
|
|
|
path = "/run/mediawiki/oidc-client-secret";
|
|
|
|
symlink = false;
|
|
|
|
mode = "440";
|
|
|
|
owner = "mediawiki";
|
|
|
|
group = "mediawiki";
|
|
|
|
};
|
|
|
|
|
|
|
|
age.secrets.mediawiki-secret-key = {
|
|
|
|
file = "${flake.self}/secrets/mediawiki-secret-key.age";
|
|
|
|
path = "/run/mediawiki/secret-key";
|
|
|
|
symlink = false;
|
|
|
|
mode = "440";
|
|
|
|
owner = "mediawiki";
|
|
|
|
group = "mediawiki";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
authentication = ''
|
|
|
|
host mediawiki all 172.17.0.0/16 password
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
services.nginx.virtualHosts."wiki.${config.pub-solar-os.networking.domain}" = {
|
2023-10-30 00:22:34 +00:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:8293";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.mediawiki = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "mediawiki";
|
|
|
|
inherit uid;
|
|
|
|
};
|
|
|
|
users.groups.mediawiki = {
|
|
|
|
inherit gid;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualisation = {
|
|
|
|
oci-containers = {
|
|
|
|
backend = "docker";
|
|
|
|
|
|
|
|
containers."mediawiki" = {
|
2024-07-15 16:51:10 +00:00
|
|
|
image = "git.pub.solar/pub-solar/mediawiki-oidc-docker:1.42.1";
|
2023-10-30 00:22:34 +00:00
|
|
|
user = "1000:${builtins.toString gid}";
|
|
|
|
autoStart = true;
|
|
|
|
|
|
|
|
ports = [ "127.0.0.1:8293:80" ];
|
|
|
|
|
|
|
|
extraOptions = [
|
|
|
|
"--add-host=host.docker.internal:host-gateway"
|
|
|
|
"--pull=always"
|
|
|
|
];
|
|
|
|
|
|
|
|
volumes = [
|
|
|
|
"/run/mediawiki:/run/mediawiki"
|
|
|
|
"/var/lib/mediawiki/images:/var/www/html/images"
|
|
|
|
"/var/lib/mediawiki/uploads:/var/www/html/uploads"
|
|
|
|
"/var/lib/mediawiki/logs:/var/log/mediawiki"
|
|
|
|
"${localSettingsPHP}:/var/www/html/LocalSettings.php"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-08-25 00:33:55 +00:00
|
|
|
|
|
|
|
services.restic.backups.mediawiki-garage = {
|
|
|
|
paths = [
|
|
|
|
"/var/lib/mediawiki/images"
|
|
|
|
"/var/lib/mediawiki/uploads"
|
|
|
|
"/tmp/mediawiki-backup.sql"
|
|
|
|
];
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "*-*-* 00:30:00 Etc/UTC";
|
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-garage-nachtigall".path;
|
|
|
|
environmentFile = config.age.secrets."restic-repo-garage-nachtigall-env".path;
|
|
|
|
repository = "s3:https://buckets.pub.solar/mediawiki-backups";
|
|
|
|
backupPrepareCommand = ''
|
|
|
|
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d mediawiki > /tmp/mediawiki-backup.sql
|
|
|
|
'';
|
|
|
|
backupCleanupCommand = ''
|
|
|
|
rm /tmp/mediawiki-backup.sql
|
|
|
|
'';
|
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 4"
|
|
|
|
"--keep-monthly 3"
|
|
|
|
];
|
|
|
|
};
|
2023-10-30 00:22:34 +00:00
|
|
|
}
|