Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / monitoring / zabbix / server.nix
blob6a1ee65c87588215c9f03f7b08151e1e5862ae42
1 { lib, stdenv, fetchurl, autoreconfHook, pkg-config, curl, libevent, libiconv, libxml2, openssl, pcre, zlib
2 , jabberSupport ? true, iksemel
3 , ldapSupport ? true, openldap
4 , odbcSupport ? true, unixODBC
5 , snmpSupport ? true, net-snmp
6 , sshSupport ? true, libssh2
7 , mysqlSupport ? false, libmysqlclient
8 , postgresqlSupport ? false, postgresql
9 , ipmiSupport ? false, openipmi
12 # ensure exactly one primary database type is selected
13 assert mysqlSupport -> !postgresqlSupport;
14 assert postgresqlSupport -> !mysqlSupport;
16 let
17   inherit (lib) optional optionalString;
19   import ./versions.nix ({ version, hash, ... }:
20     stdenv.mkDerivation {
21       pname = "zabbix-server";
22       inherit version;
24       src = fetchurl {
25         url = "https://cdn.zabbix.com/zabbix/sources/stable/${lib.versions.majorMinor version}/zabbix-${version}.tar.gz";
26         inherit hash;
27       };
29       nativeBuildInputs = [ autoreconfHook pkg-config ];
30       buildInputs = [
31         curl
32         libevent
33         libiconv
34         libxml2
35         openssl
36         pcre
37         zlib
38       ]
39       ++ optional odbcSupport unixODBC
40       ++ optional jabberSupport iksemel
41       ++ optional ldapSupport openldap
42       ++ optional snmpSupport net-snmp
43       ++ optional sshSupport libssh2
44       ++ optional mysqlSupport libmysqlclient
45       ++ optional postgresqlSupport postgresql
46       ++ optional ipmiSupport openipmi;
48       configureFlags = [
49         "--enable-ipv6"
50         "--enable-server"
51         "--with-iconv"
52         "--with-libcurl"
53         "--with-libevent"
54         "--with-libpcre"
55         "--with-libxml2"
56         "--with-openssl=${openssl.dev}"
57         "--with-zlib=${zlib}"
58       ]
59       ++ optional odbcSupport "--with-unixodbc"
60       ++ optional jabberSupport "--with-jabber"
61       ++ optional ldapSupport "--with-ldap=${openldap.dev}"
62       ++ optional snmpSupport "--with-net-snmp"
63       ++ optional sshSupport "--with-ssh2=${libssh2.dev}"
64       ++ optional mysqlSupport "--with-mysql"
65       ++ optional postgresqlSupport "--with-postgresql"
66       ++ optional ipmiSupport "--with-openipmi=${openipmi.dev}";
68       prePatch = ''
69         find database -name data.sql -exec sed -i 's|/usr/bin/||g' {} +
70       '';
72       preAutoreconf = ''
73         for i in $(find . -type f -name "*.m4"); do
74           substituteInPlace $i \
75             --replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
76         done
77       '';
79       postInstall = ''
80         mkdir -p $out/share/zabbix/database/
81         cp -r include $out/
82       '' + optionalString mysqlSupport ''
83         mkdir -p $out/share/zabbix/database/mysql
84         cp -prvd database/mysql/*.sql $out/share/zabbix/database/mysql/
85       '' + optionalString postgresqlSupport ''
86         mkdir -p $out/share/zabbix/database/postgresql
87         cp -prvd database/postgresql/*.sql $out/share/zabbix/database/postgresql/
88       '';
90       meta = with lib; {
91         description = "Enterprise-class open source distributed monitoring solution";
92         homepage = "https://www.zabbix.com/";
93         license = licenses.gpl2Plus;
94         maintainers = with maintainers; [ mmahut psyanticy ];
95         platforms = platforms.linux;
96       };
97     })