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