From 7571055ad320acbc9b8ec1422bb7b5c14704c39d Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Thu, 5 Nov 2009 18:21:03 +0000 Subject: [PATCH] * Declare options for sub-services. * Add deprecated options for "serviceType", "serviceName", "function" and "config" without changing the behavior. svn path=/nixos/trunk/; revision=18150 --- modules/module-list.nix | 1 + .../web-servers/apache-httpd/default.nix | 27 ++-- .../apache-httpd/per-server-options.nix | 9 +- .../web-servers/apache-httpd/services.nix | 131 ++++++++++++++++++ 4 files changed, 141 insertions(+), 27 deletions(-) create mode 100644 modules/services/web-servers/apache-httpd/services.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 6a3a36d5229..4addbda5760 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -94,6 +94,7 @@ ./services/ttys/mingetty.nix ./services/web-servers/apache-httpd/default.nix ./services/web-servers/apache-httpd/per-server-options.nix + ./services/web-servers/apache-httpd/services.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 53116191b70..76b2bea4e9f 100644 --- a/modules/services/web-servers/apache-httpd/default.nix +++ b/modules/services/web-servers/apache-httpd/default.nix @@ -41,25 +41,14 @@ let # extensions of NixOS. callSubservices = serverInfo: defs: let f = svc: - let - svcFunction = - if svc ? function then svc.function - else import "${./.}/${if svc ? serviceType then svc.serviceType else svc.serviceName}.nix"; - config = addDefaultOptionValues res.options - (if svc ? config then svc.config else svc); - defaults = { - extraConfig = ""; - extraModules = []; - extraModulesPre = []; - extraPath = []; - extraServerPath = []; - globalEnvVars = []; - robotsEntries = ""; - startupScript = ""; - options = {}; - }; - res = defaults // svcFunction {inherit config pkgs serverInfo servicesPath;}; - in res; + rec { + config = + if res ? options then + addDefaultOptionValues res.options svc.config + else + svc.config; + res = svc // svc.function {inherit config pkgs serverInfo servicesPath;}; + }.res; in map f defs; 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 0029e1293cb..6e98b8685fa 100644 --- a/modules/services/web-servers/apache-httpd/per-server-options.nix +++ b/modules/services/web-servers/apache-httpd/per-server-options.nix @@ -3,7 +3,7 @@ # has additional options that affect the web server as a whole, like # the user/group to run under.) -{options, config, pkgs, ...}@moduleArguments: +{options, config, pkgs, ...}: let inherit (pkgs.lib) mkOption addDefaultOptionValues types; @@ -122,13 +122,6 @@ let "; }; - extraSubservices = mkOption { - default = []; - description = " - Extra subservices to enable in the webserver. - "; - }; - enableUserDir = mkOption { default = false; description = " diff --git a/modules/services/web-servers/apache-httpd/services.nix b/modules/services/web-servers/apache-httpd/services.nix new file mode 100644 index 00000000000..f8d95f955cf --- /dev/null +++ b/modules/services/web-servers/apache-httpd/services.nix @@ -0,0 +1,131 @@ +{options, config, pkgs, ...}: + +let + inherit (pkgs.lib) mkOption addDefaultOptionValues types; + + mainServerArgs = { + config = config.services.httpd; + options = options.services.httpd; + }; + + subServiceOptions = {options, config, ...}: { + options = { + + extraConfig = mkOption { + default = ""; + description = "Not documented yet."; + }; + + extraModules = mkOption { + default = []; + description = "Not documented yet."; + }; + + extraModulesPre = mkOption { + default = []; + description = "Not documented yet."; + }; + + extraPath = mkOption { + default = []; + description = "Not documented yet."; + }; + + extraServerPath = mkOption { + default = []; + description = "Not documented yet."; + }; + + globalEnvVars = mkOption { + default = []; + description = "Not documented yet."; + }; + + robotsEntries = mkOption { + default = ""; + description = "Not documented yet."; + }; + + startupScript = mkOption { + default = ""; + description = "Not documented yet."; + }; + + + serviceType = mkOption { + default = ""; + description = "Obsolete name of ."; + # serviceType is the old name of serviceName. + apply = x: config.serviceName; + }; + + serviceName = mkOption { + default = ""; + example = "trac"; + description = " + (Deprecated) + + Identify a service by the name of the file containing it. The + service expression is contained inside + ./modules/services/web-servers/apache-httpd + directory. + + Due to lack of documentation, this option will be replaced by + enable flags. + "; + + # serviceName is the new name of serviceType. + extraConfigs = map (def: def.value) options.serviceType.definitions; + }; + + function = mkOption { + default = null; + description = " + (Deprecated) Add a function which configure the current sub-service. + "; + apply = f: + if isNull f then + import "${./.}/${config.serviceName}.nix" + else + f; + }; + + config = mkOption { + default = {}; + description = " + (Deprecated) Define option values of the current sub-service. + "; + }; + + }; + }; + + + perServerOptions = {config, ...}: { + + extraSubservices = mkOption { + default = []; + type = with types; listOf optionSet; + description = " + Extra subservices to enable in the webserver. + "; + options = [ subServiceOptions ]; + }; + + }; + +in + +{ + options = { + services.httpd = { + + virtualHosts = mkOption { + options = [ perServerOptions ]; + }; + + } + // perServerOptions mainServerArgs + ; + }; +}