diff options
author | Thomas Tuegel <ttuegel@gmail.com> | 2016-01-16 17:20:06 -0600 |
---|---|---|
committer | Thomas Tuegel <ttuegel@gmail.com> | 2016-01-18 15:29:19 -0600 |
commit | decb5802c91915814fc6551442cd3f586a78de30 (patch) | |
tree | c27b785a10bf89000419d00e4781160e724326f7 | |
parent | 1724a07e2e06a7de4c30fc0983dfd4411771183e (diff) | |
download | nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar.gz nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar.bz2 nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar.lz nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar.xz nixlib-decb5802c91915814fc6551442cd3f586a78de30.tar.zst nixlib-decb5802c91915814fc6551442cd3f586a78de30.zip |
elpaBuild: factor out package installation
Building packages requires package-build.el from Melpa, but installing packages only requires package.el. Packages from ELPA are already built, so there is no need to involve package-build.el.
-rw-r--r-- | pkgs/applications/editors/emacs-modes/elpa-packages.nix | 2 | ||||
-rw-r--r-- | pkgs/build-support/emacs/elpa.nix | 30 | ||||
-rw-r--r-- | pkgs/build-support/emacs/elpa2nix.el | 27 | ||||
-rw-r--r-- | pkgs/build-support/emacs/melpa.nix | 4 | ||||
-rw-r--r-- | pkgs/build-support/emacs/melpa2nix.el | 25 |
5 files changed, 60 insertions, 28 deletions
diff --git a/pkgs/applications/editors/emacs-modes/elpa-packages.nix b/pkgs/applications/editors/emacs-modes/elpa-packages.nix index 60cd4251888f..7fc8a06644f9 100644 --- a/pkgs/applications/editors/emacs-modes/elpa-packages.nix +++ b/pkgs/applications/editors/emacs-modes/elpa-packages.nix @@ -23,7 +23,7 @@ self: super = removeAttrs imported [ "dash" ]; - elpaBuild = import ../../../build-support/emacs/melpa.nix { + elpaBuild = import ../../../build-support/emacs/elpa.nix { inherit fetchurl lib stdenv texinfo; inherit (self) emacs; }; diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix new file mode 100644 index 000000000000..79a26abcb831 --- /dev/null +++ b/pkgs/build-support/emacs/elpa.nix @@ -0,0 +1,30 @@ +# builder for Emacs packages built for packages.el + +{ lib, stdenv, fetchurl, emacs, texinfo }: + +with lib; + +{ pname +, version +, src +, ... +}@args: + +import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ + + phases = "installPhase fixupPhase distPhase"; + + installPhase = '' + runHook preInstall + + emacs --batch -Q -l ${./elpa2nix.el} \ + -f elpa2nix-install-package \ + "${src}" "$out/share/emacs/site-lisp/elpa" + + runHook postInstall + ''; +} + +// removeAttrs args [ "files" "fileSpecs" + "meta" + ]) diff --git a/pkgs/build-support/emacs/elpa2nix.el b/pkgs/build-support/emacs/elpa2nix.el new file mode 100644 index 000000000000..3a2d65d640f4 --- /dev/null +++ b/pkgs/build-support/emacs/elpa2nix.el @@ -0,0 +1,27 @@ +(require 'package) +(package-initialize) + +(defun elpa2nix-install-package () + (if (not noninteractive) + (error "`elpa2nix-install-package' is to be used only with -batch")) + (pcase command-line-args-left + (`(,archive ,elpa) + (progn (setq package-user-dir elpa) + (elpa2nix-install-file archive))))) + +(defun elpa2nix-install-from-buffer () + "Install a package from the current buffer." + (let ((pkg-desc (if (derived-mode-p 'tar-mode) + (package-tar-file-info) + (package-buffer-info)))) + ;; Install the package itself. + (package-unpack pkg-desc) + pkg-desc)) + +(defun elpa2nix-install-file (file) + "Install a package from a file. +The file can either be a tar file or an Emacs Lisp file." + (with-temp-buffer + (insert-file-contents-literally file) + (when (string-match "\\.tar\\'" file) (tar-mode)) + (elpa2nix-install-from-buffer))) diff --git a/pkgs/build-support/emacs/melpa.nix b/pkgs/build-support/emacs/melpa.nix index fb2440811476..3b8a23d8c2a4 100644 --- a/pkgs/build-support/emacs/melpa.nix +++ b/pkgs/build-support/emacs/melpa.nix @@ -63,8 +63,8 @@ import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ installPhase = '' runHook preInstall - emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \ - -f melpa2nix-install-package \ + emacs --batch -Q -l ${./elpa2nix.el} \ + -f elpa2nix-install-package \ "$archive" "$out/share/emacs/site-lisp/elpa" runHook postInstall diff --git a/pkgs/build-support/emacs/melpa2nix.el b/pkgs/build-support/emacs/melpa2nix.el index fb35fc681257..3cd5bbdb954a 100644 --- a/pkgs/build-support/emacs/melpa2nix.el +++ b/pkgs/build-support/emacs/melpa2nix.el @@ -6,14 +6,6 @@ (setq package-build-working-dir (expand-file-name ".") package-build-archive-dir (expand-file-name ".")) -(defun melpa2nix-install-package () - (if (not noninteractive) - (error "`melpa2nix-install-package' is to be used only with -batch")) - (pcase command-line-args-left - (`(,archive ,elpa) - (progn (setq package-user-dir elpa) - (melpa2nix-install-file archive))))) - (defun melpa2nix-build-package () (if (not noninteractive) (error "`melpa2nix-build-package' is to be used only with -batch")) @@ -48,20 +40,3 @@ (time-to-seconds (time-since start-time)) (current-time-string)) (princ (format "%s\n" archive-file))))) - -(defun melpa2nix-install-from-buffer () - "Install a package from the current buffer." - (let ((pkg-desc (if (derived-mode-p 'tar-mode) - (package-tar-file-info) - (package-buffer-info)))) - ;; Install the package itself. - (package-unpack pkg-desc) - pkg-desc)) - -(defun melpa2nix-install-file (file) - "Install a package from a file. -The file can either be a tar file or an Emacs Lisp file." - (with-temp-buffer - (insert-file-contents-literally file) - (when (string-match "\\.tar\\'" file) (tar-mode)) - (melpa2nix-install-from-buffer))) |