diff --git a/modules/services/web-servers/apache-httpd/default.nix b/modules/services/web-servers/apache-httpd/default.nix index 20373ba7fe6..e40c6b914df 100644 --- a/modules/services/web-servers/apache-httpd/default.nix +++ b/modules/services/web-servers/apache-httpd/default.nix @@ -10,7 +10,7 @@ let 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; extraForeignModules = filter builtins.isAttrs extraModules; 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 cdb1f72a945..0029e1293cb 100644 --- a/modules/services/web-servers/apache-httpd/per-server-options.nix +++ b/modules/services/web-servers/apache-httpd/per-server-options.nix @@ -3,12 +3,18 @@ # has additional options that affect the web server as a whole, like # the user/group to run under.) -{config, pkgs, ...}: +{options, config, pkgs, ...}@moduleArguments: let inherit (pkgs.lib) mkOption addDefaultOptionValues types; - perServerOptions = {forMainServer}: { + mainServerArgs = { + config = config.services.httpd; + options = options.services.httpd; + }; + + + perServerOptions = {forMainServer}: {config, ...}: { hostName = mkOption { default = "localhost"; @@ -26,10 +32,12 @@ let }; port = mkOption { - default = 0; + default = if config.enableSSL then 443 else 80; + type = with types; uniq int; description = " - Port for the server. 0 means use the default port: 80 for http - and 443 for https (i.e. when enableSSL is set). + Port for the server. The default port depends on the + option of this server. (80 for http and + 443 for https). "; }; @@ -175,7 +183,7 @@ in }; } - // perServerOptions {forMainServer = true;} + // perServerOptions {forMainServer = true;} mainServerArgs ; }; }