biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / monitoring / net-snmp / default.nix
blob8961bc549535947441666b81ec534c3df0b060a0
1 { lib, stdenv, fetchurl, fetchpatch
2 , file, openssl, perl, perlPackages, nettools
3 , withPerlTools ? false }: let
5   perlWithPkgs = perl.withPackages (ps: with ps; [
6     JSON
7     TermReadKey
8     Tk
9   ]);
11 in stdenv.mkDerivation rec {
12   pname = "net-snmp";
13   version = "5.9.4";
15   src = fetchurl {
16     url = "mirror://sourceforge/net-snmp/${pname}-${version}.tar.gz";
17     sha256 = "sha256-i03gE5HnTjxwFL60OWGi1tb6A6zDQoC5WF9JMHRbBUQ=";
18   };
20   patches =
21     let fetchAlpinePatch = name: sha256: fetchurl {
22       url = "https://git.alpinelinux.org/aports/plain/main/net-snmp/${name}?id=ebb21045c31f4d5993238bcdb654f21d8faf8123";
23       inherit name sha256;
24     };
25   in [
26     (fetchAlpinePatch "fix-includes.patch" "0zpkbb6k366qpq4dax5wknwprhwnhighcp402mlm7950d39zfa3m")
27     (fetchAlpinePatch "netsnmp-swinst-crash.patch" "0gh164wy6zfiwiszh58fsvr25k0ns14r3099664qykgpmickkqid")
28     (fetchAlpinePatch "fix-fd_mask.patch" "/i9ve61HjDzqZt+u1wajNtSQoizl+KePvhcAt24HKd0=")
29   ];
31   outputs = [ "bin" "out" "dev" "lib" ];
33   configureFlags =
34     [ "--with-default-snmp-version=3"
35       "--with-sys-location=Unknown"
36       "--with-sys-contact=root@unknown"
37       "--with-logfile=/var/log/net-snmpd.log"
38       "--with-persistent-directory=/var/lib/net-snmp"
39       "--with-openssl=${openssl.dev}"
40       "--disable-embedded-perl"
41       "--without-perl-modules"
42     ] ++ lib.optional stdenv.isLinux "--with-mnttab=/proc/mounts";
44   postPatch = ''
45     substituteInPlace testing/fulltests/support/simple_TESTCONF.sh --replace "/bin/netstat" "${nettools}/bin/netstat"
46   '';
48   postConfigure = ''
49     # libraries contain configure options. Mangle store paths out from
50     # ./configure-generated file.
51     sed -i include/net-snmp/net-snmp-config.h \
52       -e "/NETSNMP_CONFIGURE_OPTIONS/ s|$NIX_STORE/[a-z0-9]\{32\}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g"
53   '';
55   nativeBuildInputs = [ nettools file ];
56   buildInputs = [ openssl ]
57     ++ lib.optional withPerlTools perlWithPkgs;
59   enableParallelBuilding = true;
60   # Missing dependencies during relinking:
61   #   ./.libs/libnetsnmpagent.so: file not recognized: file format not recognized
62   enableParallelInstalling = false;
63   doCheck = false;  # tries to use networking
65   postInstall = ''
66     for f in "$lib/lib/"*.la $bin/bin/net-snmp-config $bin/bin/net-snmp-create-v3-user; do
67       sed 's|-L${openssl.dev}|-L${lib.getLib openssl}|g' -i $f
68     done
69     mkdir $dev/bin
70     mv $bin/bin/net-snmp-config $dev/bin
71   '';
73   meta = with lib; {
74     description = "Clients and server for the SNMP network monitoring protocol";
75     homepage = "http://www.net-snmp.org/";
76     license = licenses.bsd3;
77     platforms = platforms.linux;
78   };