diff --git a/configuration/options.nix b/configuration/options.nix index 3dc02e6c14d..bcad035849f 100644 --- a/configuration/options.nix +++ b/configuration/options.nix @@ -207,4 +207,13 @@ } + { + name = ["services" "httpd" "enable"]; + default = false; + description = " + Whether to enable the Apache httpd server. + "; + } + + ] diff --git a/configuration/upstart.nix b/configuration/upstart.nix index 210ea6a5f40..4a7e124c271 100644 --- a/configuration/upstart.nix +++ b/configuration/upstart.nix @@ -76,6 +76,13 @@ import ../upstart-jobs/gather.nix { inherit (pkgs.xorg) xorgserver xf86inputkeyboard xf86inputmouse xf86videovesa; }) + # Apache httpd. + ++ optional ["services" "httpd" "enable"] + (import ../upstart-jobs/httpd.nix { + inherit pkgs; + inherit (pkgs) glibc pwdutils; + }) + # Handles the reboot/halt events. ++ (map (event: makeJob (import ../upstart-jobs/halt.nix { diff --git a/upstart-jobs/httpd.nix b/upstart-jobs/httpd.nix new file mode 100644 index 00000000000..80f24a01766 --- /dev/null +++ b/upstart-jobs/httpd.nix @@ -0,0 +1,50 @@ +{pkgs, glibc, pwdutils}: + +let + + user = "wwwrun"; + group = "wwwrun"; + + webServer = import ../services/apache-httpd { + inherit (pkgs) apacheHttpd coreutils; + stdenv = pkgs.stdenvNew; + + hostName = "localhost"; + httpPort = 80; + + inherit user group; + + adminAddr = "eelco@cs.uu.nl"; + + logDir = "/var/log/httpd"; + stateDir = "/var/run/httpd"; + + subServices = []; + }; + +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 +end script + +exec ${webServer}/bin/control start + "; + +}