summary refs log tree commit diff
path: root/pkgs/servers/monitoring/zabbix/agent2.nix
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2021-01-04 16:14:36 -0500
committertomberek <tomberek@users.noreply.github.com>2021-03-28 13:35:21 -0400
commitdebbd843330393dbf9f1abdccf20255cf33712bf (patch)
tree2684a553878083b346b896fc05fbe0625b06cd9f /pkgs/servers/monitoring/zabbix/agent2.nix
parentb722e3ff4c1aac1a74cac24ef7f8c32fb33a5223 (diff)
downloadnixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar.gz
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar.bz2
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar.lz
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar.xz
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.tar.zst
nixpkgs-debbd843330393dbf9f1abdccf20255cf33712bf.zip
zabbix.agent2: init at 5.0.5
Diffstat (limited to 'pkgs/servers/monitoring/zabbix/agent2.nix')
-rw-r--r--pkgs/servers/monitoring/zabbix/agent2.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/pkgs/servers/monitoring/zabbix/agent2.nix b/pkgs/servers/monitoring/zabbix/agent2.nix
new file mode 100644
index 00000000000..f3c1be0f8e2
--- /dev/null
+++ b/pkgs/servers/monitoring/zabbix/agent2.nix
@@ -0,0 +1,66 @@
+{ lib, buildGoModule, fetchurl, autoreconfHook, pkg-config, libiconv, openssl, pcre, zlib }:
+
+import ./versions.nix ({ version, sha256 }:
+  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 sha256;
+    };
+
+    vendorSha256 = "1kb3lc9jjv0cpzq93k1b9y496i95fcnwhb03j0gwlyqmgsa6yn81";
+
+    nativeBuildInputs = [ autoreconfHook pkg-config];
+    buildInputs = [ libiconv openssl pcre zlib ];
+
+    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 \
+        --with-iconv \
+        --with-libpcre \
+        --with-openssl=${openssl.dev}
+    '';
+
+    # zabbix build process is complex to get right in nix...
+    # we need to manipulate a number of things for their build
+    # system to properly work
+    buildPhase = ''
+      cp -r vendor src/go/vendor
+      make
+    '';
+
+    installPhase = ''
+      install -Dm0644 src/go/conf/zabbix_agent2.conf $out/etc/zabbix_agent2.conf
+      install -Dm0755 src/go/bin/zabbix_agent2 $out/bin/zabbix_agent2
+    '';
+
+    # run `go mod vendor` from the correct directory
+    overrideModAttrs = (_oldAttrs : {
+      preConfigure = ''
+        cd src/go
+        '';
+    });
+
+    meta = with lib; {
+      description = "An enterprise-class open source distributed monitoring solution (client-side agent)";
+      homepage = "https://www.zabbix.com/";
+      license = licenses.gpl2Plus;
+      maintainers = [ maintainers.aanderse ];
+      platforms = platforms.linux;
+    };
+  })