From f99d9b06586dcbd50765df89a59c76bc87120640 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 2 Dec 2009 17:59:17 +0000 Subject: [PATCH] =?UTF-8?q?*=20Basic=20MediaWiki=20module.=20=20Thanks=20t?= =?UTF-8?q?o=20Dario=20Vodopivec,=20Milan=20Sene=C5=A1i=20and=20=20=20Nasi?= =?UTF-8?q?r=20Shadravan.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/nixos/trunk/; revision=18769 --- .../web-servers/apache-httpd/mediawiki.nix | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 modules/services/web-servers/apache-httpd/mediawiki.nix diff --git a/modules/services/web-servers/apache-httpd/mediawiki.nix b/modules/services/web-servers/apache-httpd/mediawiki.nix new file mode 100644 index 00000000000..b2d6c31299a --- /dev/null +++ b/modules/services/web-servers/apache-httpd/mediawiki.nix @@ -0,0 +1,176 @@ +{ config, pkgs, serverInfo, ... }: + +with pkgs.lib; + +let + + mediawikiConfig = pkgs.writeText "LocalSettings.php" + '' + + ''; + + # Unpack Mediawiki and put the config file in its root directory. + mediawikiRoot = pkgs.stdenv.mkDerivation rec { + name= "mediawiki-1.15.1"; + + src = pkgs.fetchurl { + url = "http://download.wikimedia.org/mediawiki/1.15/${name}.tar.gz"; + sha256 = "0i6sb6p4ng38i8s3az42j6wnw6fpxvv3l9cvraav6wsn2cdj4jh4"; + }; + + buildPhase = "true"; + + installPhase = + '' + ensureDir $out + cp -r * $out + cp ${mediawikiConfig} $out/LocalSettings.php + ''; + }; + +in + +{ + + extraConfig = + '' + Alias ${config.urlPrefix} ${mediawikiRoot} + + + Order allow,deny + Allow from all + DirectoryIndex index.php + + ''; + + options = { + + /* + dbName = mkOption { + example = "wikidb"; + default = "wikidb"; + description = " + Name of the wiki database that holds MediaWiki data. + "; + }; + + dbEmergencyContact = mkOption { + example = "admin@example.com"; + default = "e.dolstra@tudelft.nl"; + description = " + In case of emergency, contact this e-mail. + "; + }; + + dbPasswordSender = mkOption { + example = "passwordrecovery@example.com"; + default = "e.dolstra@tudelft.nl"; + description = " + From which e-mail the recovery password for database users will be sent + "; + }; + + dbType = mkOption { + example = "mysql"; + default = "mysql"; + description = " + Which type of database should be used + "; + }; + + dbServer = mkOption { + example = "10.0.2.2"; + default = "10.0.2.2"; + description = " + The location of the database server, e.g. localhost or remote ip address. + "; + }; + + dbPortNumber = mkOption { + example = "3306"; + default = "3306"; + description = " + Portnumber used to connect to the database server. Default: 3306. + "; + }; + + dbUser = mkOption { + example = "root"; + default = "root"; + description = " + The username for accessing the database. + "; + }; + + dbPassword = mkOption { + example = "foobar"; + default = ""; + description = " + The dbUser's password. + "; + }; + + dbSiteName = mkOption { + example = "wikipedia"; + default = "wiki"; + description = " + Name of the wiki site. + "; + }; + */ + + urlPrefix = mkOption { + example = "/wiki"; + default = "/wiki"; + description = '' + The URL prefix under which the Mediawiki service appears. + ''; + }; + + }; + + startupScript = pkgs.writeScript "mediawiki_startup.sh" + '' + if ! ${pkgs.postgresql}/bin/psql -l | grep -q ' mediawiki ' ; then + ${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole wwwrun || true + ${pkgs.postgresql}/bin/createdb mediawiki -O wwwrun + ${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} wwwrun -c "(echo 'CREATE LANGUAGE plpgsql;'; cat /nix/store/q9gdf3f4362yhsdi8inlhpk26d9b8af6-mediawiki-1.15.1/maintenance/postgres/tables.sql; echo 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english );'; echo COMMIT) | ${pkgs.postgresql}/bin/psql mediawiki" + fi + ''; + +}