* Remove needs to call getPort to access the server port. This is made

possible by using sub-modules arguments.

svn path=/nixos/trunk/; revision=18112
This commit is contained in:
Nicolas Pierron 2009-11-04 18:14:42 +00:00
parent 0e22df1587
commit 8734b7103e
2 changed files with 15 additions and 7 deletions

View File

@ -10,7 +10,7 @@ let
httpd = pkgs.apacheHttpd; httpd = pkgs.apacheHttpd;
getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80; getPort = cfg: cfg.port;
extraModules = attrByPath ["extraModules"] [] mainCfg; extraModules = attrByPath ["extraModules"] [] mainCfg;
extraForeignModules = filter builtins.isAttrs extraModules; extraForeignModules = filter builtins.isAttrs extraModules;

View File

@ -3,12 +3,18 @@
# has additional options that affect the web server as a whole, like # has additional options that affect the web server as a whole, like
# the user/group to run under.) # the user/group to run under.)
{config, pkgs, ...}: {options, config, pkgs, ...}@moduleArguments:
let let
inherit (pkgs.lib) mkOption addDefaultOptionValues types; inherit (pkgs.lib) mkOption addDefaultOptionValues types;
perServerOptions = {forMainServer}: { mainServerArgs = {
config = config.services.httpd;
options = options.services.httpd;
};
perServerOptions = {forMainServer}: {config, ...}: {
hostName = mkOption { hostName = mkOption {
default = "localhost"; default = "localhost";
@ -26,10 +32,12 @@ let
}; };
port = mkOption { port = mkOption {
default = 0; default = if config.enableSSL then 443 else 80;
type = with types; uniq int;
description = " description = "
Port for the server. 0 means use the default port: 80 for http Port for the server. The default port depends on the
and 443 for https (i.e. when enableSSL is set). <option>enableSSL</option> option of this server. (80 for http and
443 for https).
"; ";
}; };
@ -175,7 +183,7 @@ in
}; };
} }
// perServerOptions {forMainServer = true;} // perServerOptions {forMainServer = true;} mainServerArgs
; ;
}; };
} }