git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitdecb5802c91915814fc6551442cd3f586a78de30 authorThomas Tuegel <ttuegel@gmail.com> dateSat 16 Jan 2016, 17:20 (11 years ago) parent1724a07
5 files changed+60−28
pkgs/applications/editors/emacs-modes/elpa-packages.nix+1−1 pkgs/build-support/emacs/elpa.nix+30 pkgs/build-support/emacs/elpa2nix.el+27 pkgs/build-support/emacs/melpa.nix+2−2 pkgs/build-support/emacs/melpa2nix.el−25
pkgs/applications/editors/emacs-modes/elpa-packages.nix+1−1
@@ -23,7 +23,7 @@ self:
2323
2424 super = removeAttrs imported [ "dash" ];
2525
26− elpaBuild = import ../../../build-support/emacs/melpa.nix {
26+ elpaBuild = import ../../../build-support/emacs/elpa.nix {
2727 inherit fetchurl lib stdenv texinfo;
2828 inherit (self) emacs;
2929 };
pkgs/build-support/emacs/elpa.nixnew file+30
@@ -0,0 +1,30 @@
1+# builder for Emacs packages built for packages.el
2+
3+{ lib, stdenv, fetchurl, emacs, texinfo }:
4+
5+with lib;
6+
7+{ pname
8+, version
9+, src
10+, ...
11+}@args:
12+
13+import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
14+
15+ phases = "installPhase fixupPhase distPhase";
16+
17+ installPhase = ''
18+ runHook preInstall
19+
20+ emacs --batch -Q -l ${./elpa2nix.el} \
21+ -f elpa2nix-install-package \
22+ "${src}" "$out/share/emacs/site-lisp/elpa"
23+
24+ runHook postInstall
25+ '';
26+}
27+
28+// removeAttrs args [ "files" "fileSpecs"
29+ "meta"
30+ ])
pkgs/build-support/emacs/elpa2nix.elnew file+27
@@ -0,0 +1,27 @@
1+(require 'package)
2+(package-initialize)
3+
4+(defun elpa2nix-install-package ()
5+ (if (not noninteractive)
6+ (error "`elpa2nix-install-package' is to be used only with -batch"))
7+ (pcase command-line-args-left
8+ (`(,archive ,elpa)
9+ (progn (setq package-user-dir elpa)
10+ (elpa2nix-install-file archive)))))
11+
12+(defun elpa2nix-install-from-buffer ()
13+ "Install a package from the current buffer."
14+ (let ((pkg-desc (if (derived-mode-p 'tar-mode)
15+ (package-tar-file-info)
16+ (package-buffer-info))))
17+ ;; Install the package itself.
18+ (package-unpack pkg-desc)
19+ pkg-desc))
20+
21+(defun elpa2nix-install-file (file)
22+ "Install a package from a file.
23+The file can either be a tar file or an Emacs Lisp file."
24+ (with-temp-buffer
25+ (insert-file-contents-literally file)
26+ (when (string-match "\\.tar\\'" file) (tar-mode))
27+ (elpa2nix-install-from-buffer)))
pkgs/build-support/emacs/melpa.nix+2−2
@@ -63,8 +63,8 @@ import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
6363 installPhase = ''
6464 runHook preInstall
6565
66− emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \
67− -f melpa2nix-install-package \
66+ emacs --batch -Q -l ${./elpa2nix.el} \
67+ -f elpa2nix-install-package \
6868 "$archive" "$out/share/emacs/site-lisp/elpa"
6969
7070 runHook postInstall
pkgs/build-support/emacs/melpa2nix.el−25
@@ -6,14 +6,6 @@
66(setq package-build-working-dir (expand-file-name ".")
77 package-build-archive-dir (expand-file-name "."))
88
9−(defun melpa2nix-install-package ()
10− (if (not noninteractive)
11− (error "`melpa2nix-install-package' is to be used only with -batch"))
12− (pcase command-line-args-left
13− (`(,archive ,elpa)
14− (progn (setq package-user-dir elpa)
15− (melpa2nix-install-file archive)))))
16−
179(defun melpa2nix-build-package ()
1810 (if (not noninteractive)
1911 (error "`melpa2nix-build-package' is to be used only with -batch"))
@@ -48,20 +40,3 @@
4840 (time-to-seconds (time-since start-time))
4941 (current-time-string))
5042 (princ (format "%s\n" archive-file)))))
51−
52−(defun melpa2nix-install-from-buffer ()
53− "Install a package from the current buffer."
54− (let ((pkg-desc (if (derived-mode-p 'tar-mode)
55− (package-tar-file-info)
56− (package-buffer-info))))
57− ;; Install the package itself.
58− (package-unpack pkg-desc)
59− pkg-desc))
60−
61−(defun melpa2nix-install-file (file)
62− "Install a package from a file.
63−The file can either be a tar file or an Emacs Lisp file."
64− (with-temp-buffer
65− (insert-file-contents-literally file)
66− (when (string-match "\\.tar\\'" file) (tar-mode))
67− (melpa2nix-install-from-buffer)))