From patchwork Wed Jun 5 21:51:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Elsing X-Patchwork-Id: 65185 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E847627BBEA; Wed, 5 Jun 2024 22:59:59 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8EB8D27BBE2 for ; Wed, 5 Jun 2024 22:59:58 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEyfe-0007vp-Om; Wed, 05 Jun 2024 17:59:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEyfc-0007mT-E7 for guix-patches@gnu.org; Wed, 05 Jun 2024 17:59:48 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEyfb-00044D-Vp for guix-patches@gnu.org; Wed, 05 Jun 2024 17:59:48 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEyfp-0004Tn-Tb for guix-patches@gnu.org; Wed, 05 Jun 2024 18:00:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70895] [PATCH v2] grafts: Only compute necessary graft derivations. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 05 Jun 2024 22:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70895@debbugs.gnu.org Cc: David Elsing , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 70895-submit@debbugs.gnu.org id=B70895.171762476517087 (code B ref 70895); Wed, 05 Jun 2024 22:00:01 +0000 Received: (at 70895) by debbugs.gnu.org; 5 Jun 2024 21:59:25 +0000 Received: from localhost ([127.0.0.1]:41044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEyfF-0004RV-5S for submit@debbugs.gnu.org; Wed, 05 Jun 2024 17:59:25 -0400 Received: from mout01.posteo.de ([185.67.36.65]:38841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEyfC-0004R6-JJ for 70895@debbugs.gnu.org; Wed, 05 Jun 2024 17:59:24 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 296EC240027 for <70895@debbugs.gnu.org>; Wed, 5 Jun 2024 23:51:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1717624319; bh=j9xZCsJrd17MFI48R9RdtW3DTzHDgA8Ueyt6F+SUgbQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=rtvJ3exbh4Y6rQVi2fCxXrOhNYOS4dsP2VInHEmHkNAXb45Upl2zgrtPRbwcX8tk4 qFxRx9lQykJw48J1J8PsKA3pPsTguI4nEILX5r0vMNOMiWUlOTxuiHNAPSLNlOEKCE M9AO6/1PcKxK3poxC0g2xM0uQ1dRf0CMkbQ6SmiqnNhDi1xcm/Tt97xueLILFc0TB3 P+kQ9RXt5DyWkfsH2aArKYWhhSHggsgiMkAVXbG5SpfpZ86lJ+ToMy5z4s+DsDSEx+ wu+sqSmxAjcw4W273DhZ2rtaKCt+oGkuNei49YhIKMgtBGjhddtIe9imooyoYcSb/U vrxgetP5RJ5JA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Vvh4t4qWrz9rxD; Wed, 5 Jun 2024 23:51:58 +0200 (CEST) From: David Elsing Date: Wed, 5 Jun 2024 21:51:42 +0000 Message-ID: <86be6fa895a3a5d9625a49e11181f483fca3c462.1717623537.git.david.elsing@posteo.net> In-Reply-To: <7ycyov5amj.fsf@posteo.net> References: <7ycyov5amj.fsf@posteo.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/packages.scm (input-graft, input-cross-graft): Store the monadic value of the replacement in the 'replacement' field of instead of unwrapping it. (cumulative-grafts): Turn monadic values in the 'replacement' field of applicable grafts into derivations. --- guix/grafts.scm | 18 +++++++++++++++++- guix/packages.scm | 11 ++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/guix/grafts.scm b/guix/grafts.scm index f4df513daf..2f2ddbc83a 100644 --- a/guix/grafts.scm +++ b/guix/grafts.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014-2023 Ludovic Courtès +;;; Copyright © 2024 David Elsing ;;; ;;; This file is part of GNU Guix. ;;; @@ -283,6 +284,20 @@ (define (dependency-grafts items) #:system system))))) (reference-origins drv items))) + ;; If the 'replacement' field of the record is a procedure, + ;; this means that it is a value in the store monad and the actual + ;; derivation needs to be computed here. + (define (finalize-graft item) + (let ((replacement (graft-replacement item))) + (if (procedure? replacement) + (graft + (inherit item) + (replacement + (run-with-store store replacement + #:guile-for-build guile + #:system system))) + item))) + (with-cache (list (derivation-file-name drv) outputs grafts) (match (non-self-references store drv outputs) (() ;no dependencies @@ -299,7 +314,8 @@ (define (dependency-grafts items) ;; Use APPLICABLE, the subset of GRAFTS that is really ;; applicable to DRV, to avoid creating several identical ;; grafted variants of DRV. - (let* ((new (graft-derivation/shallow* store drv applicable + (let* ((new (graft-derivation/shallow* store drv + (map finalize-graft applicable) #:outputs outputs #:guile guile #:system system)) diff --git a/guix/packages.scm b/guix/packages.scm index abe89cdb07..946ccc693a 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2022 Maxime Devos ;;; Copyright © 2022 jgart ;;; Copyright © 2023 Simon Tournier +;;; Copyright © 2024 David Elsing ;;; ;;; This file is part of GNU Guix. ;;; @@ -1778,8 +1779,8 @@ (define (input-graft system) (mcached eq? (=> %package-graft-cache) (mlet %store-monad ((orig (package->derivation package system #:graft? #f)) - (new (package->derivation replacement system - #:graft? #t))) + (new -> (package->derivation replacement system + #:graft? #t))) (return (graft (origin orig) (origin-output output) @@ -1800,9 +1801,9 @@ (define (input-cross-graft target system) (mlet %store-monad ((orig (package->cross-derivation package target system #:graft? #f)) - (new (package->cross-derivation replacement - target system - #:graft? #t))) + (new -> (package->cross-derivation replacement + target system + #:graft? #t))) (return (graft (origin orig) (origin-output output)