From 45f4f704b2781ea1e1168bedca296199816cfc24 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 6 Jul 2023 09:05:07 +0100 Subject: [PATCH] mutt: avoid build-only references in 'mutt -v' The change removes `gcc` from runtime closure. This shrinks closure in half. Before the change: nix path-info -Sh $(nix-build -A mutt) |& unnix $ /<>/mutt-2.2.10 440.0M After the change: 218M $ nix path-info -Sh $(nix-build -A mutt) |& unnix /<>/mutt-2.2.10 218.7M --- .../networking/mailreaders/mutt/default.nix | 5 +++- .../mailreaders/mutt/no-build-only-refs.patch | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/networking/mailreaders/mutt/no-build-only-refs.patch diff --git a/pkgs/applications/networking/mailreaders/mutt/default.nix b/pkgs/applications/networking/mailreaders/mutt/default.nix index d449ae7db817..cda1e368f349 100644 --- a/pkgs/applications/networking/mailreaders/mutt/default.nix +++ b/pkgs/applications/networking/mailreaders/mutt/default.nix @@ -31,7 +31,10 @@ stdenv.mkDerivation rec { sha256 = "sha256-TXc/IkIveQlve5S1e+5FZUrZolFl27NkY8WClbTNPYg="; }; - patches = lib.optional smimeSupport (fetchpatch { + patches = [ + # Avoid build-only references embedding into 'mutt -v' output. + ./no-build-only-refs.patch + ] ++ lib.optional smimeSupport (fetchpatch { url = "https://salsa.debian.org/mutt-team/mutt/raw/debian/1.10.1-2/debian/patches/misc/smime.rc.patch"; sha256 = "0b4i00chvx6zj9pcb06x2jysmrcb2znn831lcy32cgfds6gr3nsi"; }); diff --git a/pkgs/applications/networking/mailreaders/mutt/no-build-only-refs.patch b/pkgs/applications/networking/mailreaders/mutt/no-build-only-refs.patch new file mode 100644 index 000000000000..de969a8a889e --- /dev/null +++ b/pkgs/applications/networking/mailreaders/mutt/no-build-only-refs.patch @@ -0,0 +1,24 @@ +Avoid build-only store references embedding into 'mutt -v'. +--- a/txt2c.sh ++++ b/txt2c.sh +@@ -21,8 +21,18 @@ txt2c_fallback () { + echo ";" + } + ++nix_store_mangle() { ++ # consume stdin ++ ++ # Avoid build-only references to nix store. These are usually ++ # 'gcc -v' output embedded into 'mutt -v'. But also might be ++ # ./configure-passed arguments. ++ sed \ ++ -e 's@'$NIX_STORE'/[a-z0-9]\{32\}-@/<>/@g' ++} ++ + if ./txt2c test /dev/null 2>&1; then +- ./txt2c "$1" ++ nix_store_mangle | ./txt2c "$1" + else +- txt2c_fallback "$1" ++ nix_store_mangle | txt2c_fallback "$1" + fi