gnu: Add package-elisp-from-package

Add a function to generate package definitions that packages single elisp
files from other packages.

* gnu/packages/emacs.scm (package-elisp-from-package): New function
master
Tim Gesthuizen 2019-01-04 22:34:36 +01:00 committed by Pierre Neidhardt
parent 915c6bf60c
commit 7d5856bd45
No known key found for this signature in database
GPG Key ID: 9BDCF497A4BBCC7F
1 changed files with 31 additions and 1 deletions

View File

@ -35,7 +35,7 @@
;;; Copyright © 2018 Sohom Bhattacharjee <soham.bhattacharjee15@gmail.com>
;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
;;; Copyright © 2018, 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
;;; Copyright © 2018 Jack Hill <jackhill@jackhill.us>
;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
;;; Copyright © 2018 Alex Branham <alex.branham@gmail.com>
@ -331,6 +331,36 @@ editor (without an X toolkit)" )
(lambda _
(invoke "mkdir" "-p" "src/deps")))))))))
(define-public (package-elisp-from-package
source-package package-name source-files)
"Returns a package definition that packages emacs-lisp files from the
SOURCE-PACKAGEs source. The package has the name PACKAGE-NAME and packages
the files SOURCE-FILES from the source in its root directory."
(let ((orig (package-source source-package)))
(package
(inherit source-package)
(name package-name)
(build-system emacs-build-system)
(source (origin
(method (origin-method orig))
(uri (origin-uri orig))
(sha256 (origin-sha256 orig))
(file-name (string-append package-name "-"
(package-version source-package)))
(modules '((guix build utils)
(srfi srfi-1)
(ice-9 ftw)))
(snippet
`(let* ((source-files (quote ,source-files))
(basenames (map basename source-files)))
(map copy-file
source-files basenames)
(map delete-file-recursively
(fold delete
(scandir ".")
(append '("." "..") basenames)))
#t)))))))
;;;
;;; Emacs hacking.