From 0383b57b3c8103f49002806e20ae3c67a83685db Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Mon, 25 Aug 2014 10:23:10 +0200 Subject: [PATCH 1/2] Added concatMapStringsSep and concatImapStringsSep Example: configure rewrite rules for Mediawiki RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d ${concatMapStringsSep "\n" (u: "RewriteCond %{REQUEST_URI} !^${u.urlPath}") serverInfo.serverConfig.servedDirs} RewriteRule ${if config.enableUploads --- lib/strings.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/strings.nix b/lib/strings.nix index efdc265465f..31b0f56e09b 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -34,6 +34,9 @@ rec { concatStringsSep = separator: list: concatStrings (intersperse separator list); + concatMapStringsSep = sep: f: list: concatStringsSep sep (map f list); + concatImapStringsSep = sep: f: list: concatStringsSep sep (lib.imap f list); + # Construct a Unix-style search path consisting of each `subDir" # directory of the given list of packages. For example, From cdd1785cd6380e971ad0413e7ecfd3af7ab38625 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Mon, 25 Aug 2014 11:55:57 +0200 Subject: [PATCH 2/2] Fixed rewrite rules for Mediawiki If Mediawiki was served from the root directory of the server it was impossible to serve other directories. Make sure that URLs defined in servedDirs are not rewritten. Use case: serving local copy of MathJax --- nixos/modules/services/web-servers/apache-httpd/mediawiki.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix b/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix index aa9aec87f0c..76c64f8cb29 100644 --- a/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix +++ b/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix @@ -133,6 +133,7 @@ in RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d + ${concatMapStringsSep "\n" (u: "RewriteCond %{REQUEST_URI} !^${u.urlPath}") serverInfo.serverConfig.servedDirs} RewriteRule ${if config.enableUploads then "!^/images" else "^.*\$"