summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-10-16 10:12:53 +0200
committerLudovic Courtès <ludo@gnu.org>2017-10-22 22:09:00 -0700
commitd298c815e638581d466222f3a883b280f019b368 (patch)
treeec0f0c1928ffc9a8391b8063ab5946c109673e30 /guix/gexp.scm
parentdedb512f8f2282f7de3d5b56e7551e486e37840c (diff)
downloadgnu-guix-d298c815e638581d466222f3a883b280f019b368.tar
gnu-guix-d298c815e638581d466222f3a883b280f019b368.tar.gz
gexp: Add 'directory-union'.
* gnu/services.scm (directory-union): Move to... * guix/gexp.scm (directory-union): ... here. New procedure. * doc/guix.texi (G-Expressions): Document it.
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 9835599bb8..b9525603ee 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -79,6 +79,7 @@
text-file*
mixed-text-file
file-union
+ directory-union
imported-files
imported-modules
compiled-modules
@@ -1203,6 +1204,25 @@ This yields an 'etc' directory containing these two files."
(ungexp target))))))
files))))))
+(define (directory-union name things)
+ "Return a directory that is the union of THINGS, where THINGS is a list of
+file-like objects denoting directories. For example:
+
+ (directory-union \"guile+emacs\" (list guile emacs))
+
+yields a directory that is the union of the 'guile' and 'emacs' packages."
+ (match things
+ ((one)
+ ;; Only one thing; return it.
+ one)
+ (_
+ (computed-file name
+ (with-imported-modules '((guix build union))
+ (gexp (begin
+ (use-modules (guix build union))
+ (union-build (ungexp output)
+ '(ungexp things)))))))))
+
;;;
;;; Syntactic sugar.