2006-12-18 20:46:48 +01:00
|
|
|
{config, pkgs, glibc, pwdutils}:
|
2006-12-18 20:20:03 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2006-12-18 20:46:48 +01:00
|
|
|
getCfg = option: config.get ["services" "httpd" option];
|
2006-12-19 02:03:15 +01:00
|
|
|
getCfgSvn = option: config.get ["services" "httpd" "subservices" "subversion" option];
|
2006-12-18 20:46:48 +01:00
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
optional = conf: subService:
|
|
|
|
if conf then [subService] else [];
|
|
|
|
|
|
|
|
|
|
|
|
hostName = getCfg "hostName";
|
|
|
|
httpPort = getCfg "httpPort";
|
|
|
|
httpsPort = getCfg "httpsPort";
|
2006-12-18 20:46:48 +01:00
|
|
|
user = getCfg "user";
|
|
|
|
group = getCfg "group";
|
2006-12-19 02:03:15 +01:00
|
|
|
adminAddr = getCfg "adminAddr";
|
|
|
|
logDir = getCfg "logDir";
|
|
|
|
stateDir = getCfg "stateDir";
|
|
|
|
enableSSL = false;
|
2006-12-18 20:20:03 +01:00
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
|
2006-12-18 20:20:03 +01:00
|
|
|
webServer = import ../services/apache-httpd {
|
|
|
|
inherit (pkgs) apacheHttpd coreutils;
|
|
|
|
stdenv = pkgs.stdenvNew;
|
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
inherit hostName httpPort httpsPort
|
|
|
|
user group adminAddr logDir stateDir;
|
|
|
|
|
|
|
|
subServices =
|
2006-12-18 20:20:03 +01:00
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
# The Subversion subservice.
|
|
|
|
optional (getCfgSvn "enable") (
|
|
|
|
let dataDir = getCfgSvn "dataDir"; in
|
|
|
|
import ../services/subversion {
|
|
|
|
reposDir = dataDir + "/repos";
|
|
|
|
dbDir = dataDir + "/db";
|
|
|
|
distsDir = dataDir + "/dist";
|
|
|
|
backupsDir = dataDir + "/backup";
|
|
|
|
tmpDir = dataDir + "/tmp";
|
|
|
|
|
2006-12-19 22:31:19 +01:00
|
|
|
inherit user group logDir adminAddr;
|
2006-12-19 02:03:15 +01:00
|
|
|
|
|
|
|
canonicalName =
|
|
|
|
if webServer.enableSSL then
|
|
|
|
"https://" + hostName + ":" + (toString httpsPort)
|
|
|
|
else
|
|
|
|
"http://" + hostName + ":" + (toString httpPort);
|
2006-12-18 20:20:03 +01:00
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
notificationSender = getCfgSvn "notificationSender";
|
|
|
|
autoVersioning = getCfgSvn "autoVersioning";
|
2006-12-18 20:20:03 +01:00
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
inherit pkgs;
|
|
|
|
})
|
|
|
|
|
|
|
|
;
|
2006-12-18 20:20:03 +01:00
|
|
|
};
|
|
|
|
|
2006-12-19 02:03:15 +01:00
|
|
|
|
2006-12-18 20:20:03 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "httpd";
|
|
|
|
|
|
|
|
job = "
|
|
|
|
description \"Apache HTTPD\"
|
|
|
|
|
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
|
|
|
start script
|
|
|
|
if ! ${glibc}/bin/getent group ${group} > /dev/null; then
|
|
|
|
${pwdutils}/sbin/groupadd ${group}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! ${glibc}/bin/getent passwd ${user} > /dev/null; then
|
|
|
|
${pwdutils}/sbin/useradd -g ${group} -d /var/empty -s /noshell \\
|
|
|
|
-c 'Apache httpd user' ${user}
|
|
|
|
fi
|
2006-12-18 20:46:48 +01:00
|
|
|
|
|
|
|
${webServer}/bin/control prepare
|
2006-12-18 20:20:03 +01:00
|
|
|
end script
|
|
|
|
|
2006-12-18 20:46:48 +01:00
|
|
|
respawn ${webServer}/bin/control run
|
2006-12-18 20:20:03 +01:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|