Implement services.httpd.virtualHosts using the module system

Changed files
+11 -19
nixos
modules
services
web-servers
apache-httpd
+11 -19
nixos/modules/services/web-servers/apache-httpd/default.nix
···
};
-
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:
···
mainSubservices = subservicesFor mainCfg;
-
allSubservices = mainSubservices ++ concatMap subservicesFor vhosts;
+
allSubservices = mainSubservices ++ concatMap subservicesFor mainCfg.virtualHosts;
# !!! should be in lib
···
${perServerConf false vhost}
</VirtualHost>
'';
-
in concatMapStrings makeVirtualHost vhosts
+
in concatMapStrings makeVirtualHost mainCfg.virtualHosts
}
'';
···
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.
";
···
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.
···
};
virtualHosts = mkOption {
+
type = types.listOf (types.submodule (
+
{ options = import ./per-server-options.nix {
+
inherit mkOption;
+
forMainServer = false;
+
};
+
}));
default = [];
example = [
{ hostName = "foo";