[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Exposing set-load-path and load-path-expression from Gexp.
From: |
Roel Janssen |
Subject: |
Exposing set-load-path and load-path-expression from Gexp. |
Date: |
Thu, 02 Mar 2017 14:31:43 +0100 |
User-agent: |
mu4e 0.9.18; emacs 25.1.1 |
Dear Guix,
To write a derivation builder that can turn a G-expression into a
derivation, it would be handy to expose two functions that are currently
not in the interface of (guix gexp).
Here's an example:
(define* (process->bash-engine-derivation proc #:key (guile (default-guile)))
"Return an executable script that runs the PROCEDURE described in PROC, with
PROCEDURE's imported modules in its search path."
(let ((name (process-full-name proc))
(exp (process-procedure proc))
(out (process-output-path proc)))
(let ((out-str (if out (format #f "(setenv \"out\" ~s)" out) "")))
(mlet %store-monad ((set-load-path
(load-path-expression (gexp-modules exp))))
(gexp->derivation
name
(gexp
(call-with-output-file (ungexp output)
(lambda (port)
(use-modules (ice-9 pretty-print))
(format port "#!~a/bin/bash~%" (ungexp bash))
;; Now that we've written all of the shell code,
;; We can start writing the Scheme code.
;; We rely on Bash for this to work.
(format port "read -d '' CODE <<EOF~%")
;; The destination can be outside of the store.
;; TODO: We have to mount this location when building inside
;; a container.
(format port "~a" (ungexp out-str))
(format port
"~%;; Code to create a proper Guile environment.~%~a~%"
(with-output-to-string
(lambda _ (pretty-print '(ungexp set-load-path)))))
(format port ";; Actual code from the procedure.~%~a~%"
(with-output-to-string
(lambda _ (pretty-print '(ungexp exp)))))
(format port "EOF~%")
(format port "~a/bin/guile -c \"$CODE\"~%" (ungexp guile))
(chmod port #o555)))))))))
Without having set-load-path and load-path-expression, I think it would
be hard (and quite possibly an exact duplicate of the code inside (guix
gexp)) to set up a proper environment for the Guile code to run.
I would like to request exposing these two functions to the public
interface of (guix gexp).
WDYT?
Kind regards,
Roel Janssen
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Exposing set-load-path and load-path-expression from Gexp.,
Roel Janssen <=