diff --git a/modules/module-list.nix b/modules/module-list.nix index b443a41a64e..6a3a36d5229 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -93,6 +93,7 @@ ./services/ttys/gpm.nix ./services/ttys/mingetty.nix ./services/web-servers/apache-httpd/default.nix + ./services/web-servers/apache-httpd/per-server-options.nix ./services/web-servers/jboss.nix ./services/web-servers/tomcat.nix ./services/x11/desktop-managers/default.nix diff --git a/modules/services/web-servers/apache-httpd/default.nix b/modules/services/web-servers/apache-httpd/default.nix index 55902f9e5e0..20373ba7fe6 100644 --- a/modules/services/web-servers/apache-httpd/default.nix +++ b/modules/services/web-servers/apache-httpd/default.nix @@ -33,24 +33,12 @@ let fullConfig = config; # machine config }; - - 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; - + vhosts = mainCfg.virtualHosts; allHosts = [mainCfg] ++ vhosts; - + # !!! This should be replaced by sub-modules to allow non-intrusive + # extensions of NixOS. callSubservices = serverInfo: defs: let f = svc: let @@ -377,13 +365,6 @@ in "; }; - extraConfig = mkOption { - default = ""; - description = " - These configuration lines will be passed verbatim to the apache config - "; - }; - extraModules = mkOption { default = []; example = [ "proxy_connect" { name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; } ]; @@ -446,24 +427,6 @@ in "; }; - virtualHosts = mkOption { - default = []; - example = [ - { hostName = "foo"; - documentRoot = "/data/webroot-foo"; - } - { hostName = "bar"; - documentRoot = "/data/webroot-bar"; - } - ]; - description = '' - Specification of the virtual hosts served by Apache. Each - element should be an attribute set specifying the - configuration of the virtual host. The available options - are the non-global options permissible for the main host. - ''; - }; - subservices = { @@ -542,13 +505,7 @@ in }; - } - - # Include the options shared between the main server and virtual hosts. - // (import ./per-server-options.nix { - inherit mkOption; - forMainServer = true; - }); + }; }; diff --git a/modules/services/web-servers/apache-httpd/per-server-options.nix b/modules/services/web-servers/apache-httpd/per-server-options.nix index 8a2ee0e849a..5f711eef68f 100644 --- a/modules/services/web-servers/apache-httpd/per-server-options.nix +++ b/modules/services/web-servers/apache-httpd/per-server-options.nix @@ -3,8 +3,13 @@ # has additional options that affect the web server as a whole, like # the user/group to run under.) -{forMainServer, mkOption}: +{config, pkgs, ...}: +let + inherit (pkgs.lib) mkOption addDefaultOptionValues; + + perServerOptions = {forMainServer}: +# !!! The following have to be re-indent later. { hostName = mkOption { @@ -135,4 +140,46 @@ "; }; -} +}; + + + vhostOptions = perServerOptions { + forMainServer = false; + }; + +in + +{ + options = { + services.httpd = { + + virtualHosts = mkOption { + default = []; + example = [ + { hostName = "foo"; + documentRoot = "/data/webroot-foo"; + } + { hostName = "bar"; + documentRoot = "/data/webroot-bar"; + } + ]; + description = '' + Specification of the virtual hosts served by Apache. Each + element should be an attribute set specifying the + configuration of the virtual host. The available options + are the non-global options permissible for the main host. + ''; + + # Add the default value for each function which is not defined. + # This should be replaced by sub-modules. + apply = + map (vhost: + addDefaultOptionValues vhostOptions vhost + ); + }; + + } + // perServerOptions {forMainServer = true;} + ; + }; +} \ No newline at end of file