summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-01-12 23:26:52 +0100
committerLudovic Courtès <ludo@gnu.org>2015-01-12 23:33:08 +0100
commit462a3fa36cddeb683df765b2982f76712f6c40f0 (patch)
tree5d52bc8a44e1302fabb13ae7466e67d232a5b94c /guix/gexp.scm
parent4a4dd5d89dc498c714d0665909597cecdb202027 (diff)
monads: Rewrite 'text-file*' using gexps.
* guix/monads.scm (text-file*): Move to... * guix/gexp.scm (text-file*): ... here. Rewrite using gexps. * tests/monads.scm ("text-file*"): Move to... * tests/gexp.scm ("text-file*"): ... here.
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm17
1 files changed, 15 insertions, 2 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 78e11f5850..d13e1c46da 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,7 +33,8 @@
gexp?
gexp->derivation
gexp->file
- gexp->script))
+ gexp->script
+ text-file*))
;;; Commentary:
;;;
@@ -522,6 +523,18 @@ its search path."
(write '(ungexp exp) port))))
#:local-build? #t))
+(define* (text-file* name #:rest text)
+ "Return as a monadic value a derivation that builds a text file containing
+all of TEXT. TEXT may list, in addition to strings, packages, derivations,
+and store file names; the resulting store file holds references to all these."
+ (define builder
+ (gexp (call-with-output-file (ungexp output "out")
+ (lambda (port)
+ (display (string-append (ungexp-splicing text)) port)))))
+
+ (gexp->derivation name builder))
+
+
;;;
;;; Syntactic sugar.