From 462a3fa36cddeb683df765b2982f76712f6c40f0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Jan 2015 23:26:52 +0100 Subject: 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. --- guix/gexp.scm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'guix/gexp.scm') 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 +;;; Copyright © 2014, 2015 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,7 +33,8 @@ (define-module (guix gexp) gexp? gexp->derivation gexp->file - gexp->script)) + gexp->script + text-file*)) ;;; Commentary: ;;; @@ -522,6 +523,18 @@ (define (gexp->file name exp) (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. -- cgit v1.2.3