From 919370291f4f9cc93878eea7db11013949ee8473 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 7 Sep 2015 22:37:14 +0200 Subject: gexp: Add 'computed-file'. * guix/gexp.scm (): New record type. (computed-file, computed-file-compiler): New procedures. * tests/gexp.scm ("lower-object, computed-file"): New test. * doc/guix.texi (G-Expressions): Document 'computed-file'. --- guix/gexp.scm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index de49fef088..ebb147d7db 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -43,6 +43,13 @@ (define-module (guix gexp) plain-file-name plain-file-content + computed-file + computed-file? + computed-file-name + computed-file-gexp + computed-file-modules + computed-file-options + gexp->derivation gexp->file gexp->script @@ -214,6 +221,32 @@ (define-gexp-compiler (plain-file-compiler (file plain-file?) system target) (($ name content references) (text-file name content references)))) +(define-record-type + (%computed-file name gexp modules options) + computed-file? + (name computed-file-name) ;string + (gexp computed-file-gexp) ;gexp + (modules computed-file-modules) ;list of module names + (options computed-file-options)) ;list of arguments + +(define* (computed-file name gexp + #:key (modules '()) (options '(#:local-build? #t))) + "Return an object representing the store item NAME, a file or directory +computed by GEXP. MODULES specifies the set of modules visible in the +execution context of GEXP. OPTIONS is a list of additional arguments to pass +to 'gexp->derivation'. + +This is the declarative counterpart of 'gexp->derivation'." + (%computed-file name gexp modules options)) + +(define-gexp-compiler (computed-file-compiler (file computed-file?) + system target) + ;; Compile FILE by returning a derivation whose build expression is its + ;; gexp. + (match file + (($ name gexp modules options) + (apply gexp->derivation name gexp #:modules modules options)))) + ;;; ;;; Inputs & outputs. -- cgit v1.2.3