1 { lib, stdenv, fetchurl, fetchpatch
2 , file, openssl, perl, perlPackages, nettools
3 , withPerlTools ? false }: let
5 perlWithPkgs = perl.withPackages (ps: with ps; [
11 in stdenv.mkDerivation rec {
16 url = "mirror://sourceforge/net-snmp/${pname}-${version}.tar.gz";
17 sha256 = "sha256-i03gE5HnTjxwFL60OWGi1tb6A6zDQoC5WF9JMHRbBUQ=";
21 let fetchAlpinePatch = name: sha256: fetchurl {
22 url = "https://git.alpinelinux.org/aports/plain/main/net-snmp/${name}?id=ebb21045c31f4d5993238bcdb654f21d8faf8123";
26 (fetchAlpinePatch "fix-includes.patch" "0zpkbb6k366qpq4dax5wknwprhwnhighcp402mlm7950d39zfa3m")
27 (fetchAlpinePatch "netsnmp-swinst-crash.patch" "0gh164wy6zfiwiszh58fsvr25k0ns14r3099664qykgpmickkqid")
28 (fetchAlpinePatch "fix-fd_mask.patch" "/i9ve61HjDzqZt+u1wajNtSQoizl+KePvhcAt24HKd0=")
31 outputs = [ "bin" "out" "dev" "lib" ];
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";
45 substituteInPlace testing/fulltests/support/simple_TESTCONF.sh --replace "/bin/netstat" "${nettools}/bin/netstat"
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"
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
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
70 mv $bin/bin/net-snmp-config $dev/bin
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;