* Allow Upstart jobs to declare extra configuration for Apache.

Did this for Nagios.  Soon we can rename upstart-jobs to 
  services/plugins/whatever (i.e. an Upstart job will just be 
  one kind of configuration item that a plugin can declare).

svn path=/nixos/trunk/; revision=9778
This commit is contained in:
Eelco Dolstra 2007-11-23 10:56:12 +00:00
parent 1089c1f7fa
commit e7e685e4ce
5 changed files with 65 additions and 8 deletions

View File

@ -874,6 +874,7 @@
";
};
# !!! this is a mis-nomer, should be "extraConfig" or something.
extraDirectories = mkOption {
default = "";
example = "
@ -1216,6 +1217,23 @@
";
};
enableWebInterface = mkOption {
default = false;
description = "
Whether to enable the Nagios web interface. You should also
enable Apache (<option>services.httpd.enable</option>).
";
};
urlPath = mkOption {
default = "/nagios";
description = "
The URL path under which the Nagios web interface appears.
That is, you can access the Nagios web interface through
<literal>http://<replaceable>server</replaceable>/<replaceable>urlPath</replaceable></literal>.
";
};
};

View File

@ -12,11 +12,7 @@ let
(config.services.mingetty.ttys)
++ [10] /* !!! sync with syslog.conf */ ;
in
import ../upstart-jobs/gather.nix {
inherit (pkgs) runCommand;
jobs = map makeJob [
# Syslogd.
(import ../upstart-jobs/syslogd.nix {
@ -171,6 +167,8 @@ import ../upstart-jobs/gather.nix {
(import ../upstart-jobs/httpd.nix {
inherit config pkgs;
inherit (pkgs) glibc;
extraConfig = pkgs.lib.concatStringsSep "\n"
(map (job: job.extraHttpdConfig) jobs);
})
# Samba service.
@ -203,7 +201,6 @@ import ../upstart-jobs/gather.nix {
inherit config pkgs;
})
# ALSA sound support.
++ optional config.sound.enable
(import ../upstart-jobs/alsa.nix {
@ -285,5 +282,9 @@ import ../upstart-jobs/gather.nix {
# For the built-in logd job.
++ [(makeJob { jobDrv = pkgs.upstart; })];
in import ../upstart-jobs/gather.nix {
inherit (pkgs) runCommand;
inherit jobs;
}

View File

@ -1,4 +1,4 @@
{config, pkgs, glibc}:
{config, pkgs, glibc, extraConfig}:
let
@ -18,7 +18,7 @@ let
stateDir = cfg.stateDir;
enableSSL = false;
noUserDir = cfg.noUserDir;
extraDirectories = cfg.extraDirectories;
extraDirectories = cfg.extraDirectories + extraConfig;
startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";

View File

@ -24,6 +24,10 @@
# Allow jobs to declare extra files that should be added to /etc.
extraEtc = if job ? extraEtc then job.extraEtc else [];
# Allow jobs to declare extra configuration for Apache (e.g. Nagios
# declaring its web interface).
extraHttpdConfig = if job ? extraHttpdConfig then job.extraHttpdConfig else "";
# Allow jobs to declare user accounts that should be created.
users = if job ? users then job.users else [];

View File

@ -45,6 +45,37 @@ let
";
# Plain configuration for the Nagios web-interface with no
# authentication.
nagiosCGICfgFile = pkgs.writeText "nagios.cgi.conf" "
main_config_file=${nagiosCfgFile}
use_authentication=0
url_html_path=/nagios
";
urlPath = config.services.nagios.urlPath;
extraHttpdConfig = "
ScriptAlias ${urlPath}/cgi-bin ${pkgs.nagios}/sbin
<Directory \"${pkgs.nagios}/sbin\">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
SetEnv NAGIOS_CGI_CONFIG ${nagiosCGICfgFile}
</Directory>
Alias ${urlPath} ${pkgs.nagios}/share
<Directory \"${pkgs.nagios}/share\">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
";
in
{
@ -68,6 +99,9 @@ in
}
];
extraHttpdConfig =
if config.services.nagios.enableWebInterface then extraHttpdConfig else "";
# Run `nagios -v' to check the validity of the configuration file so
# that a nixos-rebuild fails *before* we kill the running Nagios
# daemon.