2006-12-18 19:46:48 +00:00
|
|
|
{config, pkgs, glibc, pwdutils}:
|
2006-12-18 19:20:03 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2006-12-18 19:46:48 +00:00
|
|
|
getCfg = option: config.get ["services" "httpd" option];
|
2006-12-19 01:03:15 +00:00
|
|
|
getCfgSvn = option: config.get ["services" "httpd" "subservices" "subversion" option];
|
2006-12-18 19:46:48 +00:00
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
optional = conf: subService:
|
|
|
|
if conf then [subService] else [];
|
|
|
|
|
|
|
|
|
|
|
|
hostName = getCfg "hostName";
|
|
|
|
httpPort = getCfg "httpPort";
|
|
|
|
httpsPort = getCfg "httpsPort";
|
2006-12-18 19:46:48 +00:00
|
|
|
user = getCfg "user";
|
|
|
|
group = getCfg "group";
|
2006-12-19 01:03:15 +00:00
|
|
|
adminAddr = getCfg "adminAddr";
|
|
|
|
logDir = getCfg "logDir";
|
|
|
|
stateDir = getCfg "stateDir";
|
|
|
|
enableSSL = false;
|
2006-12-18 19:20:03 +00:00
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
|
2006-12-18 19:20:03 +00:00
|
|
|
webServer = import ../services/apache-httpd {
|
2007-01-04 10:21:25 +00:00
|
|
|
inherit (pkgs) stdenv apacheHttpd coreutils;
|
2006-12-18 19:20:03 +00:00
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
inherit hostName httpPort httpsPort
|
|
|
|
user group adminAddr logDir stateDir;
|
|
|
|
|
|
|
|
subServices =
|
2006-12-18 19:20:03 +00:00
|
|
|
|
2006-12-19 01:03:15 +00: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 21:31:19 +00:00
|
|
|
inherit user group logDir adminAddr;
|
2006-12-19 01:03:15 +00:00
|
|
|
|
|
|
|
canonicalName =
|
|
|
|
if webServer.enableSSL then
|
|
|
|
"https://" + hostName + ":" + (toString httpsPort)
|
|
|
|
else
|
|
|
|
"http://" + hostName + ":" + (toString httpPort);
|
2006-12-18 19:20:03 +00:00
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
notificationSender = getCfgSvn "notificationSender";
|
|
|
|
autoVersioning = getCfgSvn "autoVersioning";
|
2007-02-12 11:57:18 +00:00
|
|
|
userCreationDomain = getCfgSvn "userCreationDomain";
|
2006-12-18 19:20:03 +00:00
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
inherit pkgs;
|
|
|
|
})
|
|
|
|
|
|
|
|
;
|
2006-12-18 19:20:03 +00:00
|
|
|
};
|
|
|
|
|
2006-12-19 01:03:15 +00:00
|
|
|
|
2006-12-18 19:20:03 +00: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 19:46:48 +00:00
|
|
|
|
|
|
|
${webServer}/bin/control prepare
|
2006-12-18 19:20:03 +00:00
|
|
|
end script
|
|
|
|
|
2006-12-18 19:46:48 +00:00
|
|
|
respawn ${webServer}/bin/control run
|
2006-12-18 19:20:03 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|