summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-09-08 22:56:40 +0200
committerLudovic Courtès <ludo@gnu.org>2018-09-08 23:02:01 +0200
commit5dec93bb8ba89605bce2f9a5ee9c4dbadeee3b58 (patch)
tree28b7f873e8d7dd919b2110ab0bc1898aeeaaf300 /guix/gexp.scm
parente80c725db7d11618dec7c3f92845f71b0a9715b0 (diff)
gexp: 'file-union' accepts directory names.
* guix/gexp.scm (file-union): Import (guix build utils). Make the parent directories of TARGET. * tests/gexp.scm ("file-union"): New test.
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm39
1 files changed, 22 insertions, 17 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index ffc976d61b..f7a23db872 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1479,26 +1479,31 @@ denoting the target file. Here's an example:
`((\"hosts\" ,(plain-file \"hosts\"
\"127.0.0.1 localhost\"))
(\"bashrc\" ,(plain-file \"bashrc\"
- \"alias ls='ls --color'\"))))
+ \"alias ls='ls --color'\"))
+ (\"libvirt/qemu.conf\" ,(plain-file \"qemu.conf\" \"\"))))
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))))))
+ (with-imported-modules '((guix build utils))
+ (gexp
+ (begin
+ (use-modules (guix build utils))
+
+ (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))
+
+ (mkdir-p (dirname (ungexp target)))
+ (symlink (ungexp source)
+ (ungexp target))))))
+ files)))))))
(define* (directory-union name things
#:key (copy? #f) (quiet? #f)