aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-07-24 22:27:35 +0200
committerLudovic Courtès <ludo@gnu.org>2014-07-24 23:02:26 +0200
commit0a90af153199b03deced53da7ef7f50f0e561f80 (patch)
tree38c39490e95c2f2efc61ef9ab74de1bffd35e851 /guix
parent7ab44369b34a23e5d22ac51b7fbfe31c0de9fbfd (diff)
downloadgnu-guix-0a90af153199b03deced53da7ef7f50f0e561f80.tar
gnu-guix-0a90af153199b03deced53da7ef7f50f0e561f80.tar.gz
monads: Add 'interned-file'.
* guix/monads.scm (interned-file): New procedure. * tests/monads.scm ("interned-file"): New test. * doc/guix.texi (The Store Monad): Document it.
Diffstat (limited to 'guix')
-rw-r--r--guix/monads.scm13
1 files changed, 13 insertions, 0 deletions
diff --git a/guix/monads.scm b/guix/monads.scm
index c2c6f1a03d..4af2b704ab 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -55,6 +55,7 @@
run-with-store
text-file
text-file*
+ interned-file
package-file
origin->derivation
package->derivation
@@ -362,6 +363,18 @@ and store file names; the resulting store file holds references to all these."
(derivation-expression name (builder inputs)
#:inputs inputs)))
+(define* (interned-file file #:optional name
+ #:key (recursive? #t))
+ "Return the name of FILE once interned in the store. Use NAME as its store
+name, or the basename of FILE if NAME is omitted.
+
+When RECURSIVE? is true, the contents of FILE are added recursively; if FILE
+designates a flat file and RECURSIVE? is true, its contents are added, and its
+permission bits are kept."
+ (lambda (store)
+ (add-to-store store (or name (basename file))
+ recursive? "sha256" file)))
+
(define* (package-file package
#:optional file
#:key (system (%current-system)) (output "out"))