From 0de982d75bc0edddbd1dd61467eb6445eb561109 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Sep 2014 19:04:59 +0200 Subject: [PATCH] httpd: Add option for specifying robots.txt --- .../services/web-servers/apache-httpd/default.nix | 7 ++++--- .../apache-httpd/per-server-options.nix | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index c452cd126ff..85458a2ab56 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -209,10 +209,11 @@ let ''; robotsTxt = - concatStringsSep "\n" ( + concatStringsSep "\n" (filter (x: x != "") ( # If this is a vhost, the include the entries for the main server as well. - (if isMainServer then [] else map (svc: svc.robotsEntries) mainSubservices) - ++ (map (svc: svc.robotsEntries) subservices)); + (if isMainServer then [] else [mainCfg.robotsEntries] ++ map (svc: svc.robotsEntries) mainSubservices) + ++ [cfg.robotsEntries] + ++ (map (svc: svc.robotsEntries) subservices))); in '' ServerName ${serverInfo.canonicalName} diff --git a/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix b/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix index b8e86334539..76f55a63e32 100644 --- a/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix +++ b/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix @@ -142,9 +142,19 @@ with lib; type = types.str; default = "common"; example = "combined"; - description = " + description = '' Log format for Apache's log files. Possible values are: combined, common, referer, agent. - "; + ''; + }; + + robotsEntries = mkOption { + type = types.lines; + default = ""; + example = "Disallow: /foo/"; + description = '' + Specification of pages to be ignored by web crawlers. See for details. + ''; }; }