From 44131d7fc36f93f09e71724890f3d3df6b2101eb Mon Sep 17 00:00:00 2001 From: adisbladis Date: Thu, 25 Feb 2021 11:38:20 +0200 Subject: [PATCH] emacs: Remove clean-env patch and use substituteInPlace This approach applies to _all_ RUN_TEMACS calls and successfully removes -dev paths from the closure and reduces the closure size from ~1.4G to just under ~464M. It's also less brittle than having in-tree patches. --- pkgs/applications/editors/emacs/26.nix | 1 - pkgs/applications/editors/emacs/27.nix | 1 - .../editors/emacs/clean-env-26.patch | 15 --------------- pkgs/applications/editors/emacs/clean-env.patch | 16 ---------------- pkgs/applications/editors/emacs/generic.nix | 6 ++++++ pkgs/applications/editors/emacs/macport.nix | 7 +++++-- 6 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 pkgs/applications/editors/emacs/clean-env-26.patch delete mode 100644 pkgs/applications/editors/emacs/clean-env.patch diff --git a/pkgs/applications/editors/emacs/26.nix b/pkgs/applications/editors/emacs/26.nix index a151006a995..1667bec9932 100644 --- a/pkgs/applications/editors/emacs/26.nix +++ b/pkgs/applications/editors/emacs/26.nix @@ -2,7 +2,6 @@ import ./generic.nix (rec { version = "26.3"; sha256 = "119ldpk7sgn9jlpyngv5y4z3i7bb8q3xp4p0qqi7i5nq39syd42d"; patches = [ - ./clean-env-26.patch ./tramp-detect-wrapped-gvfsd-26.patch ]; }) diff --git a/pkgs/applications/editors/emacs/27.nix b/pkgs/applications/editors/emacs/27.nix index 1037c0cd91d..8bc65bad8b5 100644 --- a/pkgs/applications/editors/emacs/27.nix +++ b/pkgs/applications/editors/emacs/27.nix @@ -2,7 +2,6 @@ import ./generic.nix (rec { version = "27.1"; sha256 = "0h9f2wpmp6rb5rfwvqwv1ia1nw86h74p7hnz3vb3gjazj67i4k2a"; patches = [ - ./clean-env.patch ./tramp-detect-wrapped-gvfsd.patch ]; }) diff --git a/pkgs/applications/editors/emacs/clean-env-26.patch b/pkgs/applications/editors/emacs/clean-env-26.patch deleted file mode 100644 index 88befda899a..00000000000 --- a/pkgs/applications/editors/emacs/clean-env-26.patch +++ /dev/null @@ -1,15 +0,0 @@ -Dump temacs in an empty environment to prevent -dev paths from ending -up in the dumped image. - -diff --git a/src/Makefile.in b/src/Makefile.in ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -535,7 +535,7 @@ ifeq ($(CANNOT_DUMP),yes) - ln -f temacs$(EXEEXT) $@ - else - unset EMACS_HEAP_EXEC; \ -- LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup dump -+ env -i LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup dump - ifneq ($(PAXCTL_dumped),) - $(PAXCTL_dumped) $@ - endif diff --git a/pkgs/applications/editors/emacs/clean-env.patch b/pkgs/applications/editors/emacs/clean-env.patch deleted file mode 100644 index 2ffe8b777a0..00000000000 --- a/pkgs/applications/editors/emacs/clean-env.patch +++ /dev/null @@ -1,16 +0,0 @@ -Dump temacs in an empty environment to prevent -dev paths from ending -up in the dumped image. - -diff --git a/src/Makefile.in b/src/Makefile.in -index fd05a45df5..13f529c253 100644 ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -570,7 +570,7 @@ emacs$(EXEEXT): temacs$(EXEEXT) \ - lisp.mk $(etc)/DOC $(lisp) \ - $(lispsource)/international/charprop.el ${charsets} - ifeq ($(DUMPING),unexec) -- LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump -+ env -i LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump - ifneq ($(PAXCTL_dumped),) - $(PAXCTL_dumped) emacs$(EXEEXT) - endif diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 70e253dd6df..12c3c57bbec 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -63,6 +63,12 @@ let emacs = stdenv.mkDerivation (lib.optionalAttrs nativeComp { rm -fr .git '') + # Reduce closure size by cleaning the environment of the emacs dumper + '' + substituteInPlace src/Makefile.in \ + --replace 'RUN_TEMACS = ./temacs' 'RUN_TEMACS = env -i ./temacs' + '' + '' substituteInPlace lisp/international/mule-cmds.el \ --replace /usr/share/locale ${gettext}/share/locale diff --git a/pkgs/applications/editors/emacs/macport.nix b/pkgs/applications/editors/emacs/macport.nix index 3c57d3bc81a..b8fcc678faa 100644 --- a/pkgs/applications/editors/emacs/macport.nix +++ b/pkgs/applications/editors/emacs/macport.nix @@ -26,8 +26,6 @@ stdenv.mkDerivation rec { sha256 = "0f2wzdw2a3ac581322b2y79rlj3c9f33ddrq9allj97r1si6v5xk"; }; - patches = [ ./clean-env.patch ]; - enableParallelBuilding = true; nativeBuildInputs = [ pkg-config autoconf automake ]; @@ -57,6 +55,11 @@ stdenv.mkDerivation rec { # Fix sandbox impurities. substituteInPlace Makefile.in --replace '/bin/pwd' 'pwd' substituteInPlace lib-src/Makefile.in --replace '/bin/pwd' 'pwd' + + + # Reduce closure size by cleaning the environment of the emacs dumper + substituteInPlace src/Makefile.in \ + --replace 'RUN_TEMACS = ./temacs' 'RUN_TEMACS = env -i ./temacs' ''; configureFlags = [