2015-02-09 01:29:48 +01:00
|
|
|
(require 'package)
|
|
|
|
(package-initialize)
|
|
|
|
|
|
|
|
(require 'package-build)
|
|
|
|
|
|
|
|
(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)
|
|
|
|
(package-install-file archive)))))
|
|
|
|
|
|
|
|
(defun melpa2nix-build-package ()
|
|
|
|
(if (not noninteractive)
|
|
|
|
(error "`melpa2nix-build-package' is to be used only with -batch"))
|
|
|
|
(pcase command-line-args-left
|
|
|
|
(`(,package ,version . ,files)
|
|
|
|
(melpa2nix-package-build-archive package version files))))
|
|
|
|
|
2015-12-29 20:23:49 +01:00
|
|
|
(defun melpa2nix-build-package-from-recipe ()
|
|
|
|
(if (not noninteractive)
|
|
|
|
(error "`melpa2nix-build-package' is to be used only with -batch"))
|
|
|
|
(pcase command-line-args-left
|
|
|
|
(`(,package ,version ,recipe-file)
|
|
|
|
(let* ((rcp (cdr (package-build--read-from-file recipe-file)))
|
|
|
|
(files (package-build--config-file-list rcp)))
|
|
|
|
(melpa2nix-package-build-archive package version files)))))
|
|
|
|
|
2015-02-09 01:29:48 +01:00
|
|
|
(defun melpa2nix-package-build-archive (name version files)
|
|
|
|
"Build a package archive for package NAME."
|
2015-12-27 17:37:02 +01:00
|
|
|
(package-build--message "\n;;; %s\n" name)
|
2015-02-09 01:29:48 +01:00
|
|
|
(let* ((start-time (current-time))
|
|
|
|
(archive-entry (package-build-package name
|
|
|
|
version
|
|
|
|
files
|
|
|
|
package-build-working-dir
|
|
|
|
package-build-archive-dir)))
|
2015-12-27 17:37:02 +01:00
|
|
|
|
|
|
|
(package-build--message "Built in %.3fs, finished at %s"
|
|
|
|
(time-to-seconds (time-since start-time))
|
|
|
|
(current-time-string))))
|