From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:34661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEsy6-0007lu-MR for guix-patches@gnu.org; Thu, 19 Mar 2020 07:04:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEsy4-0001mT-JO for guix-patches@gnu.org; Thu, 19 Mar 2020 07:04:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEsy3-0001iL-9z for guix-patches@gnu.org; Thu, 19 Mar 2020 07:04:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jEsy3-0000QF-5C for guix-patches@gnu.org; Thu, 19 Mar 2020 07:04:03 -0400 Subject: [bug#40130] [PATCH 3/8] ui: Add a notification build handler. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 19 Mar 2020 12:02:47 +0100 Message-Id: <20200319110252.5081-3-ludo@gnu.org> In-Reply-To: <20200319110252.5081-1-ludo@gnu.org> References: <20200319110252.5081-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: 40130@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= * guix/ui.scm (build-notifier): New variable. --- guix/ui.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/guix/ui.scm b/guix/ui.scm index 6f1ca9c0b2..47ada9dde2 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -93,6 +93,7 @@ string->number* size->number show-derivation-outputs + build-notifier show-what-to-build show-what-to-build* show-manifest-transaction @@ -1045,6 +1046,43 @@ check and report what is prerequisites are available for download." (define show-what-to-build* (store-lift show-what-to-build)) +(define* (build-notifier #:key (dry-run? #f) (use-substitutes? #t)) + "Return a procedure suitable for 'with-build-handler' that, when +'build-things' is called, invokes 'show-what-to-build' to display the build +plan. When DRY-RUN? is true, the 'with-build-handler' form returns without +any build happening." + (define not-comma + (char-set-complement (char-set #\,))) + + (define (read-derivation-from-file* item) + (catch 'system-error + (lambda () + (read-derivation-from-file item)) + (const #f))) + + (lambda (continuation store things mode) + (define inputs + ;; List of derivation inputs to build. Filter out non-existent '.drv' + ;; files because the daemon transparently tries to substitute them. + (filter-map (match-lambda + (((? derivation-path? drv) . output) + (let ((drv (read-derivation-from-file* drv)) + (outputs (string-tokenize output not-comma))) + (and drv (derivation-input drv outputs)))) + ((? derivation-path? drv) + (and=> (read-derivation-from-file* drv) + derivation-input)) + (_ + #f)) + things)) + + (show-what-to-build store inputs + #:dry-run? dry-run? + #:use-substitutes? use-substitutes? + #:mode mode) + (unless dry-run? + (continuation #t)))) + (define (right-arrow port) "Return either a string containing the 'RIGHT ARROW' character, or an ASCII replacement if PORT is not Unicode-capable." -- 2.25.1