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.
This commit is contained in:
parent
1724a07e2e
commit
decb5802c9
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
])
|
|
@ -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)))
|
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue