From 0d4a9e3aa68da5f82fff724baee9168b50a485c8 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 25 Feb 2014 07:44:45 -0500 Subject: 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. --- nixos/modules/services/web-servers/apache-httpd/default.nix | 9 +++++++-- nixos/modules/services/web-servers/apache-httpd/mediawiki.nix | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'nixos/modules/services/web-servers') 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 '' diff --git a/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix b/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix index af2e2cae797f..7cb513f63020 100644 --- a/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix +++ b/nixos/modules/services/web-servers/apache-httpd/mediawiki.nix @@ -126,7 +126,7 @@ in ''} - Alias ${config.urlPrefix} ${mediawikiRoot} + ${optionalString (config.urlPrefix != "") "Alias ${config.urlPrefix} ${mediawikiRoot}"} Order allow,deny @@ -139,6 +139,8 @@ in ''} ''; + documentRoot = if config.urlPrefix == "" then mediawikiRoot else null; + enablePHP = true; options = { -- cgit 1.4.1