From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:55540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gihzY-0004wf-QC for guix-patches@gnu.org; Sun, 13 Jan 2019 10:48:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gihzY-0004nc-01 for guix-patches@gnu.org; Sun, 13 Jan 2019 10:48:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:58738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gihzX-0004nE-Ou for guix-patches@gnu.org; Sun, 13 Jan 2019 10:48:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gihzX-0008Nt-Do for guix-patches@gnu.org; Sun, 13 Jan 2019 10:48:03 -0500 Subject: [bug#34060] [PATCH 04/10] inferior: Add 'gexp->derivation-in-inferior'. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 13 Jan 2019 16:47:27 +0100 Message-Id: <20190113154733.29737-4-ludo@gnu.org> In-Reply-To: <20190113154733.29737-1-ludo@gnu.org> References: <20190113154733.29737-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 34060@debbugs.gnu.org * guix/inferior.scm (gexp->derivation-in-inferior): New procedure. --- guix/inferior.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/guix/inferior.scm b/guix/inferior.scm index ba8d00866b..42b3545599 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -81,6 +81,8 @@ inferior-package->manifest-entry + gexp->derivation-in-inferior + %inferior-cache-directory inferior-for-channels)) @@ -484,6 +486,30 @@ PACKAGE must be live." ;; Compile PACKAGE for SYSTEM, optionally cross-building for TARGET. (inferior-package->derivation package system #:target target)) +(define* (gexp->derivation-in-inferior name exp guix + #:rest rest) + "Return a derivation that evaluates EXP with GUIX, an instance of Guix as +returned for example by 'channel-instances->derivation'. Other arguments are +passed as-is to 'gexp->derivation'." + (define trampoline + ;; This is a crude way to run EXP on GUIX. TODO: use 'raw-derivation' and + ;; make 'guix repl' the "builder"; this will require "opening up" the + ;; mechanisms behind 'gexp->derivation', and adding '-l' to 'guix repl'. + #~(begin + (use-modules (ice-9 popen)) + + (let ((pipe (open-pipe* OPEN_WRITE + #+(file-append guix "/bin/guix") + "repl"))) + ;; Unquote EXP right here so that its references to #$output + ;; propagate to the surrounding gexp. + (write '#$exp pipe) ;XXX: load path for EXP? + + (unless (zero? (close-pipe pipe)) + (error "inferior failed" #+guix))))) + + (apply gexp->derivation name trampoline rest)) + ;;; ;;; Manifest entries. -- 2.20.1