summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/editors/emacs-modes/elpa-packages.nix2
-rw-r--r--pkgs/build-support/emacs/elpa.nix30
-rw-r--r--pkgs/build-support/emacs/elpa2nix.el27
-rw-r--r--pkgs/build-support/emacs/melpa.nix4
-rw-r--r--pkgs/build-support/emacs/melpa2nix.el25
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 60cd4251888..7fc8a06644f 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 00000000000..79a26abcb83
--- /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 00000000000..3a2d65d640f
--- /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 fb244081147..3b8a23d8c2a 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 fb35fc68125..3cd5bbdb954 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)))