* Convert per-server-options into a module.

svn path=/nixos/trunk/; revision=18105
This commit is contained in:
Nicolas Pierron 2009-11-04 17:00:42 +00:00
parent 46558b31a0
commit 063224bc84
3 changed files with 54 additions and 49 deletions

View File

@ -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

View File

@ -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;
});
};
};

View File

@ -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;}
;
};
}