Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 curl,
7 libevent,
8 libiconv,
9 openssl,
10 pcre,
11 pcre2,
12 zlib,
13 buildPackages,
14 odbcSupport ? true,
15 unixODBC,
16 snmpSupport ? stdenv.buildPlatform == stdenv.hostPlatform,
17 net-snmp,
18 sshSupport ? true,
19 libssh2,
20 sqliteSupport ? false,
21 sqlite,
22 mysqlSupport ? false,
23 libmysqlclient,
24 postgresqlSupport ? false,
25 libpq,
26}:
27
28# ensure exactly one database type is selected
29assert mysqlSupport -> !postgresqlSupport && !sqliteSupport;
30assert postgresqlSupport -> !mysqlSupport && !sqliteSupport;
31assert sqliteSupport -> !mysqlSupport && !postgresqlSupport;
32
33let
34 inherit (lib) optional optionalString;
35
36 fake_mysql_config = buildPackages.writeShellScript "mysql_config" ''
37 if [[ "$1" == "--version" ]]; then
38 $PKG_CONFIG mysqlclient --modversion
39 else
40 $PKG_CONFIG mysqlclient $@
41 fi
42 '';
43
44in
45import ./versions.nix (
46 { version, hash, ... }:
47 stdenv.mkDerivation {
48 pname = "zabbix-proxy";
49 inherit version;
50
51 src = fetchurl {
52 url = "https://cdn.zabbix.com/zabbix/sources/stable/${lib.versions.majorMinor version}/zabbix-${version}.tar.gz";
53 inherit hash;
54 };
55
56 nativeBuildInputs = [
57 pkg-config
58 ]
59 ++ optional postgresqlSupport libpq.pg_config;
60 buildInputs = [
61 curl
62 libevent
63 libiconv
64 openssl
65 (if (lib.versions.major version >= "7" && lib.versions.minor version >= "4") then pcre2 else pcre)
66 zlib
67 ]
68 ++ optional odbcSupport unixODBC
69 ++ optional snmpSupport net-snmp
70 ++ optional sqliteSupport sqlite
71 ++ optional sshSupport libssh2
72 ++ optional mysqlSupport libmysqlclient
73 ++ optional postgresqlSupport libpq;
74
75 configureFlags = [
76 "--enable-ipv6"
77 "--enable-proxy"
78 "--with-iconv"
79 "--with-libcurl"
80 "--with-libevent"
81 "--with-libpcre"
82 "--with-openssl=${openssl.dev}"
83 "--with-zlib=${zlib}"
84 ]
85 ++ optional odbcSupport "--with-unixodbc"
86 ++ optional snmpSupport "--with-net-snmp"
87 ++ optional sqliteSupport "--with-sqlite3=${sqlite.dev}"
88 ++ optional sshSupport "--with-ssh2=${libssh2.dev}"
89 ++ optional mysqlSupport "--with-mysql=${fake_mysql_config}"
90 ++ optional postgresqlSupport "--with-postgresql";
91
92 prePatch = ''
93 find database -name data.sql -exec sed -i 's|/usr/bin/||g' {} +
94 '';
95
96 makeFlags = [
97 "AR:=$(AR)"
98 "RANLIB:=$(RANLIB)"
99 ];
100
101 postInstall = ''
102 mkdir -p $out/share/zabbix/database/
103 ''
104 + optionalString sqliteSupport ''
105 mkdir -p $out/share/zabbix/database/sqlite3
106 cp -prvd database/sqlite3/schema.sql $out/share/zabbix/database/sqlite3/
107 ''
108 + optionalString mysqlSupport ''
109 mkdir -p $out/share/zabbix/database/mysql
110 cp -prvd database/mysql/schema.sql $out/share/zabbix/database/mysql/
111 ''
112 + optionalString postgresqlSupport ''
113 mkdir -p $out/share/zabbix/database/postgresql
114 cp -prvd database/postgresql/schema.sql $out/share/zabbix/database/postgresql/
115 '';
116
117 meta = {
118 description = "Enterprise-class open source distributed monitoring solution (client-server proxy)";
119 homepage = "https://www.zabbix.com/";
120 license =
121 if (lib.versions.major version >= "7") then lib.licenses.agpl3Only else lib.licenses.gpl2Plus;
122 maintainers = with lib.maintainers; [
123 bstanderline
124 mmahut
125 ];
126 platforms = lib.platforms.linux;
127 };
128 }
129)