From f8a9eb9f00ae84bc2daef9b78d2bd5153ffe81b6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 28 Oct 2013 21:58:32 +0100 Subject: [PATCH] Implement services.httpd.virtualHosts using the module system --- .../web-servers/apache-httpd/default.nix | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index e2cfc5cdb265..7688b04f1c1b 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -38,21 +38,7 @@ let }; - vhostOptions = import ./per-server-options.nix { - inherit mkOption; - forMainServer = false; - }; - - vhosts = let - makeVirtualHost = cfgIn: - let - # Fill in defaults for missing options. - cfg = addDefaultOptionValues vhostOptions cfgIn; - in cfg; - in map makeVirtualHost mainCfg.virtualHosts; - - - allHosts = [mainCfg] ++ vhosts; + allHosts = [mainCfg] ++ mainCfg.virtualHosts; callSubservices = serverInfo: defs: @@ -86,7 +72,7 @@ let mainSubservices = subservicesFor mainCfg; - allSubservices = mainSubservices ++ concatMap subservicesFor vhosts; + allSubservices = mainSubservices ++ concatMap subservicesFor mainCfg.virtualHosts; # !!! should be in lib @@ -389,7 +375,7 @@ let ${perServerConf false vhost} ''; - in concatMapStrings makeVirtualHost vhosts + in concatMapStrings makeVirtualHost mainCfg.virtualHosts } ''; @@ -428,7 +414,7 @@ in package = mkOption { default = pkgs.apacheHttpd.override { mpm = mainCfg.multiProcessingModule; }; - example = "pkgs.apacheHttpd_2_4"; + example = "pkgs.apacheHttpd_2_4"; description = " Overridable attribute of the Apache HTTP Server package to use. "; @@ -436,7 +422,7 @@ in configFile = mkOption { default = confFile; - example = ''pkgs.writeText "httpd.conf" "# my custom config file ...";''; + example = literalExample ''pkgs.writeText "httpd.conf" "# my custom config file ...";''; description = " Overridable config file to use for Apache. By default, use the file automatically generated by nixos. @@ -507,6 +493,12 @@ in }; virtualHosts = mkOption { + type = types.listOf (types.submodule ( + { options = import ./per-server-options.nix { + inherit mkOption; + forMainServer = false; + }; + })); default = []; example = [ { hostName = "foo";