GNU bug report logs - #29926
[PATCH 1/5] gexp: Add 'eval-gexp'.

Previous Next

Package: guix-patches;

Reported by: 宋文武 <iyzsong <at> member.fsf.org>

Date: Mon, 1 Jan 2018 10:34:05 UTC

Severity: normal

Tags: patch

Merged with 29925, 29927, 29928, 29929, 29930

Done: 宋文武 <iyzsong <at> outlook.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29926 in the body.
You can then email your comments to 29926 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#29926; Package guix-patches. (Mon, 01 Jan 2018 10:34:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to 宋文武 <iyzsong <at> member.fsf.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 01 Jan 2018 10:34:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> member.fsf.org>
To: guix-patches <at> gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH 1/5] gexp: Add 'eval-gexp'.
Date: Mon,  1 Jan 2018 18:33:32 +0800
* guix/gexp.scm (eval-gexp): New procedure.
---
 guix/gexp.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index f005c4d29..9709c5ecb 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -76,6 +76,7 @@
             gexp->derivation
             gexp->file
             gexp->script
+            eval-gexp
             text-file*
             mixed-text-file
             file-union
@@ -1167,6 +1168,21 @@ and '%load-compiled-path' to honor EXP's imported modules."
                          #:local-build? #t
                          #:substitutable? #f)))))
 
+(define* (eval-gexp exp #:optional (name "computed-value"))
+  "Return as a monadic value the EXP (a gexp) evaluate to.  This is
+implemented by building a store file NAME that contains the textual
+representation of EXP's value, and then @code{read} from it."
+  (mlet* %store-monad
+      ((drv (gexp->derivation
+             name
+             (gexp (with-output-to-file (ungexp output)
+                     (lambda ()
+                       (write (eval (quote (ungexp exp)) (current-module))))))
+             #:local-build? #t
+             #:substitutable? #f))
+       (_   (built-derivations (list drv))))
+    (return (call-with-input-file (derivation->output-path drv) read))))
+
 (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, objects of any type that
-- 
2.13.3





Merged 29926. Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Wed, 07 Mar 2018 14:05:02 GMT) Full text and rfc822 format available.

Merged 29925 29926. Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Wed, 07 Mar 2018 14:05:03 GMT) Full text and rfc822 format available.

Merged 29925 29926 29929. Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Wed, 07 Mar 2018 14:05:04 GMT) Full text and rfc822 format available.

Merged 29925 29926 29929 29930. Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Wed, 07 Mar 2018 14:06:02 GMT) Full text and rfc822 format available.

Merged 29925 29926 29927 29928 29929 29930. Request was from Leo Prikler <leo.prikler <at> student.tugraz.at> to control <at> debbugs.gnu.org. (Tue, 11 May 2021 13:36:02 GMT) Full text and rfc822 format available.

Merged 29925 29926 29927 29928 29929 29930. Request was from Leo Prikler <leo.prikler <at> student.tugraz.at> to control <at> debbugs.gnu.org. (Tue, 11 May 2021 13:36:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Jun 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.