2015-02-09 03:29:48 +03: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-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 22:23:49 +03: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
|
2016-01-16 02:53:54 +03:00
|
|
|
(`(,recipe-file ,version)
|
|
|
|
(let* ((recipe (package-build--read-from-file recipe-file))
|
|
|
|
(rcp (cdr recipe))
|
|
|
|
(package (car recipe))
|
2015-12-29 22:23:49 +03:00
|
|
|
(files (package-build--config-file-list rcp)))
|
|
|
|
(melpa2nix-package-build-archive package version files)))))
|
|
|
|
|
2015-02-09 03:29:48 +03:00
|
|
|
(defun melpa2nix-package-build-archive (name version files)
|
|
|
|
"Build a package archive for package NAME."
|
2015-12-27 19:37:02 +03:00
|
|
|
(package-build--message "\n;;; %s\n" name)
|
2015-02-09 03:29:48 +03:00
|
|
|
(let* ((start-time (current-time))
|
|
|
|
(archive-entry (package-build-package name
|
|
|
|
version
|
|
|
|
files
|
|
|
|
package-build-working-dir
|
2016-01-16 19:01:33 +03:00
|
|
|
package-build-archive-dir))
|
|
|
|
(archive-file (package-build--archive-file-name archive-entry)))
|
2015-12-27 19:37:02 +03:00
|
|
|
|
2016-01-16 19:01:33 +03:00
|
|
|
(progn
|
|
|
|
(package-build--message "Built in %.3fs, finished at %s"
|
2015-12-27 19:37:02 +03:00
|
|
|
(time-to-seconds (time-since start-time))
|
2016-01-16 19:01:33 +03:00
|
|
|
(current-time-string))
|
|
|
|
(princ (format "%s\n" archive-file)))))
|