From ca73360bb710b9975d63e07058e565c828dfdebf Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 2 Nov 2023 17:20:32 +0000 Subject: [PATCH] net-snmp: drop build-only references from the closure Before the change `net-snmp` embedded it's `./configure` options as is and retained unneeded dependencies: $ nix path-info -rSh $(nix-build -A net-snmp.lib) | nl |& unnix 1 /<>/libunistring-1.1 1.8M 2 /<>/xgcc-12.3.0-libgcc 139.1K 3 /<>/libidn2-2.3.4 2.1M 4 /<>/glibc-2.38-23 31.1M 5 /<>/net-snmp-5.9.4 1.7M 6 /<>/bash-5.2-p15 32.6M 7 /<>/openssl-3.0.11 37.3M 8 /<>/openssl-3.0.11-bin 39.8M 9 /<>/openssl-3.0.11-dev 41.7M 10 /<>/net-snmp-5.9.4-lib 46.2M After the change the closure skips `openssl.dev` input and gets rid of 5MB of closure: $ nix path-info -rSh $(nix-build -A net-snmp.lib) | nl |& unnix 1 /<>/libunistring-1.1 1.8M 2 /<>/xgcc-12.3.0-libgcc 139.1K 3 /<>/libidn2-2.3.4 2.1M 4 /<>/glibc-2.38-23 31.1M 5 /<>/net-snmp-5.9.4 1.7M 6 /<>/openssl-3.0.11 37.3M 7 /<>/net-snmp-5.9.4-lib 41.8M --- pkgs/servers/monitoring/net-snmp/default.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/servers/monitoring/net-snmp/default.nix b/pkgs/servers/monitoring/net-snmp/default.nix index 638d7fad330c..8961bc549535 100644 --- a/pkgs/servers/monitoring/net-snmp/default.nix +++ b/pkgs/servers/monitoring/net-snmp/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, fetchpatch, removeReferencesTo +{ lib, stdenv, fetchurl, fetchpatch , file, openssl, perl, perlPackages, nettools , withPerlTools ? false }: let @@ -45,7 +45,14 @@ in stdenv.mkDerivation rec { substituteInPlace testing/fulltests/support/simple_TESTCONF.sh --replace "/bin/netstat" "${nettools}/bin/netstat" ''; - nativeBuildInputs = [ nettools removeReferencesTo file ]; + postConfigure = '' + # libraries contain configure options. Mangle store paths out from + # ./configure-generated file. + sed -i include/net-snmp/net-snmp-config.h \ + -e "/NETSNMP_CONFIGURE_OPTIONS/ s|$NIX_STORE/[a-z0-9]\{32\}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" + ''; + + nativeBuildInputs = [ nettools file ]; buildInputs = [ openssl ] ++ lib.optional withPerlTools perlWithPkgs; @@ -61,9 +68,6 @@ in stdenv.mkDerivation rec { done mkdir $dev/bin mv $bin/bin/net-snmp-config $dev/bin - # libraries contain configure options - find $lib/lib -type f -exec remove-references-to -t $bin '{}' + - find $lib/lib -type f -exec remove-references-to -t $dev '{}' + ''; meta = with lib; {