Give types to the Apache httpd options

This commit is contained in:
Eelco Dolstra 2013-10-29 14:03:39 +01:00
parent 0afdb1e933
commit 985f1f2d8a
2 changed files with 90 additions and 75 deletions

View file

@ -30,7 +30,7 @@ let
# Admin address: inherit from the main server if not specified for
# a virtual host.
adminAddr = if cfg.adminAddr != "" then cfg.adminAddr else mainCfg.adminAddr;
adminAddr = if cfg.adminAddr != null then cfg.adminAddr else mainCfg.adminAddr;
vhostConfig = cfg;
serverConfig = mainCfg;
@ -217,7 +217,7 @@ let
${concatMapStrings (alias: "ServerAlias ${alias}\n") cfg.serverAliases}
${if cfg.sslServerCert != "" then ''
${if cfg.sslServerCert != null then ''
SSLCertificateFile ${cfg.sslServerCert}
SSLCertificateKeyFile ${cfg.sslServerKey}
'' else ""}
@ -229,7 +229,7 @@ let
SSLEngine off
'' else ""}
${if isMainServer || cfg.adminAddr != "" then ''
${if isMainServer || cfg.adminAddr != null then ''
ServerAdmin ${cfg.adminAddr}
'' else ""}
@ -260,7 +260,7 @@ let
'' else ""}
${if cfg.globalRedirect != "" then ''
${if cfg.globalRedirect != null then ''
RedirectPermanent / ${cfg.globalRedirect}
'' else ""}
@ -408,96 +408,104 @@ in
services.httpd = {
enable = mkOption {
type = types.bool;
default = false;
description = "
Whether to enable the Apache httpd server.
";
description = "Whether to enable the Apache HTTP Server.";
};
package = mkOption {
type = types.path;
default = pkgs.apacheHttpd.override { mpm = mainCfg.multiProcessingModule; };
example = "pkgs.apacheHttpd_2_4";
description = "
description = ''
Overridable attribute of the Apache HTTP Server package to use.
";
'';
};
configFile = mkOption {
type = types.path;
default = confFile;
example = literalExample ''pkgs.writeText "httpd.conf" "# my custom config file ...";'';
description = "
Overridable config file to use for Apache. By default, use the
file automatically generated by nixos.
";
description = ''
Override the configuration file used by Apache. By default,
NixOS generates one automatically.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "
These configuration lines will be appended to the Apache config
file. Note that this mechanism may not work when <option>configFile</option>
is overridden.
";
description = ''
Cnfiguration lines appended to the generated Apache
configuration file. Note that this mechanism may not work
when <option>configFile</option> is overridden.
'';
};
extraModules = mkOption {
type = types.listOf types.unspecified;
default = [];
example = [ "proxy_connect" { name = "php5"; path = "${php}/modules/libphp5.so"; } ];
description = ''
Specifies additional Apache modules. These can be specified
as a string in the case of modules distributed with Apache,
or as an attribute set specifying the
Additional Apache modules to be used. These can be
specified as a string in the case of modules distributed
with Apache, or as an attribute set specifying the
<varname>name</varname> and <varname>path</varname> of the
module.
'';
};
logPerVirtualHost = mkOption {
type = types.bool;
default = false;
description = "
description = ''
If enabled, each virtual host gets its own
<filename>access_log</filename> and
<filename>error_log</filename>, namely suffixed by the
<option>hostName</option> of the virtual host.
";
'';
};
user = mkOption {
type = types.str;
default = "wwwrun";
description = "
description = ''
User account under which httpd runs. The account is created
automatically if it doesn't exist.
";
'';
};
group = mkOption {
type = types.str;
default = "wwwrun";
description = "
description = ''
Group under which httpd runs. The account is created
automatically if it doesn't exist.
";
'';
};
logDir = mkOption {
type = types.path;
default = "/var/log/httpd";
description = "
description = ''
Directory for Apache's log files. It is created automatically.
";
'';
};
stateDir = mkOption {
default = "/var/run/httpd";
description = "
type = types.path;
default = "/run/httpd";
description = ''
Directory for Apache's transient runtime state (such as PID
files). It is created automatically. Note that the default,
<filename>/var/run/httpd</filename>, is deleted at boot time.
";
<filename>/run/httpd</filename>, is deleted at boot time.
'';
};
virtualHosts = mkOption {
type = types.listOf (types.submodule (
{ options = import ./per-server-options.nix {
inherit mkOption;
inherit pkgs;
forMainServer = false;
};
}));
@ -519,6 +527,7 @@ in
};
phpOptions = mkOption {
type = types.lines;
default = "";
example =
''
@ -529,9 +538,9 @@ in
};
multiProcessingModule = mkOption {
type = types.str;
default = "prefork";
example = "worker";
type = types.uniq types.string;
description =
''
Multi-processing module to be used by Apache. Available
@ -546,12 +555,14 @@ in
};
maxClients = mkOption {
type = types.int;
default = 150;
example = 8;
description = "Maximum number of httpd processes (prefork)";
};
maxRequestsPerChild = mkOption {
type = types.int;
default = 0;
example = 500;
description =
@ -561,7 +572,7 @@ in
# Include the options shared between the main server and virtual hosts.
// (import ./per-server-options.nix {
inherit mkOption;
inherit pkgs;
forMainServer = true;
});

