From 9f479291385e087afabc91eee7682eed87f2b65c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 18 Dec 2006 19:46:48 +0000 Subject: [PATCH] * Apache configuration. svn path=/nixos/trunk/; revision=7393 --- configuration/options.nix | 78 ++++++++++++++++++++++++++++++++++++++- configuration/system.nix | 2 +- configuration/upstart.nix | 5 ++- upstart-jobs/httpd.nix | 23 +++++++----- 4 files changed, 95 insertions(+), 13 deletions(-) diff --git a/configuration/options.nix b/configuration/options.nix index bcad035849f..fa05d544307 100644 --- a/configuration/options.nix +++ b/configuration/options.nix @@ -2,7 +2,7 @@ { - name = ["networking" "hostname"]; + name = ["networking" "hostName"]; default = "nixos"; description = "The name of the machine."; } @@ -216,4 +216,80 @@ } + { + name = ["services" "httpd" "user"]; + default = "wwwrun"; + description = " + User account under which httpd runs. The account is created + automatically if it doesn't exist. + "; + } + + + { + name = ["services" "httpd" "group"]; + default = "wwwrun"; + description = " + Group under which httpd runs. The account is created + automatically if it doesn't exist. + "; + } + + + { + name = ["services" "httpd" "hostName"]; + default = "localhost"; + description = " + Canonical hostname for the server. + "; + } + + + { + name = ["services" "httpd" "httpPort"]; + default = 80; + description = " + Port for unencrypted HTTP requests. + "; + } + + + { + name = ["services" "httpd" "httpsPort"]; + default = 443; + description = " + Port for encrypted HTTP requests. + "; + } + + + { + name = ["services" "httpd" "adminAddr"]; + example = "admin@example.org"; + description = " + E-mail address of the server administrator. + "; + } + + + { + name = ["services" "httpd" "logDir"]; + default = "/var/log/httpd"; + description = " + Directory for Apache's log files. It is created automatically. + "; + } + + + { + name = ["services" "httpd" "stateDir"]; + default = "/var/run/httpd"; + description = " + Directory for Apache's transient runtime state (such as PID + files). It is created automatically. Note that the default, + /var/run/httpd, is deleted at boot time. + "; + } + + ] diff --git a/configuration/system.nix b/configuration/system.nix index 5a91c38e95b..fddb0e4c41f 100644 --- a/configuration/system.nix +++ b/configuration/system.nix @@ -172,7 +172,7 @@ rec { inherit etc; inherit (pkgs) kernel; readOnlyRoot = config.get ["boot" "readOnlyRoot"]; - hostName = config.get ["networking" "hostname"]; + hostName = config.get ["networking" "hostName"]; wrapperDir = setuidWrapper.wrapperDir; path = [ diff --git a/configuration/upstart.nix b/configuration/upstart.nix index 4a7e124c271..d6249fc0294 100644 --- a/configuration/upstart.nix +++ b/configuration/upstart.nix @@ -79,7 +79,7 @@ import ../upstart-jobs/gather.nix { # Apache httpd. ++ optional ["services" "httpd" "enable"] (import ../upstart-jobs/httpd.nix { - inherit pkgs; + inherit config pkgs; inherit (pkgs) glibc pwdutils; }) @@ -104,6 +104,7 @@ import ../upstart-jobs/gather.nix { # User-defined events. ++ (map makeJob (config.get ["services" "extraJobs"])) - # For the builtin logd job. + # For the built-in logd job. ++ [pkgs.upstart]; + } diff --git a/upstart-jobs/httpd.nix b/upstart-jobs/httpd.nix index 80f24a01766..4167343b6ad 100644 --- a/upstart-jobs/httpd.nix +++ b/upstart-jobs/httpd.nix @@ -1,23 +1,26 @@ -{pkgs, glibc, pwdutils}: +{config, pkgs, glibc, pwdutils}: let - user = "wwwrun"; - group = "wwwrun"; + getCfg = option: config.get ["services" "httpd" option]; + + user = getCfg "user"; + group = getCfg "group"; webServer = import ../services/apache-httpd { inherit (pkgs) apacheHttpd coreutils; stdenv = pkgs.stdenvNew; - hostName = "localhost"; - httpPort = 80; + hostName = getCfg "hostName"; + httpPort = getCfg "httpPort"; + httpsPort = getCfg "httpsPort"; inherit user group; - adminAddr = "eelco@cs.uu.nl"; + adminAddr = getCfg "adminAddr"; - logDir = "/var/log/httpd"; - stateDir = "/var/run/httpd"; + logDir = getCfg "logDir"; + stateDir = getCfg "stateDir"; subServices = []; }; @@ -42,9 +45,11 @@ start script ${pwdutils}/sbin/useradd -g ${group} -d /var/empty -s /noshell \\ -c 'Apache httpd user' ${user} fi + + ${webServer}/bin/control prepare end script -exec ${webServer}/bin/control start +respawn ${webServer}/bin/control run "; }