diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-10-16 09:57:44 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-10-22 22:09:00 -0700 |
commit | dedb512f8f2282f7de3d5b56e7551e486e37840c (patch) | |
tree | 4f9b9bbd43c9d7ac174bc9508a0f4cd43ba83815 /guix | |
parent | 7a51c78c6e0cd06dd31f3f28cd941fde15eb17d6 (diff) |
gexp: Add 'file-union'.
* gnu/services.scm (file-union): Move to...
* guix/gexp.scm (file-union): ... here. New procedure.
* doc/guix.texi (G-Expressions): Document it.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/gexp.scm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm index 2622c5cb62..9835599bb8 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)))))) + ;;; ;;; Syntactic sugar. |