2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, serverInfo, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2008-06-09 17:52:02 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# The Zabbix PHP frontend needs to be able to write its
|
|
|
|
# configuration settings (the connection info to the database) to
|
|
|
|
# the "conf" subdirectory. So symlink $out/conf to some directory
|
|
|
|
# outside of the Nix store where we want to keep this stateful info.
|
|
|
|
# Note that different instances of the frontend will therefore end
|
|
|
|
# up with their own copies of the PHP sources. !!! Alternatively,
|
|
|
|
# we could generate zabbix.conf.php declaratively.
|
2010-02-15 20:02:42 +01:00
|
|
|
zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {}
|
|
|
|
''
|
2013-06-13 02:28:23 +02:00
|
|
|
cp -rs ${pkgs.zabbix.server}/share/zabbix/php "$out"
|
2010-02-15 20:02:42 +01:00
|
|
|
chmod -R u+w $out
|
2013-06-13 02:28:23 +02:00
|
|
|
ln -s "${if config.configFile == null
|
|
|
|
then "${config.stateDir}/zabbix.conf.php"
|
|
|
|
else config.configFile}" "$out/conf/zabbix.conf.php"
|
2010-02-15 20:02:42 +01:00
|
|
|
'';
|
2008-06-09 17:52:02 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2010-07-14 14:58:38 +02:00
|
|
|
enablePHP = true;
|
2008-06-09 18:02:38 +02:00
|
|
|
|
2010-02-15 20:02:42 +01:00
|
|
|
phpOptions =
|
|
|
|
''
|
|
|
|
post_max_size = 32M
|
|
|
|
max_execution_time = 300
|
2013-06-13 02:31:35 +02:00
|
|
|
max_input_time = 300
|
2010-02-15 20:02:42 +01:00
|
|
|
'';
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2008-06-09 17:52:02 +02:00
|
|
|
extraConfig = ''
|
|
|
|
Alias ${config.urlPrefix}/ ${zabbixPHP}/
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2008-06-09 17:52:02 +02:00
|
|
|
<Directory ${zabbixPHP}>
|
|
|
|
DirectoryIndex index.php
|
|
|
|
Order deny,allow
|
|
|
|
Allow from *
|
|
|
|
</Directory>
|
|
|
|
'';
|
|
|
|
|
|
|
|
startupScript = pkgs.writeScript "zabbix-startup-hook" ''
|
|
|
|
mkdir -p ${config.stateDir}
|
|
|
|
chown -R ${serverInfo.serverConfig.user} ${config.stateDir}
|
|
|
|
'';
|
|
|
|
|
2008-06-09 18:02:38 +02:00
|
|
|
# The frontend needs "ps" to find out whether zabbix_server is running.
|
2011-11-25 17:32:54 +01:00
|
|
|
extraServerPath = [ pkgs.procps ];
|
2008-06-09 18:02:38 +02:00
|
|
|
|
2008-06-09 17:52:02 +02:00
|
|
|
options = {
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
urlPrefix = mkOption {
|
2008-06-09 17:52:02 +02:00
|
|
|
default = "/zabbix";
|
|
|
|
description = "
|
|
|
|
The URL prefix under which the Zabbix service appears.
|
|
|
|
Use the empty string to have it appear in the server root.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
configFile = mkOption {
|
2013-06-13 02:28:23 +02:00
|
|
|
default = null;
|
2014-04-14 16:26:48 +02:00
|
|
|
type = types.nullOr types.path;
|
2013-06-13 02:28:23 +02:00
|
|
|
description = ''
|
|
|
|
The configuration file (zabbix.conf.php) which contains the database
|
|
|
|
connection settings. If not set, the configuration settings will created
|
|
|
|
by the web installer.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
stateDir = mkOption {
|
2008-06-09 17:52:02 +02:00
|
|
|
default = "/var/lib/zabbix/frontend";
|
|
|
|
description = "
|
|
|
|
Directory where the dynamically generated configuration data
|
|
|
|
of the PHP frontend will be stored.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|