3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/upstart-jobs/httpd.nix
Eelco Dolstra 2d6e8e63ae * Forgot to commit.
svn path=/nixos/trunk/; revision=7430
2006-12-19 21:31:19 +00:00

88 lines
2.1 KiB
Nix

{config, pkgs, glibc, pwdutils}:
let
getCfg = option: config.get ["services" "httpd" option];
getCfgSvn = option: config.get ["services" "httpd" "subservices" "subversion" option];
optional = conf: subService:
if conf then [subService] else [];
hostName = getCfg "hostName";
httpPort = getCfg "httpPort";
httpsPort = getCfg "httpsPort";
user = getCfg "user";
group = getCfg "group";
adminAddr = getCfg "adminAddr";
logDir = getCfg "logDir";
stateDir = getCfg "stateDir";
enableSSL = false;
webServer = import ../services/apache-httpd {
inherit (pkgs) apacheHttpd coreutils;
stdenv = pkgs.stdenvNew;
inherit hostName httpPort httpsPort
user group adminAddr logDir stateDir;
subServices =
# 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";
inherit user group logDir adminAddr;
canonicalName =
if webServer.enableSSL then
"https://" + hostName + ":" + (toString httpsPort)
else
"http://" + hostName + ":" + (toString httpPort);
notificationSender = getCfgSvn "notificationSender";
autoVersioning = getCfgSvn "autoVersioning";
inherit pkgs;
})
;
};
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
${webServer}/bin/control prepare
end script
respawn ${webServer}/bin/control run
";
}