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.
This commit is contained in:
Ludovic Courtès 2017-10-16 10:12:53 +02:00
parent dedb512f8f
commit d298c815e6
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 32 additions and 16 deletions

View File

@ -5007,6 +5007,17 @@ denoting the target file. Here's an example:
This yields an @code{etc} directory containing these two files. This yields an @code{etc} directory containing these two files.
@end deffn @end deffn
@deffn {Scheme Procedure} directory-union @var{name} @var{things}
Return a directory that is the union of @var{things}, where @var{things} is a list of
file-like objects denoting directories. For example:
@example
(directory-union "guile+emacs" (list guile emacs))
@end example
yields a directory that is the union of the @code{guile} and @code{emacs} packages.
@end deffn
@deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{} @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
Return a file-like object that expands to the concatenation of @var{obj} Return a file-like object that expands to the concatenation of @var{obj}
and @var{suffix}, where @var{obj} is a lowerable object and each and @var{suffix}, where @var{obj} is a lowerable object and each

View File

@ -95,9 +95,7 @@
%boot-service %boot-service
%activation-service %activation-service
etc-service etc-service))
directory-union))
;;; Comment: ;;; Comment:
;;; ;;;
@ -387,19 +385,6 @@ boot."
(list (service-extension boot-service-type (list (service-extension boot-service-type
cleanup-gexp))))) cleanup-gexp)))))
(define (directory-union name things)
"Return a directory that is the union of THINGS."
(match things
((one)
;; Only one thing; return it.
one)
(_
(computed-file name
(with-imported-modules '((guix build union))
#~(begin
(use-modules (guix build union))
(union-build #$output '#$things)))))))
(define* (activation-service->script service) (define* (activation-service->script service)
"Return as a monadic value the activation script for SERVICE, a service of "Return as a monadic value the activation script for SERVICE, a service of
ACTIVATION-SCRIPT-TYPE." ACTIVATION-SCRIPT-TYPE."

View File

@ -79,6 +79,7 @@
text-file* text-file*
mixed-text-file mixed-text-file
file-union file-union
directory-union
imported-files imported-files
imported-modules imported-modules
compiled-modules compiled-modules
@ -1203,6 +1204,25 @@ This yields an 'etc' directory containing these two files."
(ungexp target)))))) (ungexp target))))))
files)))))) 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. ;;; Syntactic sugar.