From 5016fdb2696d95adf4d9c162c5de7d92316444b8 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 10 Dec 2020 21:31:49 +0000 Subject: emacsPackages.elpaBuild: pass through meta Previously, meta wasn't being passed through at all, because it's removed from args without being used anywhere. This made it so that rcirc-menu wasn't being marked as broken even though it was supposed to be. This patch copies the meta handling from melpaBuild, including the default home page (adapted for ELPA). --- pkgs/build-support/emacs/elpa.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pkgs/build-support/emacs/elpa.nix') diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix index e6f6c23e449..214aed9c3f9 100644 --- a/pkgs/build-support/emacs/elpa.nix +++ b/pkgs/build-support/emacs/elpa.nix @@ -7,9 +7,18 @@ with lib; { pname , version , src +, meta ? {} , ... }@args: +let + + defaultMeta = { + homepage = args.src.meta.homepage or "https://elpa.gnu.org/packages/${pname}.html"; + }; + +in + import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ phases = "installPhase fixupPhase distPhase"; @@ -23,6 +32,8 @@ import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ runHook postInstall ''; + + meta = defaultMeta // meta; } // removeAttrs args [ "files" "fileSpecs" -- cgit 1.4.1 From ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b Mon Sep 17 00:00:00 2001 From: Mauricio Collares Date: Mon, 28 Dec 2020 01:12:44 -0300 Subject: emacs: add currently compiling package dirs to load-path Co-authored-by: Tad Fisher --- .../editors/emacs-modes/elpa-packages.nix | 4 +- pkgs/build-support/emacs/elpa.nix | 4 +- pkgs/build-support/emacs/emacs-funcs.sh | 34 +++++++++++++++++ pkgs/build-support/emacs/generic.nix | 25 ++++++++++-- pkgs/build-support/emacs/melpa.nix | 4 +- pkgs/build-support/emacs/setup-hook.sh | 44 ---------------------- pkgs/top-level/emacs-packages.nix | 2 +- 7 files changed, 63 insertions(+), 54 deletions(-) create mode 100644 pkgs/build-support/emacs/emacs-funcs.sh delete mode 100644 pkgs/build-support/emacs/setup-hook.sh (limited to 'pkgs/build-support/emacs/elpa.nix') diff --git a/pkgs/applications/editors/emacs-modes/elpa-packages.nix b/pkgs/applications/editors/emacs-modes/elpa-packages.nix index 8b9ad33fce7..98c265894ea 100644 --- a/pkgs/applications/editors/emacs-modes/elpa-packages.nix +++ b/pkgs/applications/editors/emacs-modes/elpa-packages.nix @@ -20,7 +20,7 @@ instantenous and formats commits for you. */ -{ lib, stdenv, texinfo }: +{ lib, stdenv, texinfo, writeText }: self: let @@ -31,7 +31,7 @@ self: let }; elpaBuild = import ../../../build-support/emacs/elpa.nix { - inherit lib stdenv texinfo; + inherit lib stdenv texinfo writeText; inherit (self) emacs; }; diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix index 214aed9c3f9..41a0670d0c8 100644 --- a/pkgs/build-support/emacs/elpa.nix +++ b/pkgs/build-support/emacs/elpa.nix @@ -1,6 +1,6 @@ # builder for Emacs packages built for packages.el -{ lib, stdenv, emacs, texinfo }: +{ lib, stdenv, emacs, texinfo, writeText }: with lib; @@ -19,7 +19,7 @@ let in -import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ +import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({ phases = "installPhase fixupPhase distPhase"; diff --git a/pkgs/build-support/emacs/emacs-funcs.sh b/pkgs/build-support/emacs/emacs-funcs.sh new file mode 100644 index 00000000000..e1e6a3b6220 --- /dev/null +++ b/pkgs/build-support/emacs/emacs-funcs.sh @@ -0,0 +1,34 @@ +addToEmacsLoadPath() { + local lispDir="$1" + if [[ -d $lispDir && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then + # It turns out, that the trailing : is actually required + # see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html + export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}" + fi +} + +addToEmacsNativeLoadPath() { + local nativeDir="$1" + if [[ -d $nativeDir && ${EMACSNATIVELOADPATH-} != *"$nativeDir":* ]]; then + export EMACSNATIVELOADPATH="$nativeDir:${EMACSNATIVELOADPATH-}" + fi +} + +addEmacsVars () { + addToEmacsLoadPath "$1/share/emacs/site-lisp" + + if [ -n "${addEmacsNativeLoadPath:-}" ]; then + addToEmacsNativeLoadPath "$1/share/emacs/native-lisp" + fi + + # Add sub paths to the Emacs load path if it is a directory + # containing .el files. This is necessary to build some packages, + # e.g., using trivialBuild. + for lispDir in \ + "$1/share/emacs/site-lisp/"* \ + "$1/share/emacs/site-lisp/elpa/"*; do + if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" ]] ; then + addToEmacsLoadPath "$lispDir" + fi + done +} diff --git a/pkgs/build-support/emacs/generic.nix b/pkgs/build-support/emacs/generic.nix index d84fa24923d..1456d9e423d 100644 --- a/pkgs/build-support/emacs/generic.nix +++ b/pkgs/build-support/emacs/generic.nix @@ -1,6 +1,6 @@ # generic builder for Emacs packages -{ lib, stdenv, emacs, texinfo, ... }: +{ lib, stdenv, emacs, texinfo, writeText, ... }: with lib; @@ -49,7 +49,19 @@ stdenv.mkDerivation ({ propagatedBuildInputs = packageRequires; propagatedUserEnvPkgs = packageRequires; - setupHook = ./setup-hook.sh; + setupHook = writeText "setup-hook.sh" '' + source ${./emacs-funcs.sh} + + if [[ ! -v emacsHookDone ]]; then + emacsHookDone=1 + + # If this is for a wrapper derivation, emacs and the dependencies are all + # run-time dependencies. If this is for precompiling packages into bytecode, + # emacs is a compile-time dependency of the package. + addEnvHooks "$hostOffset" addEmacsVars + addEnvHooks "$targetOffset" addEmacsVars + fi + ''; doCheck = false; @@ -63,9 +75,16 @@ stdenv.mkDerivation ({ addEmacsNativeLoadPath = true; postInstall = '' + # Besides adding the output directory to the native load path, make sure + # the current package's elisp files are in the load path, otherwise + # (require 'file-b) from file-a.el in the same package will fail. + mkdir -p $out/share/emacs/native-lisp + source ${./emacs-funcs.sh} + addEmacsVars "$out" + find $out/share/emacs -type f -name '*.el' -print0 \ | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \ - "emacs --batch --eval=\"(add-to-list 'comp-eln-load-path \\\"$out/share/emacs/native-lisp/\\\")\" -f batch-native-compile {} || true" + "emacs --batch -f batch-native-compile {} || true" ''; } diff --git a/pkgs/build-support/emacs/melpa.nix b/pkgs/build-support/emacs/melpa.nix index d6fe3085837..824611b20c8 100644 --- a/pkgs/build-support/emacs/melpa.nix +++ b/pkgs/build-support/emacs/melpa.nix @@ -1,7 +1,7 @@ # builder for Emacs packages built for packages.el # using MELPA package-build.el -{ lib, stdenv, fetchFromGitHub, emacs, texinfo }: +{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }: with lib; @@ -28,7 +28,7 @@ let in -import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ +import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({ ename = if ename == null diff --git a/pkgs/build-support/emacs/setup-hook.sh b/pkgs/build-support/emacs/setup-hook.sh deleted file mode 100644 index f6f2331b8e0..00000000000 --- a/pkgs/build-support/emacs/setup-hook.sh +++ /dev/null @@ -1,44 +0,0 @@ -addToEmacsLoadPath() { - local lispDir="$1" - if [[ -d $lispDir && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then - # It turns out, that the trailing : is actually required - # see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html - export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}" - fi -} - -addToEmacsNativeLoadPath() { - local nativeDir="$1" - if [[ -d $nativeDir && ${EMACSNATIVELOADPATH-} != *"$nativeDir":* ]]; then - export EMACSNATIVELOADPATH="$nativeDir:${EMACSNATIVELOADPATH-}" - fi -} - -addEmacsVars () { - addToEmacsLoadPath "$1/share/emacs/site-lisp" - - if [ -n "${addEmacsNativeLoadPath:-}" ]; then - addToEmacsNativeLoadPath "$1/share/emacs/native-lisp" - fi - - # Add sub paths to the Emacs load path if it is a directory - # containing .el files. This is necessary to build some packages, - # e.g., using trivialBuild. - for lispDir in \ - "$1/share/emacs/site-lisp/"* \ - "$1/share/emacs/site-lisp/elpa/"*; do - if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" ]] ; then - addToEmacsLoadPath "$lispDir" - fi - done -} - -if [[ ! -v emacsHookDone ]]; then - emacsHookDone=1 - - # If this is for a wrapper derivation, emacs and the dependencies are all - # run-time dependencies. If this is for precompiling packages into bytecode, - # emacs is a compile-time dependency of the package. - addEnvHooks "$hostOffset" addEmacsVars - addEnvHooks "$targetOffset" addEmacsVars -fi diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index d0bb7c56d99..329fb572582 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -45,7 +45,7 @@ let mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix { - inherit lib stdenv texinfo; + inherit lib stdenv texinfo writeText; }; # Contains both melpa stable & unstable -- cgit 1.4.1 From 8bc10fbc56db2aaf1f234349e4d0c7607b8ead4f Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 12 Jun 2021 11:21:35 -0500 Subject: Add gcc for emacs wrapper so native-comp works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macos, we don’t have a gcc executable by default, which is required for some reason when compiling site-start. --- pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix | 3 ++- pkgs/build-support/emacs/elpa.nix | 4 ++-- pkgs/build-support/emacs/generic.nix | 4 +++- pkgs/build-support/emacs/melpa.nix | 4 ++-- pkgs/build-support/emacs/wrapper.nix | 7 +++++-- pkgs/top-level/emacs-packages.nix | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) (limited to 'pkgs/build-support/emacs/elpa.nix') diff --git a/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix index 02a9a6e6562..cefed111f4f 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix @@ -21,7 +21,7 @@ formats commits for you. */ -{ lib, stdenv, texinfo, writeText }: +{ lib, stdenv, texinfo, writeText, gcc }: self: let @@ -34,6 +34,7 @@ self: let elpaBuild = import ../../../../build-support/emacs/elpa.nix { inherit lib stdenv texinfo writeText; inherit (self) emacs; + inherit gcc; }; generateElpa = lib.makeOverridable ({ diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix index 41a0670d0c8..965b8d8189a 100644 --- a/pkgs/build-support/emacs/elpa.nix +++ b/pkgs/build-support/emacs/elpa.nix @@ -1,6 +1,6 @@ # builder for Emacs packages built for packages.el -{ lib, stdenv, emacs, texinfo, writeText }: +{ lib, stdenv, emacs, texinfo, writeText, gcc }: with lib; @@ -19,7 +19,7 @@ let in -import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({ +import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({ phases = "installPhase fixupPhase distPhase"; diff --git a/pkgs/build-support/emacs/generic.nix b/pkgs/build-support/emacs/generic.nix index 1456d9e423d..ef154982ad0 100644 --- a/pkgs/build-support/emacs/generic.nix +++ b/pkgs/build-support/emacs/generic.nix @@ -1,6 +1,6 @@ # generic builder for Emacs packages -{ lib, stdenv, emacs, texinfo, writeText, ... }: +{ lib, stdenv, emacs, texinfo, writeText, gcc, ... }: with lib; @@ -72,6 +72,8 @@ stdenv.mkDerivation ({ LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib"; + nativeBuildInputs = [ gcc ]; + addEmacsNativeLoadPath = true; postInstall = '' diff --git a/pkgs/build-support/emacs/melpa.nix b/pkgs/build-support/emacs/melpa.nix index 824611b20c8..5c41a66970e 100644 --- a/pkgs/build-support/emacs/melpa.nix +++ b/pkgs/build-support/emacs/melpa.nix @@ -1,7 +1,7 @@ # builder for Emacs packages built for packages.el # using MELPA package-build.el -{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }: +{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText, gcc }: with lib; @@ -28,7 +28,7 @@ let in -import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({ +import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({ ename = if ename == null diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix index 571d0eb687c..6b53f3fdd95 100644 --- a/pkgs/build-support/emacs/wrapper.nix +++ b/pkgs/build-support/emacs/wrapper.nix @@ -32,7 +32,7 @@ in customEmacsPackages.emacs.pkgs.withPackages (epkgs: [ epkgs.evil epkgs.magit */ -{ lib, lndir, makeWrapper, runCommand }: self: +{ lib, lndir, makeWrapper, runCommand, gcc }: self: with lib; @@ -65,7 +65,10 @@ runCommand # Store all paths we want to add to emacs here, so that we only need to add # one path to the load lists deps = runCommand "emacs-packages-deps" - { inherit explicitRequires lndir emacs; } + { + inherit explicitRequires lndir emacs; + nativeBuildInputs = lib.optional nativeComp gcc; + } '' findInputsOld() { local pkg="$1"; shift diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index d168d34e373..34f99561601 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -26,7 +26,7 @@ let mkElpaPackages = { pkgs, lib }: import ../applications/editors/emacs/elisp-packages/elpa-packages.nix { - inherit (pkgs) stdenv texinfo writeText; + inherit (pkgs) stdenv texinfo writeText gcc; inherit lib; }; @@ -44,7 +44,7 @@ let }; emacsWithPackages = { pkgs, lib }: import ../build-support/emacs/wrapper.nix { - inherit (pkgs) makeWrapper runCommand; + inherit (pkgs) makeWrapper runCommand gcc; inherit (pkgs.xorg) lndir; inherit lib; }; -- cgit 1.4.1 From 46d4bb5d01175feefbe8f3fdaee68701801e9741 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 30 Jun 2021 07:49:08 -0700 Subject: elpaBuild: Delay src evaluation so it can be overridden This change allows ELPA packages to have their src attribute updated by overrideAttrs. Without this change the installPhase references the original src attribute and overriding is not possible. --- pkgs/build-support/emacs/elpa.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/build-support/emacs/elpa.nix') diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix index 41a0670d0c8..61960ed22c6 100644 --- a/pkgs/build-support/emacs/elpa.nix +++ b/pkgs/build-support/emacs/elpa.nix @@ -28,7 +28,7 @@ import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({ emacs --batch -Q -l ${./elpa2nix.el} \ -f elpa2nix-install-package \ - "${src}" "$out/share/emacs/site-lisp/elpa" + "$src" "$out/share/emacs/site-lisp/elpa" runHook postInstall ''; -- cgit 1.4.1