Implement services.httpd.virtualHosts using the module system

This commit is contained in:
Eelco Dolstra 2013-10-28 21:58:32 +01:00
parent 30a36f9a80
commit f8a9eb9f00

View File

@ -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}
</VirtualHost>
'';
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";