From 84c4c6556ea039e62a28510f372a4e9e683a275d Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Tue, 3 Feb 2026 14:46:33 -0600 Subject: [PATCH 1/4] modularize media wiki --- modules/mediawiki/default.nix | 13 +++++++ modules/mediawiki/options.nix | 72 +++++++++++++++++++++++++++++++++++ modules/mediawiki/sys.nix | 31 +++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 modules/mediawiki/default.nix create mode 100644 modules/mediawiki/options.nix create mode 100644 modules/mediawiki/sys.nix diff --git a/modules/mediawiki/default.nix b/modules/mediawiki/default.nix new file mode 100644 index 0000000..2ed69c2 --- /dev/null +++ b/modules/mediawiki/default.nix @@ -0,0 +1,13 @@ +{ + config, + lib, + pkgs, + doctrine, + ... +}: +doctrine.lib.mkModule { + inherit config; + name = "mediawiki"; + sys = ./sys.nix; + options = ./options.nix; +} diff --git a/modules/mediawiki/options.nix b/modules/mediawiki/options.nix new file mode 100644 index 0000000..06acbf1 --- /dev/null +++ b/modules/mediawiki/options.nix @@ -0,0 +1,72 @@ +{lib, ...}: +with lib.types; { + sys = { + hostName = lib.mkOption { + type = str; + description = "used for nginx virtualhost. no protocol"; + example = "wiki.posixlycorrect.com"; + }; + + name = lib.mkOption { + type = str; + description = "name of the wiki"; + example = "posixlycorrect wiki"; + }; + + passwordFile = lib.mkOption { + type = types.path; + description = "path of passwordfile for mediawiki"; + example = "/run/keys/mediawiki-password"; + }; + + skins = lib.mkOption { + type = types.attrsOf (types.nullOr str); + description = "skins for mediawiki"; + example = ''{ + citizen = "flakes.mediawikiSkinCitizen"; + };''; + }; + + extraConfig = lib.mkOption { + type = str; + example = '' + # Disable anonymous editing and account creation + $wgGroupPermissions['*']['edit'] = false; + $wgGroupPermissions['*']['createaccount'] = false; + + $wgCitizenThemeDefault = 'dark'; + $wgCitizenShowPageTools = 'login'; + $wgLogos = [ + 'icon' => "https://example.com/favicon.png", + '1x' => "https://example.com/favicon.png", + '2x' => "https://example.com/favicon.png", + ]; + + $wgEnableEmail = false; #TODO: arreglar esto + $wgNoReplyAddress = 'mediawiki@example.com'; + $wgEmergencyContact = 'mediawiki@example.com'; + $wgPasswordSender = 'mediawiki@example.com'; + ''; + }; + + extensions = lib.mkOption { + type = types.attrsOf (types.nullOr types.path); + description = "some extensions are included and can enabled by passing null"; + example = ''{ + VisualEditor = null; + CategoryTree = null; + CiteThisPage = null; + Scribunto = null; + Cite = null; + CodeEditor = null; + Math = null; + MultimediaViewer = null; + PdfHandler = null; + Poem = null; + SecureLinkFixer = null; + WikiEditor = null; + ParserFunctions = null; + };''; + }; + }; +} diff --git a/modules/mediawiki/sys.nix b/modules/mediawiki/sys.nix new file mode 100644 index 0000000..525ec3e --- /dev/null +++ b/modules/mediawiki/sys.nix @@ -0,0 +1,31 @@ +{ + pkgs, + lib, + cfg, + doctrine, + ... +}: with lib; { + services = { + nginx = { + virtualHosts.${cfg.hostName} = { + enableACME = true; + forceSSL = true; + extraConfig = '' + proxy_headers_hash_max_size 512; + proxy_headers_hash_bucket_size 128; + ''; + }; + }; + mediawiki = { + enable = true; + name = cfg.name; + webserver = "nginx"; + nginx.hostName = cfg.hostName; + database.type = "postgres"; + passwordFile = cfg.passwordFile; + skins = cfg.skins; + extraConfig = cfg.extraConfig; + extensions = cfg.extensions; + }; + }; +} From 6e15b6b370add1684d22e88f4276ecdc18d05a03 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Tue, 3 Feb 2026 15:30:40 -0600 Subject: [PATCH 2/4] trivionomicon: mediawiki: add blank defaults --- modules/mediawiki/options.nix | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/modules/mediawiki/options.nix b/modules/mediawiki/options.nix index 06acbf1..dc01a74 100644 --- a/modules/mediawiki/options.nix +++ b/modules/mediawiki/options.nix @@ -22,6 +22,7 @@ with lib.types; { skins = lib.mkOption { type = types.attrsOf (types.nullOr str); description = "skins for mediawiki"; + default = {}; example = ''{ citizen = "flakes.mediawikiSkinCitizen"; };''; @@ -29,29 +30,18 @@ with lib.types; { extraConfig = lib.mkOption { type = str; + default = ""; example = '' # Disable anonymous editing and account creation $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; - - $wgCitizenThemeDefault = 'dark'; - $wgCitizenShowPageTools = 'login'; - $wgLogos = [ - 'icon' => "https://example.com/favicon.png", - '1x' => "https://example.com/favicon.png", - '2x' => "https://example.com/favicon.png", - ]; - - $wgEnableEmail = false; #TODO: arreglar esto - $wgNoReplyAddress = 'mediawiki@example.com'; - $wgEmergencyContact = 'mediawiki@example.com'; - $wgPasswordSender = 'mediawiki@example.com'; ''; }; extensions = lib.mkOption { type = types.attrsOf (types.nullOr types.path); description = "some extensions are included and can enabled by passing null"; + default = {}; example = ''{ VisualEditor = null; CategoryTree = null; From 47390d14a36a30720f152bda440152e6334c6b30 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Wed, 4 Feb 2026 20:35:54 -0600 Subject: [PATCH 3/4] trivionomicon: mediawiki: update passwordFile option description --- modules/mediawiki/options.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mediawiki/options.nix b/modules/mediawiki/options.nix index dc01a74..3ab7894 100644 --- a/modules/mediawiki/options.nix +++ b/modules/mediawiki/options.nix @@ -15,7 +15,7 @@ with lib.types; { passwordFile = lib.mkOption { type = types.path; - description = "path of passwordfile for mediawiki"; + description = "A file containing the initial password for the administrator account 'admin'"; example = "/run/keys/mediawiki-password"; }; From f057233bc5d6b5d86be73261c002c46ed50ad43b Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Sun, 8 Feb 2026 22:51:02 -0600 Subject: [PATCH 4/4] trivionomicon: mediawiki: formatting --- modules/mediawiki/options.nix | 42 +++++++++++++++++------------------ modules/mediawiki/sys.nix | 3 ++- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/modules/mediawiki/options.nix b/modules/mediawiki/options.nix index 3ab7894..bb39a14 100644 --- a/modules/mediawiki/options.nix +++ b/modules/mediawiki/options.nix @@ -12,22 +12,22 @@ with lib.types; { description = "name of the wiki"; example = "posixlycorrect wiki"; }; - + passwordFile = lib.mkOption { type = types.path; description = "A file containing the initial password for the administrator account 'admin'"; example = "/run/keys/mediawiki-password"; }; - + skins = lib.mkOption { type = types.attrsOf (types.nullOr str); description = "skins for mediawiki"; default = {}; - example = ''{ - citizen = "flakes.mediawikiSkinCitizen"; - };''; + example = '' { + citizen = "flakes.mediawikiSkinCitizen"; + };''; }; - + extraConfig = lib.mkOption { type = str; default = ""; @@ -42,21 +42,21 @@ with lib.types; { type = types.attrsOf (types.nullOr types.path); description = "some extensions are included and can enabled by passing null"; default = {}; - example = ''{ - VisualEditor = null; - CategoryTree = null; - CiteThisPage = null; - Scribunto = null; - Cite = null; - CodeEditor = null; - Math = null; - MultimediaViewer = null; - PdfHandler = null; - Poem = null; - SecureLinkFixer = null; - WikiEditor = null; - ParserFunctions = null; - };''; + example = '' { + VisualEditor = null; + CategoryTree = null; + CiteThisPage = null; + Scribunto = null; + Cite = null; + CodeEditor = null; + Math = null; + MultimediaViewer = null; + PdfHandler = null; + Poem = null; + SecureLinkFixer = null; + WikiEditor = null; + ParserFunctions = null; + };''; }; }; } diff --git a/modules/mediawiki/sys.nix b/modules/mediawiki/sys.nix index 525ec3e..b6a9273 100644 --- a/modules/mediawiki/sys.nix +++ b/modules/mediawiki/sys.nix @@ -4,7 +4,8 @@ cfg, doctrine, ... -}: with lib; { +}: +with lib; { services = { nginx = { virtualHosts.${cfg.hostName} = {