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
    $ /<<NIX>>/mutt-2.2.10     440.0M

After the change: 218M

    $ nix path-info -Sh $(nix-build -A mutt) |& unnix
    /<<NIX>>/mutt-2.2.10     218.7M
This commit is contained in:
Sergei Trofimovich
2023-07-06 09:36:56 +01:00
parent 34e822a853
commit 45f4f704b2
2 changed files with 28 additions and 1 deletions
@@ -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";
});
@@ -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\}-@/<<NIX>>/@g'
+}
+
if ./txt2c test </dev/null >/dev/null 2>&1; then
- ./txt2c "$1"
+ nix_store_mangle | ./txt2c "$1"
else
- txt2c_fallback "$1"
+ nix_store_mangle | txt2c_fallback "$1"
fi