summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Gesthuizen <tim.gesthuizen@yahoo.de>2019-01-04 22:34:36 +0100
committerPierre Neidhardt <mail@ambrevar.xyz>2019-01-07 14:45:21 +0100
commit7d5856bd4570a6c5a3cf1daf6273b638e09b6d50 (patch)
tree27ba2073a9930dda1b676777aafe77defc60f59f
parent915c6bf60cd6bd69fafc3acc69fac1242c3d96a3 (diff)
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
-rw-r--r--gnu/packages/emacs.scm32
1 files changed, 31 insertions, 1 deletions
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index ec67f278c9..cbfec8f70a 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -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.