summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/apache-httpd/default.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-02-25 07:44:45 -0500
committerShea Levy <shea@shealevy.com>2014-02-25 07:44:45 -0500
commit0d4a9e3aa68da5f82fff724baee9168b50a485c8 (patch)
tree577fd4f5f96be1c7157f0c4e201441b7959e2040 /nixos/modules/services/web-servers/apache-httpd/default.nix
parentec09c7d34e6edf9c503cde439252f0dd5d721a7e (diff)
downloadnixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar.gz
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar.bz2
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar.lz
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar.xz
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.tar.zst
nixlib-0d4a9e3aa68da5f82fff724baee9168b50a485c8.zip
Allow httpd subservices to set the document root
Only the main service OR one of the subservices can set the document
root. This is used by mediawiki when it is hosted at the root of the
vhost.
Diffstat (limited to 'nixos/modules/services/web-servers/apache-httpd/default.nix')
-rw-r--r--nixos/modules/services/web-servers/apache-httpd/default.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix
index b96f5cf159b0..f239d4fd6c35 100644
--- a/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -63,6 +63,7 @@ let
           enablePHP = false;
           phpOptions = "";
           options = {};
+          documentRoot = null;
         };
         res = defaults // svcFunction { inherit config pkgs serverInfo php; };
       in res;
@@ -188,7 +189,11 @@ let
 
     subservices = callSubservices serverInfo cfg.extraSubservices;
 
-    documentRoot = if cfg.documentRoot != null then cfg.documentRoot else
+    maybeDocumentRoot = fold (svc: acc:
+      if acc == null then svc.documentRoot else assert svc.documentRoot == null; acc
+    ) null ([ cfg ] ++ subservices);
+
+    documentRoot = if maybeDocumentRoot != null then maybeDocumentRoot else
       pkgs.runCommand "empty" {} "ensureDir $out";
 
     documentRootConf = ''
@@ -240,7 +245,7 @@ let
 
     ${robotsConf}
 
-    ${if isMainServer || cfg.documentRoot != null then documentRootConf else ""}
+    ${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
 
     ${if cfg.enableUserDir then ''