summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-07-16 11:40:34 +0200
committerLudovic Courtès <ludo@gnu.org>2018-07-19 11:48:04 +0200
commite529d46828c359b449fc570bdc293fc12534647c (patch)
tree2d6127bccc33d4f90baf8da1f6778dc5fadbd2e3 /guix/gexp.scm
parent8df2eca6b0915942ea087d7c5981514c532d47a2 (diff)
downloadgnu-guix-e529d46828c359b449fc570bdc293fc12534647c.tar
gnu-guix-e529d46828c359b449fc570bdc293fc12534647c.tar.gz
gexp: 'imported-files/derivation' can copy files instead of symlinking.
* guix/gexp.scm (imported-files/derivation): Add #:symlink? and honor it. (imported-files): Pass #:symlink? to 'imported-files/derivation'. * tests/gexp.scm ("imported-files with file-like objects"): Add 'file=?' and use it instead of calling 'readlink'.
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 19d90f5eee..ffc976d61b 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1078,6 +1078,7 @@ to a tree suitable for 'interned-file-tree'."
(define* (imported-files/derivation files
#:key (name "file-import")
+ (symlink? #f)
(system (%current-system))
(guile (%guile-for-build))
@@ -1091,7 +1092,8 @@ to a tree suitable for 'interned-file-tree'."
"Return a derivation that imports FILES into STORE. FILES must be a list
of (FINAL-PATH . FILE) pairs. Each FILE is mapped to FINAL-PATH in the
resulting store path. FILE can be either a file name, or a file-like object,
-as returned by 'local-file' for example."
+as returned by 'local-file' for example. If SYMLINK? is true, create symlinks
+to the source files instead of copying them."
(define file-pair
(match-lambda
((final-path . (? string? file-name))
@@ -1114,7 +1116,8 @@ as returned by 'local-file' for example."
(for-each (match-lambda
((final-path store-path)
(mkdir-p (dirname final-path))
- (symlink store-path final-path)))
+ ((ungexp (if symlink? 'symlink 'copy-file))
+ store-path final-path)))
'(ungexp files)))))
;; TODO: Pass FILES as an environment variable so that BUILD remains
@@ -1160,6 +1163,7 @@ as returned by 'local-file' for example."
(_ #f))
files))
(imported-files/derivation files #:name name
+ #:symlink? derivation?
#:system system #:guile guile
#:deprecation-warnings deprecation-warnings)
(interned-file-tree `(,name directory