nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 93 lines 2.3 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchurl, 5 autoreconfHook, 6 pkg-config, 7 libiconv, 8 openssl, 9 pcre, 10 pcre2, 11 zlib, 12}: 13 14import ./versions.nix ( 15 { 16 version, 17 hash, 18 ... 19 }: 20 buildGoModule { 21 pname = "zabbix-agent2"; 22 inherit version; 23 24 src = fetchurl { 25 url = "https://cdn.zabbix.com/zabbix/sources/stable/${lib.versions.majorMinor version}/zabbix-${version}.tar.gz"; 26 inherit hash; 27 }; 28 29 modRoot = "src/go"; 30 31 vendorHash = null; 32 33 nativeBuildInputs = [ 34 autoreconfHook 35 pkg-config 36 ]; 37 buildInputs = [ 38 libiconv 39 openssl 40 (if (lib.versions.major version >= "7" && lib.versions.minor version >= "4") then pcre2 else pcre) 41 zlib 42 ]; 43 44 # need to provide GO* env variables & patch for reproducibility 45 postPatch = '' 46 substituteInPlace src/go/Makefile.am \ 47 --replace '`go env GOOS`' "$GOOS" \ 48 --replace '`go env GOARCH`' "$GOARCH" \ 49 --replace '`date +%H:%M:%S`' "00:00:00" \ 50 --replace '`date +"%b %_d %Y"`' "Jan 1 1970" 51 ''; 52 53 # manually configure the c dependencies 54 preConfigure = '' 55 ./configure \ 56 --prefix=${placeholder "out"} \ 57 --enable-agent2 \ 58 --enable-ipv6 \ 59 --with-iconv \ 60 --with-libpcre \ 61 --with-openssl=${openssl.dev} 62 ''; 63 64 # zabbix build process is complex to get right in nix... 65 # use automake to build the go project ensuring proper access to the go vendor directory 66 buildPhase = '' 67 cd ../.. 68 make 69 ''; 70 71 installPhase = '' 72 mkdir -p $out/sbin 73 74 install -Dm0644 src/go/conf/zabbix_agent2.conf $out/etc/zabbix_agent2.conf 75 install -Dm0755 src/go/bin/zabbix_agent2 $out/bin/zabbix_agent2 76 77 # create a symlink which is compatible with the zabbixAgent module 78 ln -s $out/bin/zabbix_agent2 $out/sbin/zabbix_agentd 79 ''; 80 81 meta = { 82 description = "Enterprise-class open source distributed monitoring solution (client-side agent)"; 83 homepage = "https://www.zabbix.com/"; 84 license = 85 if (lib.versions.major version >= "7") then lib.licenses.agpl3Only else lib.licenses.gpl2Plus; 86 maintainers = with lib.maintainers; [ 87 aanderse 88 bstanderline 89 ]; 90 platforms = lib.platforms.unix; 91 }; 92 } 93)