From 6a6110bd76cfd8715f47217e2ca2aab1585b4528 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 3 Jun 2023 15:05:14 -0300 Subject: [PATCH 1/6] emacs generic.nix: require `pname` Also, remove versionModifier and name --- pkgs/applications/editors/emacs/generic.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index ddfdbe337186..8f8a3665acb0 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -1,7 +1,5 @@ -{ pname ? "emacs" +{ pname , version -, versionModifier ? "" -, name ? "emacs-${version}${versionModifier}" , variant , src , patches ? _: [ ] From 441036d7f901a745e8436167dd4dcc9cebf88f54 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 4 Jun 2023 22:49:27 -0300 Subject: [PATCH 2/6] emacs generic.nix: append `-macport` to pname when appropriate --- pkgs/applications/editors/emacs/generic.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 8f8a3665acb0..042ea3f05d95 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -140,6 +140,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { } // { pname = pname + (if noGui then "-nox" + else if (variant == "macport") then "-macport" else if withPgtk then "-pgtk" else if withGTK3 then "-gtk3" else if withGTK2 then "-gtk2" From 196d71b29564b46b53842e07bc558da1abb91b93 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 3 Jun 2023 15:34:33 -0300 Subject: [PATCH 3/6] emacs generic: decouple Xwidgets from X --- pkgs/applications/editors/emacs/generic.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 042ea3f05d95..b73079fbd282 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -94,7 +94,7 @@ , withWebP ? lib.versionAtLeast version "29" , withX ? !(stdenv.isDarwin || noGui || withPgtk) , withXinput2 ? withX && lib.versionAtLeast version "29" -, withXwidgets ? false +, withXwidgets ? !noGui && (withGTK3 || withPgtk) # Options , siteStart ? ./site-start.el @@ -118,7 +118,7 @@ assert withGconf -> withX; assert withGpm -> stdenv.isLinux; assert withNS -> stdenv.isDarwin && !(withX || variant == "macport"); assert withPgtk -> withGTK3 && !withX; -assert withXwidgets -> withGTK3; +assert withXwidgets -> !noGui && (withGTK3 || withPgtk); let libGccJitLibraryPaths = [ @@ -241,7 +241,6 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { motif ] ++ lib.optionals (withX && withXwidgets) [ glib-networking - webkitgtk ] ++ lib.optionals nativeComp [ libgccjit ] ++ lib.optionals withImageMagick [ @@ -265,7 +264,6 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { ] ++ lib.optionals withX [ Xaw3d cairo - giflib libXaw libXpm @@ -273,6 +271,8 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { libpng librsvg libtiff + ] ++ lib.optionals withXwidgets [ + webkitgtk ] ++ lib.optionals stdenv.isDarwin [ sigtool ] ++ lib.optionals withNS [ From e5e43e6beb418dbd2900fb692b1e8e6585f2cbcb Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 4 Jun 2023 22:06:36 -0300 Subject: [PATCH 4/6] emacs generic: rename attributes Namely: - treeSitter -> withTreeSitter - nativeComp -> withNativeCompilation --- pkgs/applications/editors/emacs/generic.nix | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index b73079fbd282..4a981930e549 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -72,7 +72,11 @@ , WebKit # Boolean flags -, nativeComp ? true +, nativeComp ? null +, withNativeCompilation ? + if nativeComp != null + then lib.warn "nativeComp option is deprecated and will be removed; use withNativeCompilation instead" nativeComp + else true , noGui ? false , srcRepo ? true , withAcl ? false @@ -132,7 +136,7 @@ let then llvmPackages_6.stdenv else stdenv) mkDerivation; in -mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { +mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation { env = { NATIVE_FULL_AOT = "1"; LIBRARY_PATH = lib.concatStringsSep ":" libGccJitLibraryPaths; @@ -140,7 +144,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { } // { pname = pname + (if noGui then "-nox" - else if (variant == "macport") then "-macport" + else if variant == "macport" then "-macport" else if withPgtk then "-pgtk" else if withGTK3 then "-gtk3" else if withGTK2 then "-gtk2" @@ -149,7 +153,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { inherit src; - patches = patches fetchpatch ++ lib.optionals nativeComp [ + patches = patches fetchpatch ++ lib.optionals withNativeCompilation [ (substituteAll { src = if lib.versionOlder finalAttrs.version "29" then ./native-comp-driver-options-28.patch @@ -241,7 +245,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { motif ] ++ lib.optionals (withX && withXwidgets) [ glib-networking - ] ++ lib.optionals nativeComp [ + ] ++ lib.optionals withNativeCompilation [ libgccjit ] ++ lib.optionals withImageMagick [ imagemagick @@ -324,7 +328,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { ] ++ (lib.optional stdenv.isDarwin (lib.withFeature withNS "ns")) ++ lib.optional (!withToolkitScrollBars) "--without-toolkit-scroll-bars" - ++ lib.optional nativeComp "--with-native-compilation" + ++ lib.optional withNativeCompilation "--with-native-compilation" ++ lib.optional withImageMagick "--with-imagemagick" ++ lib.optional withTreeSitter "--with-tree-sitter" ++ lib.optional withXinput2 "--with-xinput2" @@ -355,9 +359,9 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { '' + lib.optionalString withNS '' mkdir -p $out/Applications mv nextstep/Emacs.app $out/Applications - '' + lib.optionalString (nativeComp && (withNS || variant == "macport")) '' + '' + lib.optionalString (withNativeCompilation && (withNS || variant == "macport")) '' ln -snf $out/lib/emacs/*/native-lisp $out/Applications/Emacs.app/Contents/native-lisp - '' + lib.optionalString nativeComp '' + '' + lib.optionalString withNativeCompilation '' echo "Generating native-compiled trampolines..." # precompile trampolines in parallel, but avoid spawning one process per trampoline. # 1000 is a rough lower bound on the number of trampolines compiled. @@ -378,8 +382,8 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { ''; passthru = { - inherit nativeComp; - treeSitter = withTreeSitter; + inherit withNativeCompilation; + inherit withTreeSitter; pkgs = recurseIntoAttrs (emacsPackagesFor finalAttrs.finalPackage); tests = { inherit (nixosTests) emacs-daemon; }; }; From 5d68e9014cf30d00218d9a03e21d67d696115a41 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 4 Jun 2023 22:34:28 -0300 Subject: [PATCH 5/6] build-support/emacs: synchronize with emacs' modified attributes --- pkgs/build-support/emacs/generic.nix | 17 +++--------- pkgs/build-support/emacs/wrapper.nix | 41 +++++++++++----------------- 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/pkgs/build-support/emacs/generic.nix b/pkgs/build-support/emacs/generic.nix index e3d1505dde87..add8fb5525f9 100644 --- a/pkgs/build-support/emacs/generic.nix +++ b/pkgs/build-support/emacs/generic.nix @@ -2,32 +2,25 @@ { lib, stdenv, emacs, texinfo, writeText, gcc, ... }: -with lib; - { pname , version ? null - , buildInputs ? [] , packageRequires ? [] - , meta ? {} - , ... }@args: let - defaultMeta = { broken = false; platforms = emacs.meta.platforms; - } // optionalAttrs ((args.src.meta.homepage or "") != "") { + } // lib.optionalAttrs ((args.src.meta.homepage or "") != "") { homepage = args.src.meta.homepage; }; - in stdenv.mkDerivation ({ - name = "emacs-${pname}${optionalString (version != null) "-${version}"}"; + name = "emacs-${pname}${lib.optionalString (version != null) "-${version}"}"; unpackCmd = '' case "$curSrc" in @@ -68,7 +61,7 @@ stdenv.mkDerivation ({ meta = defaultMeta // meta; } -// lib.optionalAttrs (emacs.nativeComp or false) { +// lib.optionalAttrs (emacs.withNativeCompilation or false) { LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib"; @@ -90,6 +83,4 @@ stdenv.mkDerivation ({ ''; } -// removeAttrs args [ "buildInputs" "packageRequires" - "meta" - ]) +// removeAttrs args [ "buildInputs" "packageRequires" "meta" ]) diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix index bd7702ebb916..4c30a0657122 100644 --- a/pkgs/build-support/emacs/wrapper.nix +++ b/pkgs/build-support/emacs/wrapper.nix @@ -32,34 +32,25 @@ in customEmacsPackages.withPackages (epkgs: [ epkgs.evil epkgs.magit ]) */ -{ lib, lndir, makeWrapper, runCommand, gcc }: self: - -with lib; - +{ lib, lndir, makeWrapper, runCommand, gcc }: +self: let - inherit (self) emacs; - - nativeComp = emacs.nativeComp or false; - - treeSitter = emacs.treeSitter or false; - + withNativeCompilation = emacs.withNativeCompilation or false; + withTreeSitter = emacs.withTreeSitter or false; in - packagesFun: # packages explicitly requested by the user - let explicitRequires = if lib.isFunction packagesFun - then packagesFun self + then packagesFun self else packagesFun; in - runCommand - (appendToName "with-packages" emacs).name + (lib.appendToName "with-packages" emacs).name { - nativeBuildInputs = [ emacs lndir makeWrapper ]; inherit emacs explicitRequires; + nativeBuildInputs = [ emacs lndir makeWrapper ]; preferLocalBuild = true; allowSubstitutes = false; @@ -69,8 +60,8 @@ runCommand deps = runCommand "emacs-packages-deps" ({ inherit explicitRequires lndir emacs; - nativeBuildInputs = lib.optional nativeComp gcc; - } // lib.optionalAttrs nativeComp { + nativeBuildInputs = lib.optional withNativeCompilation gcc; + } // lib.optionalAttrs withNativeCompilation { inherit (emacs) LIBRARY_PATH; }) '' @@ -110,10 +101,10 @@ runCommand } mkdir -p $out/bin mkdir -p $out/share/emacs/site-lisp - ${optionalString nativeComp '' + ${lib.optionalString withNativeCompilation '' mkdir -p $out/share/emacs/native-lisp ''} - ${optionalString treeSitter '' + ${lib.optionalString withTreeSitter '' mkdir -p $out/lib ''} @@ -137,10 +128,10 @@ runCommand linkEmacsPackage() { linkPath "$1" "bin" "bin" linkPath "$1" "share/emacs/site-lisp" "share/emacs/site-lisp" - ${optionalString nativeComp '' + ${lib.optionalString withNativeCompilation '' linkPath "$1" "share/emacs/native-lisp" "share/emacs/native-lisp" ''} - ${optionalString treeSitter '' + ${lib.optionalString withTreeSitter '' linkPath "$1" "lib" "lib" ''} } @@ -171,10 +162,10 @@ runCommand (load-file "$emacs/share/emacs/site-lisp/site-start.el")) (add-to-list 'load-path "$out/share/emacs/site-lisp") (add-to-list 'exec-path "$out/bin") - ${optionalString nativeComp '' + ${lib.optionalString withNativeCompilation '' (add-to-list 'native-comp-eln-load-path "$out/share/emacs/native-lisp/") ''} - ${optionalString treeSitter '' + ${lib.optionalString withTreeSitter '' (add-to-list 'treesit-extra-load-path "$out/lib/") ''} EOF @@ -189,7 +180,7 @@ runCommand # Byte-compiling improves start-up time only slightly, but costs nothing. $emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs" - ${optionalString nativeComp '' + ${lib.optionalString withNativeCompilation '' $emacs/bin/emacs --batch \ --eval "(add-to-list 'native-comp-eln-load-path \"$out/share/emacs/native-lisp/\")" \ -f batch-native-compile "$siteStart" "$subdirs" From c8cb3bb3789e3b1f990651a9715be26f880e417a Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 4 Jun 2023 22:35:17 -0300 Subject: [PATCH 6/6] mu: synchronize with emacs' modified attributes --- pkgs/tools/networking/mu/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/networking/mu/default.nix b/pkgs/tools/networking/mu/default.nix index a0f14b2fc694..891a42ae1cdc 100644 --- a/pkgs/tools/networking/mu/default.nix +++ b/pkgs/tools/networking/mu/default.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { ''; # AOT native-comp, mostly copied from pkgs/build-support/emacs/generic.nix - postInstall = lib.optionalString (emacs.nativeComp or false) '' + postInstall = lib.optionalString (emacs.withNativeCompilation or false) '' mkdir -p $out/share/emacs/native-lisp export EMACSLOADPATH=$out/share/emacs/site-lisp/mu4e: export EMACSNATIVELOADPATH=$out/share/emacs/native-lisp: