From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id mDy9GEIBwmLGCAAAbAwnHQ (envelope-from ) for ; Sun, 03 Jul 2022 22:51:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id GD7iF0IBwmKgfwEAG6o9tA (envelope-from ) for ; Sun, 03 Jul 2022 22:51:14 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 196BA24254 for ; Sun, 3 Jul 2022 22:51:12 +0200 (CEST) Received: from localhost ([::1]:57696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o86Yh-0002mv-CF for larch@yhetil.org; Sun, 03 Jul 2022 16:51:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o86YY-0002mm-RQ for bug-guix@gnu.org; Sun, 03 Jul 2022 16:51:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o86YY-0001ak-ID for bug-guix@gnu.org; Sun, 03 Jul 2022 16:51:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o86YY-0004oQ-BP for bug-guix@gnu.org; Sun, 03 Jul 2022 16:51:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56114: Guix does not have a documented general and practical procedure for lowering a single lowerable object to the /gnu/store/... string. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sun, 03 Jul 2022 20:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56114 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Maxime Devos Cc: 56114@debbugs.gnu.org Received: via spool by 56114-submit@debbugs.gnu.org id=B56114.165688145118479 (code B ref 56114); Sun, 03 Jul 2022 20:51:02 +0000 Received: (at 56114) by debbugs.gnu.org; 3 Jul 2022 20:50:51 +0000 Received: from localhost ([127.0.0.1]:45533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o86YM-0004nz-G9 for submit@debbugs.gnu.org; Sun, 03 Jul 2022 16:50:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o86YL-0004nn-BN for 56114@debbugs.gnu.org; Sun, 03 Jul 2022 16:50:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42062) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o86YF-0001aO-2D; Sun, 03 Jul 2022 16:50:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=1MUWv7KeStl3UsY01XQNGUgHjeEP4V5VtS4iH1ZW1tA=; b=EMO+RgZ8gIgn+Yv28+L7 SGN3gC0qsaNc+IojgyNN2QdzsLb+BmSC4uAcKvHyB21T0fJub0jZ+X425TJuYNl2d+QRXMoMBhfz6 jfxgnqF7CcaNPmYYqJ7KdnFHOqlKVMcvncVO6MVjevAwQb12F9jI13L6lD9Xu0CdwoxuJAzBrd0id Q6NI3Br4I9VgxlGNi7eC4a7tz0h/qXZSHgB8XjHwh5sw+bxyXv1OaRGlC5DO9MfIKL2fwKghBGcT3 IuZzPg21Oj9lD8EyxTUk37VB2Z+T2s36s1KWdAgTWkdJiCuShOPyp2FeIxfYiRvxvxexYpS71e1ba GDW5AVGuNlcaVw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:49818 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o86YE-0003Nj-FE; Sun, 03 Jul 2022 16:50:42 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <1652a111d71c3e74c61904f89120ea45631c7013.camel@telenet.be> Date: Sun, 03 Jul 2022 22:50:40 +0200 In-Reply-To: <1652a111d71c3e74c61904f89120ea45631c7013.camel@telenet.be> (Maxime Devos's message of "Mon, 20 Jun 2022 23:01:54 +0200") Message-ID: <87edz1zzrz.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656881473; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=1MUWv7KeStl3UsY01XQNGUgHjeEP4V5VtS4iH1ZW1tA=; b=CjSkvReeK5g7XVb+ha8Y9Wgqe8/F/YzNADzp0NV7ygpnUCEk830QrBDTTNnEbBvhDsnk8G AdufKjY0SPXGUWcWiwt/JCiVYSW1YvlElkm15HDPFaWRRWrqqDfQoUyxnq/tUMJ93tTVnQ h4pBak43taliFv26UwYSOe7SuPU0ulitT2Fju4mHvIoOp0CvR4tniMqJGYakisJy40C2nQ A9xD2JxiE/cLzNCEdICD7hNRqGHIOHNSLSk89H6Em1GZmQ85u79eTiUnL0jm4t0aA0O8oU XAF3YuhKoWKjishxI6tKSmw16TRz2IJSbeZ9ZF+JaBRaJmK9Rb6B1mBLDnReDw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656881473; a=rsa-sha256; cv=none; b=L4Klqly8G+Pc3PCwlo+ZlRkOjfvRrXxnb9fJpmR8Lo94MP7W3BrPmj5wt0JnEJowj9Cfun A/nc/wKqrOu2QheAxe8Oq6v60B6PJNgrG1TIJ/CEl+2s9dy6Vyj2J0YwnvJgCwLEXXyZK1 gL29QwL8QJUuXoqY33UekOYGPYFij79/+K8RyniuZx+BGkqYHUblnsDoGGf2C1goe0Agxx AHhHmJKNQ4AtamGf07P8VOyHF6lWxXnLGn8CykQd/kEAFWHr4kvEDnteolBSswufSZav9v GoZtdXKFIBur1eU1C/tBNrD9VoU/MVWyL+zCL9WqsXaUvroddWhhhVcRokSrkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=EMO+RgZ8; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.74 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=EMO+RgZ8; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 196BA24254 X-Spam-Score: -3.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: jMphdiX+oroC --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Maxime, Maxime Devos skribis: > Seems like we are missing a general & documented & simple to use > 'lower-object-completely' (or maybe 'compile-object'?) procedure for > this ... And maybe also a ,build-object REPL command? How about the attached patch? Sample session: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(gnu packages base) scheme@(guile-user)> ,build coreutils $11 =3D "/gnu/store/y8933036ljrz4ah9zcph09nmvdmmv5sf-coreutils-8.32-debug" $12 =3D "/gnu/store/8fpk2cja3f07xls48jfnpgrzrljpqivr-coreutils-8.32" scheme@(guile-user)> ,lower coreutils $13 =3D # /gnu/store/y8933036ljrz4ah9zcph09nmvdmmv5sf-coreutils-8.32-de= bug /gnu/store/8fpk2cja3f07xls48jfnpgrzrljpqivr-coreutils-8.32 7f0ebaf821e0> scheme@(guile-user)> ,build (computed-file "foo" #~(begin (display "hi!\n")= (mkdir #$output)(mkdir #$output:lib))) $14 =3D "/gnu/store/axij9bkg56xv3k1z0l20gd6b0swn14sy-foo-lib" $15 =3D "/gnu/store/h5s7k7m0fxk9n7q7729l3n4q7vyxnvpy-foo" scheme@(guile-user)> ,build (computed-file "foo" #~(begin (display "Goeden = dag!\n")(mkdir #$output))) substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0% substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 10= 0.0% substitute: updating substitutes from 'https://guix.bordeaux.inria.fr'... 1= 00.0% building /gnu/store/gplhka9g0bwv8b640zavw1z65y9zrvag-foo.drv... $16 =3D "/gnu/store/ynvga6gxwj68mmk8ddj3i9sjhavkqah1-foo" --8<---------------cut here---------------end--------------->8--- =E2=80=9Clower=E2=80=9D does what you would expect; =E2=80=9Cbuild=E2=80=9D= yields one value per output. If that works for you, I=E2=80=99ll update the manual accordingly, and we c= an always add more features (like build options) later on. Thoughts? Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/guix/monad-repl.scm b/guix/monad-repl.scm index aefabdeebb..15c10efe01 100644 --- a/guix/monad-repl.scm +++ b/guix/monad-repl.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2014, 2015, 2016 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2014, 2015, 2016, 2022 Ludovic Court=C3=A8s ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +21,12 @@ (define-module (guix monad-repl) #:use-module (guix monads) #:use-module (guix utils) #:use-module (guix packages) + #:use-module (guix status) + #:autoload (guix gexp) (lower-object) + #:use-module ((guix derivations) + #:select (derivation? + derivation->output-paths built-derivations)) + #:use-module (ice-9 match) #:use-module (ice-9 pretty-print) #:use-module (system repl repl) #:use-module (system repl common) @@ -69,16 +75,56 @@ (define (store-monad-language store) #:guile-for-build guile) 'store-monad))) =20 +(define %build-verbosity 1) + +(define* (evaluate/print-with-store mvalue #:key build?) + "Run monadic value MVALUE in the store monad and print its value." + (with-store store + (set-build-options store + #:print-build-trace #t + #:print-extended-build-trace? #t + #:multiplexed-build-output? #t) + (with-status-verbosity %build-verbosity + (let* ((guile (or (%guile-for-build) + (default-guile-derivation store))) + (values (run-with-store store + (if build? + (mlet %store-monad ((obj mvalue)) + (if (derivation? obj) + (mbegin %store-monad + (built-derivations (list obj)) + (return + (match (derivation->output-paths obj) + (((_ . files) ...) files)))) + (return (list obj)))) + (mlet %store-monad ((obj mvalue)) + (return (list obj)))) + #:guile-for-build guile))) + (for-each (lambda (value) + (run-hook before-print-hook value) + (pretty-print value)) + values))))) + (define-meta-command ((run-in-store guix) repl (form)) "run-in-store EXP Run EXP through the store monad." - (with-store store - (let* ((guile (or (%guile-for-build) - (default-guile-derivation store))) - (value (run-with-store store (repl-eval repl form) - #:guile-for-build guile))) - (run-hook before-print-hook value) - (pretty-print value)))) + (evaluate/print-with-store (repl-eval repl form))) + +(define-meta-command ((verbosity guix) repl (level)) + "verbosity LEVEL +Change build verbosity to LEVEL." + (set! %build-verbosity level)) + +(define-meta-command ((lower guix) repl (form)) + "lower OBJECT +Lower OBJECT into a derivation and return it." + (evaluate/print-with-store (lower-object (repl-eval repl form)))) + +(define-meta-command ((build guix) repl (form)) + "build OBJECT +Lower OBJECT and build it, returning its output file name(s)." + (evaluate/print-with-store (lower-object (repl-eval repl form)) + #:build? #t)) =20 (define-meta-command ((enter-store-monad guix) repl) "enter-store-monad --=-=-=--