From: "Ludovic Courtès" <ludo@gnu.org>
To: 27284@debbugs.gnu.org
Subject: bug#27284: [PATCH 4/8] gexp: Add 'file-union'.
Date: Fri, 20 Oct 2017 18:05:53 +0200 [thread overview]
Message-ID: <20171020160557.27096-5-ludo@gnu.org> (raw)
In-Reply-To: <20171020160557.27096-1-ludo@gnu.org>
* gnu/services.scm (file-union): Move to...
* guix/gexp.scm (file-union): ... here. New procedure.
* doc/guix.texi (G-Expressions): Document it.
---
doc/guix.texi | 17 +++++++++++++++++
gnu/services.scm | 20 --------------------
guix/gexp.scm | 32 ++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 20 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index b7f4f88f9..1de3494da 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4990,6 +4990,23 @@ as in:
This is the declarative counterpart of @code{text-file*}.
@end deffn
+@deffn {Scheme Procedure} file-union @var{name} @var{files}
+Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
+Each item in @var{files} must be a two-element list where the first element is the
+file name to use in the new directory, and the second element is a gexp
+denoting the target file. Here's an example:
+
+@example
+(file-union "etc"
+ `(("hosts" ,(plain-file "hosts"
+ "127.0.0.1 localhost"))
+ ("bashrc" ,(plain-file "bashrc"
+ "alias ls='ls --color'"))))
+@end example
+
+This yields an @code{etc} directory containing these two files.
+@end deffn
+
@deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
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
diff --git a/gnu/services.scm b/gnu/services.scm
index 0bd362085..bc866eafe 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -97,7 +97,6 @@
%activation-service
etc-service
- file-union ;XXX: for lack of a better place
directory-union))
;;; Comment:
@@ -388,25 +387,6 @@ boot."
(list (service-extension boot-service-type
cleanup-gexp)))))
-(define* (file-union name files) ;FIXME: Factorize.
- "Return a <computed-file> that builds a directory containing all of FILES.
-Each item in FILES must be a list where the first element is the file name to
-use in the new directory, and the second element is a gexp denoting the target
-file."
- (computed-file name
- #~(begin
- (mkdir #$output)
- (chdir #$output)
- #$@(map (match-lambda
- ((target source)
- #~(begin
- ;; Stat the source to abort early if it
- ;; does not exist.
- (stat #$source)
-
- (symlink #$source #$target))))
- files))))
-
(define (directory-union name things)
"Return a directory that is the union of THINGS."
(match things
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 2622c5cb6..9835599bb 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -78,6 +78,7 @@
gexp->script
text-file*
mixed-text-file
+ file-union
imported-files
imported-modules
compiled-modules
@@ -1171,6 +1172,37 @@ This is the declarative counterpart of 'text-file*'."
(computed-file name build))
+(define (file-union name files)
+ "Return a <computed-file> that builds a directory containing all of FILES.
+Each item in FILES must be a two-element list where the first element is the
+file name to use in the new directory, and the second element is a gexp
+denoting the target file. Here's an example:
+
+ (file-union \"etc\"
+ `((\"hosts\" ,(plain-file \"hosts\"
+ \"127.0.0.1 localhost\"))
+ (\"bashrc\" ,(plain-file \"bashrc\"
+ \"alias ls='ls --color'\"))))
+
+This yields an 'etc' directory containing these two files."
+ (computed-file name
+ (gexp
+ (begin
+ (mkdir (ungexp output))
+ (chdir (ungexp output))
+ (ungexp-splicing
+ (map (match-lambda
+ ((target source)
+ (gexp
+ (begin
+ ;; Stat the source to abort early if it does
+ ;; not exist.
+ (stat (ungexp source))
+
+ (symlink (ungexp source)
+ (ungexp target))))))
+ files))))))
+
\f
;;;
;;; Syntactic sugar.
--
2.14.2
next prev parent reply other threads:[~2017-10-20 16:07 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 8:39 bug#27284: Memory leak in 'guix pull' or 'make' in guix source ng0
2017-06-08 15:02 ` ng0
2017-09-19 20:48 ` Ludovic Courtès
2017-09-20 2:40 ` Maxim Cournoyer
2017-09-20 11:42 ` Ludovic Courtès
2017-09-20 18:29 ` Maxim Cournoyer
2017-09-20 20:12 ` Ludovic Courtès
2017-09-21 14:43 ` Maxim Cournoyer
2017-09-23 18:14 ` Taylan Ulrich Bayırlı/Kammer
2017-09-24 19:44 ` Ludovic Courtès
2017-09-25 21:00 ` Maxim Cournoyer
2017-10-20 16:05 ` bug#27284: [PATCH 0/8] 'guix pull' creates several derivations Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 1/8] build: Factorize module compilation in (guix build compile) Ludovic Courtès
2017-10-22 21:22 ` Maxim Cournoyer
2017-10-23 1:50 ` Ludovic Courtès
2017-10-22 21:42 ` Eric Bavier
2017-10-23 2:51 ` Ludovic Courtès
2017-10-22 22:52 ` Eric Bavier
2017-10-23 5:10 ` Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 2/8] build: Honor make's '-j' flag Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 3/8] discovery: Move 'file-name->module-name' to (guix modules) Ludovic Courtès
2017-10-20 16:05 ` Ludovic Courtès [this message]
2017-10-20 16:05 ` bug#27284: [PATCH 5/8] gexp: Add 'directory-union' Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 6/8] union: Parametrize the symlink procedure Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 7/8] gexp: 'directory-union' has a #:quiet? parameter Ludovic Courtès
2017-10-20 16:05 ` bug#27284: [PATCH 8/8] DRAFT Add (guix self) and use it when pulling Ludovic Courtès
2017-10-22 20:05 ` Maxim Cournoyer
2017-10-27 23:49 ` Ludovic Courtès
2017-11-21 22:26 ` bug#27284: [PATCH 0/8] 'guix pull' creates several derivations Ludovic Courtès
2017-11-21 22:56 ` Ludovic Courtès
2017-12-11 10:52 ` bug#27284: [PATCH 0/4] 'guix pull' reloads modules, second try Ludovic Courtès
2017-12-11 10:52 ` bug#27284: [PATCH 1/4] gnu: Fix ambiguous 'zip' reference Ludovic Courtès
2017-12-11 10:52 ` bug#27284: [PATCH 2/4] gexp: 'computed-file' has a new #:guile parameter Ludovic Courtès
2017-12-11 10:52 ` bug#27284: [PATCH 3/4] Add (guix self) and use it when pulling Ludovic Courtès
2017-12-18 14:57 ` Ludovic Courtès
2018-03-27 9:14 ` bug#27284: ‘guix pull’ builds using multiple derivations Ludovic Courtès
2018-03-27 14:33 ` Ludovic Courtès
2018-03-27 19:25 ` Nils Gillmann
2018-03-27 20:51 ` Ludovic Courtès
2018-04-08 16:37 ` Ludovic Courtès
2018-04-09 19:53 ` Ricardo Wurmus
2018-04-10 21:53 ` bug#27284: ‘guix pull’ broken on Guile 2.0 Ludovic Courtès
2018-04-10 23:18 ` bug#31117: " Ludovic Courtès
2018-04-14 17:39 ` Ricardo Wurmus
2017-12-11 10:52 ` bug#27284: [PATCH 4/4] pull: Reload modules before doing anything else Ludovic Courtès
2017-11-12 21:33 ` bug#27284: Memory leak in 'guix pull' or 'make' in guix source Ludovic Courtès
2017-11-13 8:59 ` Ricardo Wurmus
2017-11-13 9:28 ` Ludovic Courtès
2017-11-13 14:09 ` Ricardo Wurmus
2017-11-13 17:48 ` Ricardo Wurmus
2017-11-14 7:54 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171020160557.27096-5-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=27284@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.