View file

@ -3,38 +3,40 @@
# has additional options that affect the web server as a whole, like
# the user/group to run under.)
{forMainServer, mkOption}:
{ forMainServer, pkgs }:
with pkgs.lib;
{
hostName = mkOption {
type = types.str;
default = "localhost";
description = "
Canonical hostname for the server.
";
description = "Canonical hostname for the server.";
};
serverAliases = mkOption {
type = types.listOf types.str;
default = [];
example = ["www.example.org" "www.example.org:8080" "example.org"];
description = "
description = ''
Additional names of virtual hosts served by this virtual host configuration.
";
'';
};
port = mkOption {
type = types.int;
default = 0;
description = "
description = ''
Port for the server. 0 means use the default port: 80 for http
and 443 for https (i.e. when enableSSL is set).
";
'';
};
enableSSL = mkOption {
type = types.bool;
default = false;
description = "
Whether to enable SSL (https) support.
";
description = "Whether to enable SSL (https) support.";
};
# Note: sslServerCert and sslServerKey can be left empty, but this
@ -42,62 +44,62 @@
# main server).
sslServerCert = mkOption {
default = "";
type = types.nullOr types.path;
default = null;
example = "/var/host.cert";
description = "
Path to server SSL certificate.
";
description = "Path to server SSL certificate.";
};
sslServerKey = mkOption {
default = "";
type = types.path;
example = "/var/host.key";
description = "
Path to server SSL certificate key.
";
description = "Path to server SSL certificate key.";
};
adminAddr = mkOption ({
type = types.nullOr types.str;
example = "admin@example.org";
description = "
E-mail address of the server administrator.
";
} // (if forMainServer then {} else {default = "";}));
description = "E-mail address of the server administrator.";
} // (if forMainServer then {} else {default = null;}));
documentRoot = mkOption {
type = types.nullOr types.path;
default = null;
example = "/data/webserver/docs";
description = "
description = ''
The path of Apache's document root directory. If left undefined,
an empty directory in the Nix store will be used as root.
";
'';
};
servedDirs = mkOption {
type = types.listOf types.attrs;
default = [];
example = [
{ urlPath = "/nix";
dir = "/home/eelco/Dev/nix-homepage";
}
];
description = "
description = ''
This option provides a simple way to serve static directories.
";
'';
};
servedFiles = mkOption {
type = types.listOf types.attrs;
default = [];
example = [
{ urlPath = "/foo/bar.png";
dir = "/home/eelco/some-file.png";
}
];
description = "
description = ''
This option provides a simple way to serve individual, static files.
";
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
<Directory /home>
@ -105,37 +107,39 @@
AllowOverride All
</Directory>
'';
description = "
description = ''
These lines go to httpd.conf verbatim. They will go after
directories and directory aliases defined by default.
";
'';
};
extraSubservices = mkOption {
type = types.listOf types.unspecified;
default = [];
description = "
Extra subservices to enable in the webserver.
";
description = "Extra subservices to enable in the webserver.";
};
enableUserDir = mkOption {
type = types.bool;
default = false;
description = "
description = ''
Whether to enable serving <filename>~/public_html</filename> as
<literal>/~<replaceable>username</replaceable></literal>.
";
'';
};
globalRedirect = mkOption {
default = "";
type = types.nullOr types.str;
default = null;
example = http://newserver.example.org/;
description = "
description = ''
If set, all requests for this host are redirected permanently to
the given URL.
";
'';
};
logFormat = mkOption {
type = types.str;
default = "common";
example = "combined";
description = "