diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index ddfdbe337186..4a981930e549 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 ? _: [ ] @@ -74,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 @@ -96,7 +98,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 @@ -120,7 +122,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 = [ @@ -134,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; @@ -142,6 +144,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" @@ -150,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 @@ -242,8 +245,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { motif ] ++ lib.optionals (withX && withXwidgets) [ glib-networking - webkitgtk - ] ++ lib.optionals nativeComp [ + ] ++ lib.optionals withNativeCompilation [ libgccjit ] ++ lib.optionals withImageMagick [ imagemagick @@ -266,7 +268,6 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { ] ++ lib.optionals withX [ Xaw3d cairo - giflib libXaw libXpm @@ -274,6 +275,8 @@ mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp { libpng librsvg libtiff + ] ++ lib.optionals withXwidgets [ + webkitgtk ] ++ lib.optionals stdenv.isDarwin [ sigtool ] ++ lib.optionals withNS [ @@ -325,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" @@ -356,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. @@ -379,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; }; }; 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" 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: