2015-02-09 01:29:48 +01:00
|
|
|
(require 'package)
|
|
|
|
(package-initialize)
|
|
|
|
|
2018-07-16 03:52:41 +02:00
|
|
|
(require 'package-recipe)
|
2015-02-09 01:29:48 +01:00
|
|
|
(require 'package-build)
|
|
|
|
|
2018-07-16 03:52:41 +02:00
|
|
|
(setq package-build-working-dir (expand-file-name "working/"))
|
|
|
|
(setq package-build-archive-dir (expand-file-name "packages/"))
|
|
|
|
(setq package-build-recipes-dir (expand-file-name "recipes/"))
|
2015-02-09 01:29:48 +01:00
|
|
|
|
2021-12-19 17:07:18 +01:00
|
|
|
;; Allow installing package tarfiles larger than 10MB
|
|
|
|
(setq large-file-warning-threshold nil)
|
|
|
|
|
2023-12-29 14:00:46 +01:00
|
|
|
(defun melpa2nix-build-package-1 (rcp)
|
|
|
|
(let* ((default-directory (package-recipe--working-tree rcp)))
|
2022-05-23 21:52:17 +02:00
|
|
|
(unwind-protect
|
|
|
|
(let ((files (package-build-expand-files-spec rcp t)))
|
2023-12-29 14:00:46 +01:00
|
|
|
(unless files
|
|
|
|
(error "Unable to find files matching recipe patterns"))
|
|
|
|
(if (> (length files) 1)
|
|
|
|
(package-build--build-multi-file-package rcp files)
|
|
|
|
(package-build--build-single-file-package rcp files))))))
|
2022-05-23 21:52:17 +02:00
|
|
|
|
2015-02-09 01:29:48 +01:00
|
|
|
(defun melpa2nix-build-package ()
|
2023-12-29 14:00:46 +01:00
|
|
|
(unless noninteractive
|
|
|
|
(error "`melpa2nix-build-package' is to be used only with -batch"))
|
2015-02-09 01:29:48 +01:00
|
|
|
(pcase command-line-args-left
|
2021-07-06 17:52:13 +02:00
|
|
|
(`(,package ,version ,commit)
|
2023-12-29 14:00:46 +01:00
|
|
|
(let ((recipe (package-recipe-lookup package)))
|
|
|
|
(setf (oref recipe commit) commit)
|
|
|
|
(setf (oref recipe version) version)
|
|
|
|
(melpa2nix-build-package-1 recipe)))))
|