* Convert per-server-options into a module.
svn path=/nixos/trunk/; revision=18105
This commit is contained in:
parent
46558b31a0
commit
063224bc84
|
@ -93,6 +93,7 @@
|
||||||
./services/ttys/gpm.nix
|
./services/ttys/gpm.nix
|
||||||
./services/ttys/mingetty.nix
|
./services/ttys/mingetty.nix
|
||||||
./services/web-servers/apache-httpd/default.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/jboss.nix
|
||||||
./services/web-servers/tomcat.nix
|
./services/web-servers/tomcat.nix
|
||||||
./services/x11/desktop-managers/default.nix
|
./services/x11/desktop-managers/default.nix
|
||||||
|
|
|
@ -33,24 +33,12 @@ let
|
||||||
fullConfig = config; # machine config
|
fullConfig = config; # machine config
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vhosts = mainCfg.virtualHosts;
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
allHosts = [mainCfg] ++ vhosts;
|
allHosts = [mainCfg] ++ vhosts;
|
||||||
|
|
||||||
|
# !!! This should be replaced by sub-modules to allow non-intrusive
|
||||||
|
# extensions of NixOS.
|
||||||
callSubservices = serverInfo: defs:
|
callSubservices = serverInfo: defs:
|
||||||
let f = svc:
|
let f = svc:
|
||||||
let
|
let
|
||||||
|
@ -377,13 +365,6 @@ in
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "
|
|
||||||
These configuration lines will be passed verbatim to the apache config
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraModules = mkOption {
|
extraModules = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
example = [ "proxy_connect" { name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; } ];
|
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 = {
|
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,13 @@
|
||||||
# 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.)
|
||||||
|
|
||||||
{forMainServer, mkOption}:
|
{config, pkgs, ...}:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) mkOption addDefaultOptionValues;
|
||||||
|
|
||||||
|
perServerOptions = {forMainServer}:
|
||||||
|
# !!! The following have to be re-indent later.
|
||||||
{
|
{
|
||||||
|
|
||||||
hostName = mkOption {
|
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;}
|
||||||
|
;
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue