nixpkgs/pkgs/servers/monitoring/zabbix/agent2.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.2 KiB
Nix
Raw Normal View History

{
lib,
buildGoModule,
fetchurl,
autoreconfHook,
pkg-config,
libiconv,
openssl,
pcre,
zlib,
}:
2021-01-04 21:14:36 +00:00
import ./versions.nix (
{
version,
hash,
vendorHash ? throw "unsupported version ${version} for zabbix-agent2",
...
}:
2021-01-04 21:14:36 +00:00
buildGoModule {
pname = "zabbix-agent2";
inherit version;
src = fetchurl {
url = "https://cdn.zabbix.com/zabbix/sources/stable/${lib.versions.majorMinor version}/zabbix-${version}.tar.gz";
inherit hash;
2021-01-04 21:14:36 +00:00
};
2021-03-29 21:27:03 +00:00
modRoot = "src/go";
inherit vendorHash;
2021-01-04 21:14:36 +00:00
nativeBuildInputs = [
autoreconfHook
pkg-config
];
buildInputs = [
libiconv
openssl
pcre
zlib
];
2021-01-04 21:14:36 +00:00
inherit (buildGoModule.go) GOOS GOARCH;
# need to provide GO* env variables & patch for reproducibility
postPatch = ''
substituteInPlace src/go/Makefile.am \
--replace '`go env GOOS`' "$GOOS" \
--replace '`go env GOARCH`' "$GOARCH" \
--replace '`date +%H:%M:%S`' "00:00:00" \
--replace '`date +"%b %_d %Y"`' "Jan 1 1970"
'';
# manually configure the c dependencies
preConfigure = ''
./configure \
--prefix=${placeholder "out"} \
--enable-agent2 \
2021-12-15 15:53:48 +00:00
--enable-ipv6 \
2021-01-04 21:14:36 +00:00
--with-iconv \
--with-libpcre \
--with-openssl=${openssl.dev}
'';
# zabbix build process is complex to get right in nix...
2021-03-29 21:27:03 +00:00
# use automake to build the go project ensuring proper access to the go vendor directory
2021-01-04 21:14:36 +00:00
buildPhase = ''
2021-03-29 21:27:03 +00:00
cd ../..
2021-01-04 21:14:36 +00:00
make
'';
installPhase = ''
mkdir -p $out/sbin
2021-01-04 21:14:36 +00:00
install -Dm0644 src/go/conf/zabbix_agent2.conf $out/etc/zabbix_agent2.conf
install -Dm0755 src/go/bin/zabbix_agent2 $out/bin/zabbix_agent2
# create a symlink which is compatible with the zabbixAgent module
ln -s $out/bin/zabbix_agent2 $out/sbin/zabbix_agentd
2021-01-04 21:14:36 +00:00
'';
meta = {
2021-01-04 21:14:36 +00:00
description = "Enterprise-class open source distributed monitoring solution (client-side agent)";
homepage = "https://www.zabbix.com/";
license =
if (lib.versions.major version >= "7") then lib.licenses.agpl3Only else lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ aanderse ];
platforms = lib.platforms.unix;
2021-01-04 21:14:36 +00:00
};
}
)