1 { stdenv, runCommand, lib, fetchFromGitHub, cmake, flex, bison, systemd
2 , boost, openssl, patchelf, mariadb-connector-c, postgresql, zlib, tzdata
4 , withMysql ? true, withPostgresql ? false
6 , withChecker ? true, withCompat ? false, withLivestatus ? false
7 , withNotification ? true, withPerfdata ? true, withIcingadb ? true
10 stdenv.mkDerivation rec {
11 pname = "icinga2${nameSuffix}";
14 src = fetchFromGitHub {
18 hash = "sha256-QXe/+yQlyyOa78eEiudDni08SCUP3nhTYVpbmVUVKA8=";
22 ./etc-icinga2.patch # Makes /etc/icinga2 relative to / instead of the store path
23 ./no-systemd-service.patch # Prevent systemd service from being written to /usr
24 ./no-var-directories.patch # Prevent /var directories from being created
28 mkFeatureFlag = label: value: "-DICINGA2_WITH_${label}=${if value then "ON" else "OFF"}";
31 "-DCMAKE_INSTALL_SYSCONFDIR=etc"
32 "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
33 "-DCMAKE_INSTALL_FULL_SBINDIR=bin"
34 "-DICINGA2_RUNDIR=/run"
35 "-DMYSQL_INCLUDE_DIR=${mariadb-connector-c.dev}/include/mariadb"
36 "-DMYSQL_LIB=${mariadb-connector-c.out}/lib/mariadb/libmysqlclient.a"
37 "-DICINGA2_PLUGINDIR=bin"
38 "-DICINGA2_LTO_BUILD=yes"
40 (mkFeatureFlag "MYSQL" withMysql)
41 (mkFeatureFlag "PGSQL" withPostgresql)
42 (mkFeatureFlag "CHECKER" withChecker)
43 (mkFeatureFlag "COMPAT" withCompat)
44 (mkFeatureFlag "LIVESTATUS" withLivestatus)
45 (mkFeatureFlag "NOTIFICATION" withNotification)
46 (mkFeatureFlag "PERFDATA" withPerfdata)
47 (mkFeatureFlag "ICINGADB" withIcingadb)
49 "-DICINGA2_USER=icinga2"
50 "-DICINGA2_GROUP=icinga2"
51 "-DICINGA2_GIT_VERSION_INFO=OFF"
55 outputs = [ "out" "doc" ];
57 buildInputs = [ boost openssl systemd ]
58 ++ lib.optional withPostgresql postgresql;
60 nativeBuildInputs = [ cmake flex bison patchelf ];
63 nativeCheckInputs = [ tzdata ]; # legacytimeperiod/dst needs this
66 rm -r $out/etc/logrotate.d $out/etc/sysconfig $out/lib/icinga2/prepare-dirs
69 sed -i 's:/usr/bin/::g' $out/etc/icinga2/scripts/*
72 sed -i 's/sbin/bin/g' $out/lib/icinga2/safe-reload
75 ${lib.optionalString withMysql ''
76 # Add dependencies of the MySQL shim to the shared library
77 patchelf --add-needed ${zlib.out}/lib/libz.so $(readlink -f $out/lib/icinga2/libmysql_shim.so)
79 # Make Icinga find the MySQL shim
80 icinga2Bin=$out/lib/icinga2/sbin/icinga2
81 patchelf --set-rpath $out/lib/icinga2:$(patchelf --print-rpath $icinga2Bin) $icinga2Bin
85 vim = runCommand "vim-icinga2-${version}" { pname = "vim-icinga2"; } ''
86 mkdir -p $out/share/vim-plugins
87 cp -r "${src}/tools/syntax/vim" $out/share/vim-plugins/icinga2
91 description = "Open source monitoring system";
92 homepage = "https://www.icinga.com";
93 license = lib.licenses.gpl2Plus;
94 platforms = lib.platforms.linux;
95 maintainers = lib.teams.helsinki-systems.members;