1{ config, lib, pkgs, serverInfo, ... }: 2 3with lib; 4 5let 6 7 # The Zabbix PHP frontend needs to be able to write its 8 # configuration settings (the connection info to the database) to 9 # the "conf" subdirectory. So symlink $out/conf to some directory 10 # outside of the Nix store where we want to keep this stateful info. 11 # Note that different instances of the frontend will therefore end 12 # up with their own copies of the PHP sources. !!! Alternatively, 13 # we could generate zabbix.conf.php declaratively. 14 zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {} 15 '' 16 cp -rs ${pkgs.zabbix.server}/share/zabbix/php "$out" 17 chmod -R u+w $out 18 ln -s "${if config.configFile == null 19 then "${config.stateDir}/zabbix.conf.php" 20 else config.configFile}" "$out/conf/zabbix.conf.php" 21 ''; 22 23in 24 25{ 26 27 enablePHP = true; 28 29 phpOptions = 30 '' 31 post_max_size = 32M 32 max_execution_time = 300 33 max_input_time = 300 34 ''; 35 36 extraConfig = '' 37 Alias ${config.urlPrefix}/ ${zabbixPHP}/ 38 39 <Directory ${zabbixPHP}> 40 DirectoryIndex index.php 41 Order deny,allow 42 Allow from * 43 </Directory> 44 ''; 45 46 startupScript = pkgs.writeScript "zabbix-startup-hook" '' 47 mkdir -p ${config.stateDir} 48 chown -R ${serverInfo.serverConfig.user} ${config.stateDir} 49 ''; 50 51 # The frontend needs "ps" to find out whether zabbix_server is running. 52 extraServerPath = [ pkgs.procps ]; 53 54 options = { 55 56 urlPrefix = mkOption { 57 default = "/zabbix"; 58 description = " 59 The URL prefix under which the Zabbix service appears. 60 Use the empty string to have it appear in the server root. 61 "; 62 }; 63 64 configFile = mkOption { 65 default = null; 66 type = types.nullOr types.path; 67 description = '' 68 The configuration file (zabbix.conf.php) which contains the database 69 connection settings. If not set, the configuration settings will created 70 by the web installer. 71 ''; 72 }; 73 74 stateDir = mkOption { 75 default = "/var/lib/zabbix/frontend"; 76 description = " 77 Directory where the dynamically generated configuration data 78 of the PHP frontend will be stored. 79 "; 80 }; 81 82 }; 83 84}