* Option `services.apache.phpIni' (which is of type derivation)

replaced by `services.apache.phpOptions' (of type string).
* Allow Apache subservices to add to phpOptions.
* Set the TZ environment variable in Apache.
* Updated the Zabbix web interface.

svn path=/nixos/trunk/; revision=20023
This commit is contained in:
Eelco Dolstra 2010-02-15 19:02:42 +00:00
parent 014ffaac5d
commit 83b76bc2cf
3 changed files with 58 additions and 67 deletions

View file

@ -45,6 +45,8 @@ in
config = mkIf config.services.zabbixServer.enable {
services.postgresql.enable = true;
users.extraUsers = singleton
{ name = "zabbix";
uid = config.ids.uids.zabbix;
@ -52,7 +54,7 @@ in
};
jobs.zabbix_server =
{ #name = "zabbix-server"; !!! mkIf bug
{ name = "zabbix-server";
description = "Zabbix server daemon";
@ -67,18 +69,21 @@ in
if ! test -e "${libDir}/db-created"; then
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
cat ${pkgs.zabbixServer}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
cat ${pkgs.zabbixServer}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
cat ${pkgs.zabbixServer}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
touch "${libDir}/db-created"
fi
export PATH=${pkgs.nettools}/bin:$PATH
${pkgs.zabbixServer}/sbin/zabbix_server --config ${configFile}
${pkgs.zabbix.server}/sbin/zabbix_server --config ${configFile}
'';
postStop =
''
pid=$(cat ${pidFile})
test -n "$pid" && kill "$pid"
# Wait until they're really gone.
while ${pkgs.procps}/bin/pkill -u zabbix zabbix_server; do true; done
'';
};

View file

@ -68,6 +68,7 @@ let
globalEnvVars = [];
robotsEntries = "";
startupScript = "";
phpOptions = "";
options = {};
};
res = defaults // svcFunction {inherit config pkgs serverInfo servicesPath;};
@ -358,7 +359,18 @@ let
}
'';
# Generate the PHP configuration file. Should probably be factored
# out into a separate module.
phpIni = pkgs.runCommand "php.ini"
{ options = concatStringsSep "\n"
([ mainCfg.phpOptions ] ++ (map (svc: svc.phpOptions) allSubservices));
}
''
cat ${pkgs.php}/etc/php-recommended.ini > $out
echo "$options" >> $out
'';
in
@ -464,54 +476,14 @@ in
'';
};
phpIni = mkOption {
default = pkgs.writeText "php.ini" ''
; Needed for PHP's mail() function.
sendmail_path = sendmail -t -i
'';
example = ''
Example code (copy & paste):
most simple:
phpIni pkgs.writeText "php.ini" '''
; Needed for PHP's mail() function.
sendmail_path = sendmail -t -i
''';
using recommended settings and enabling Xdebug:
phpIni = pkgs.phpIniBuilder.override {
appendLines = '''
sendmail_path = sendmail -t -i
zend_extension="''\${pkgs.phpXdebug}/lib/xdebug.so"
zend_extension_ts="''\${pkgs.phpXdebug}/lib/xdebug.so"
zend_extension_debug="''\${pkgs.phpXdebug}/lib/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.remote_mode=req
''';
};
'';
description = ''
The contents of this option are used as global php.ini file by the
PHP interpreter used by Apache. You have to enable PHP explicitly.
See extraModules options.
This file defaults to defining sendmail_path only.
Note: Depending on your configuration you can set PHP ini values using .htaccess files and the
php_value option.
The example shows how to enable Xdebug and use the recommended
php.ini values which are contained in the PHP distribution.
I don't know whether they are equal to defaults
'';
phpOptions = mkOption {
default = "";
example =
''
date.timezone = "CET"
'';
description =
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
};
}
@ -540,6 +512,15 @@ in
environment.systemPackages = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices;
services.httpd.phpOptions =
''
; Needed for PHP's mail() function.
sendmail_path = sendmail -t -i
; Apparently PHP doesn't use $TZ.
date.timezone = "${config.time.timeZone}"
'';
jobs.httpd =
{ # Statically verify the syntactic correctness of the generated
# httpd.conf. !!! this is impure! It doesn't just check for
@ -570,7 +551,9 @@ in
optional config.networking.defaultMailServer.directDelivery "${pkgs.ssmtp}/sbin"
++ (concatMap (svc: svc.extraServerPath) allSubservices) );
PHPRC = mainCfg.phpIni;
PHPRC = phpIni;
TZ = config.time.timeZone;
} // (listToAttrs (concatMap (svc: svc.globalEnvVars) allSubservices));
@ -606,4 +589,3 @@ in
};
}

View file

@ -9,23 +9,27 @@ let
# 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.
zabbixPHP = pkgs.runCommand "${pkgs.zabbixServer.name}-php" {} ''
cp -rs ${pkgs.zabbixServer}/share/zabbix/php $out
chmod -R u+w $out
#rm -rf $out/conf
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php
'';
zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {}
''
cp -rs ${pkgs.zabbix.server}/share/zabbix/php $out
chmod -R u+w $out
#rm -rf $out/conf
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php
'';
in
{
extraModules = [
{ name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
];
extraModules =
[ { name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; } ];
# !!! should also declare PHP options that Zabbix needs like the
# timezone and timeout.
phpOptions =
''
post_max_size = 32M
max_execution_time = 300
mbstring.func_overload = 2
'';
extraConfig = ''
Alias ${config.urlPrefix}/ ${zabbixPHP}/