diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index 9ac28373dacb..c452cd126ffb 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -208,16 +208,11 @@ let ''; - robotsTxt = pkgs.writeText "robots.txt" '' - ${# If this is a vhost, the include the entries for the main server as well. - if isMainServer then "" - else concatMapStrings (svc: svc.robotsEntries) mainSubservices} - ${concatMapStrings (svc: svc.robotsEntries) subservices} - ''; - - robotsConf = '' - Alias /robots.txt ${robotsTxt} - ''; + robotsTxt = + concatStringsSep "\n" ( + # 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)); in '' ServerName ${serverInfo.canonicalName} @@ -245,7 +240,9 @@ let CustomLog ${mainCfg.logDir}/access_log-${cfg.hostName} ${cfg.logFormat} '' else ""} - ${robotsConf} + ${optionalString (robotsTxt != "") '' + Alias /robots.txt ${pkgs.writeText "robots.txt" robotsTxt} + ''} ${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}