From unknown Sun Jun 15 09:02:55 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74475] [PATCH core-team] packages: 'package-input-rewriting/spec' optionally replace hidden. Resent-From: Greg Hogan Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 22 Nov 2024 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74475 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74475@debbugs.gnu.org Cc: Greg Hogan , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.173228579019308 (code B ref -1); Fri, 22 Nov 2024 14:30:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Nov 2024 14:29:50 +0000 Received: from localhost ([127.0.0.1]:53771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEUfO-00051M-AV for submit@debbugs.gnu.org; Fri, 22 Nov 2024 09:29:50 -0500 Received: from lists.gnu.org ([209.51.188.17]:34882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEUfN-00051F-3T for submit@debbugs.gnu.org; Fri, 22 Nov 2024 09:29:49 -0500 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 1tEUfM-0003pJ-Sr for guix-patches@gnu.org; Fri, 22 Nov 2024 09:29:48 -0500 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEUfK-0006GJ-Ka for guix-patches@gnu.org; Fri, 22 Nov 2024 09:29:48 -0500 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7b14df8f821so156123185a.2 for ; Fri, 22 Nov 2024 06:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greghogan-com.20230601.gappssmtp.com; s=20230601; t=1732285785; x=1732890585; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1V5+H53BIfpIVQMYDL+X9jt66teXyyJ9gA1oiNR9W00=; b=vFh++7GiIk2cPoLb9Oul+bbgBUBnMNr4Przzqh3NlrEGpLvMSFc1FkSGdRIt7elbBR hOd8GlOPdGsUt/5AKA8kk9Zp0LKxKzkP6GWs/zLrluzUEAqfOpfNxteyk8QrA/YC3ZIi mlD1OnwP7isrCbtj5jjL0C5U0QRvo+nigI/8hopWKST2sJlu5AOcclsQTR0LhPZdnImf QXm/Bf4gClgvrPSA5HRuWKRQhs5rrK8UkV87V1T1hJrY23i84cNf3AVS1iwjMilZBXsC m9U4ECiQAkogGb+y60rLEe6IhXY4+5Up03WGTcj9l6sFIk0e6abNpDLVMjkzu/gTWWJA 9RHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732285785; x=1732890585; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1V5+H53BIfpIVQMYDL+X9jt66teXyyJ9gA1oiNR9W00=; b=X/UG+O4Z4MnhSB7sv5NM3mb74AcpywX+sGnyaEeGu6Xk7luul146ketfCZu7Ss8C6u 28v4KPOkyKTiJ0zCuyOgmj8L6fijiQqyMbIGY5EKsACCEGB+AU6on4IXegHBvEgjqhuc JvVCKQBB9jwJmkNhT94oHGrhI/vKacdp3CMVnwjDNioD8RBzwiMRtl5ev3e+uEAu6rZ9 afpc2SyyyC/oV/TOMSMHV3mP7RrVOdPJd45Hlwz5/RxNqWTgVZOQAZwDaXemrOKteBfm GRKmSKjm7DqH/YLbV3ImXyRJAdN455y/VjfPJo/yc6XQUDr1zUl3N9+R9lT/oG5u+rNi gkAw== X-Gm-Message-State: AOJu0YzGpyifGKxCo/3lJzXwUyeWQH9J6shbzgsx52u+SisypmrdGxer gmO+045OBRPCSIuK2s0Bcg20r8nLAgdYgXn5O1q25HaTAZBRMB9sVOmooa21zZFJYVWuFMltQIu kIs4= X-Gm-Gg: ASbGnctxDY1caaGZw+MRyBuT2FDQoOWeMHUkQNj9li6d9u6V8P0qm29+ugiRr9KvFUp yTFNmvO2+G4USysbntPz6uw0FEfgmKk3jenV2+c8E100hXQ/HXRhvTpF1ask8HFX8YBen90PPUn KL3f1OFlVAHSSuDGLnJkeZepc6k319LaVZYXQNADzCuqR+FNyGFAD/cKCshY1uh7J17+0Ur/846 WqH8UGiUSKaLm1Kw5YHaAbYzJ2PLHNphLJoLLVyqRADjlWw+x9u3XsNeO7HtH+2eCej4gdkswsp egaElAro65sYXiLugyoYi0exuEDZ7LnMP2iPJTolUyeqjCijAQ== X-Google-Smtp-Source: AGHT+IFiiCld9lsovlNLZiyZG15O1UKwLEyIwPDJ6UpC/n/pGYRSzHptckgGrB9jfZF2kgKFBnwzhw== X-Received: by 2002:a05:620a:1917:b0:7a9:b914:279c with SMTP id af79cd13be357-7b5143dff90mr487051385a.0.1732285784859; Fri, 22 Nov 2024 06:29:44 -0800 (PST) Received: from ip-10-114-89-186.evoforge.org (ec2-52-70-167-183.compute-1.amazonaws.com. [52.70.167.183]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b513f9063csm91144885a.8.2024.11.22.06.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 06:29:44 -0800 (PST) From: Greg Hogan Date: Fri, 22 Nov 2024 14:29:39 +0000 Message-ID: <7daac6d4cf5c0934236b37b39a112971a0ee0610.1732284490.git.code@greghogan.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:20::72b; envelope-from=code@greghogan.com; helo=mail-qk1-x72b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Commit eee95b5a879b7096dffd533f24107cf8926b621e changed package rewriting to ignore hidden packages. This patch permits the previous use by adding an option to rewrite hidden packages. * guix/packages.scm (package-input-rewriting/spec)[rewrite]: When P is hidden, return it as-is unless #:replace-hidden? has been enabled. * tests/packages.scm ("package-input-rewriting/spec, replace hidden package"): New test. * doc/guix.texi (Defining Package Variants): Update. Change-Id: I0a7988cac70e0c6b88b0fe6e27c1036fa723e030 --- doc/guix.texi | 5 +++-- guix/packages.scm | 9 ++++++--- tests/packages.scm | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1c39628ffa..e22bb693d7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8619,7 +8619,8 @@ Defining Package Variants The following variant of @code{package-input-rewriting} can match packages to be replaced by name rather than by identity. -@deffn {Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t] +@deffn {Procedure} package-input-rewriting/spec @var{replacements} @ + [#:deep? #t] [#:replace-hidden? #t] Return a procedure that, given a package, applies the given @var{replacements} to all the package graph, including implicit inputs unless @var{deep?} is false. @@ -8628,7 +8629,7 @@ Defining Package Variants package specification such as @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching package and returns a replacement for that package. Matching packages that have the @code{hidden?} property -set are not replaced. +set are not replaced unless @var{replace-hidden?} is set to true. @end deffn The example above could be rewritten this way: diff --git a/guix/packages.scm b/guix/packages.scm index f373136d22..dbb8597488 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1611,14 +1611,16 @@ (define* (package-input-rewriting replacements (package-mapping rewrite cut? #:deep? deep?)) -(define* (package-input-rewriting/spec replacements #:key (deep? #t)) +(define* (package-input-rewriting/spec replacements + #:key (deep? #t) (replace-hidden? #f)) "Return a procedure that, given a package, applies the given REPLACEMENTS to all the package graph, including implicit inputs unless DEEP? is false. REPLACEMENTS is a list of spec/procedures pair; each spec is a package specification such as \"gcc\" or \"guile@2\", and each procedure takes a matching package and returns a replacement for that package. Matching -packages that have the 'hidden?' property set are not replaced." +packages that have the 'hidden?' property set are not replaced unless +REPLACE-HIDDEN? is set to true." (define table (fold (lambda (replacement table) (match replacement @@ -1647,7 +1649,8 @@ (define* (package-input-rewriting/spec replacements #:key (deep? #t)) (define (rewrite p) (if (or (assq-ref (package-properties p) replacement-property) - (hidden-package? p)) + (and (not replace-hidden?) + (hidden-package? p))) p (match (find-replacement p) (#f p) diff --git a/tests/packages.scm b/tests/packages.scm index a623628447..7c28e75c45 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1628,6 +1628,21 @@ (define compressors '(("gzip" . "gz") (match (delete-duplicates pythons eq?) ((p) (eq? p python))))) +(test-assert "package-input-rewriting/spec, replace hidden package" + ;; Rewrite hidden packages when requested. + (let* ((python (hidden-package python)) + (p0 (dummy-package "chbouib" + (build-system trivial-build-system) + (inputs (list python)))) + (rewrite (package-input-rewriting/spec + `(("python" . ,(const sed))) + #:replace-hidden? #t)) + (p1 (rewrite p0))) + (match (package-inputs p1) + ((("python" python)) + (and (string=? (package-full-name python) + (package-full-name sed))))))) + (test-equal "package-input-rewriting/spec, graft" (derivation-file-name (package-derivation %store sed)) base-commit: ba3a03151e6971bdfa9a86af5179055601042ff8 -- 2.46.0 From unknown Sun Jun 15 09:02:55 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Greg Hogan Subject: bug#74475: closed (Re: bug#74475: [PATCH core-team] packages: 'package-input-rewriting/spec' optionally replace hidden.) Message-ID: References: <87zflewdox.fsf@gnu.org> <7daac6d4cf5c0934236b37b39a112971a0ee0610.1732284490.git.code@greghogan.com> X-Gnu-PR-Message: they-closed 74475 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 74475@debbugs.gnu.org Date: Mon, 02 Dec 2024 11:03:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1733137382-3127-1" This is a multi-part message in MIME format... ------------=_1733137382-3127-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #74475: [PATCH core-team] packages: 'package-input-rewriting/spec' optional= ly replace hidden. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 74475@debbugs.gnu.org. --=20 74475: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D74475 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1733137382-3127-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 74475-done) by debbugs.gnu.org; 2 Dec 2024 11:02:51 +0000 Received: from localhost ([127.0.0.1]:54411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tI4CY-0000ny-UP for submit@debbugs.gnu.org; Mon, 02 Dec 2024 06:02:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tI4CW-0000nc-99 for 74475-done@debbugs.gnu.org; Mon, 02 Dec 2024 06:02:48 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tI4CO-0003yY-3e; Mon, 02 Dec 2024 06:02:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=QYbOj+6kZIjP9KXqWw4yOdtJyRkSDK82RtAjFQnQSyI=; b=HW/+ixZ4/H8QYHIioaf9 QFMHeEXwhSrZU6P/fN0Le1FYzaAQps3tbU9JE8bj4HQVApOdfhzixpZDGNJzYjneS6cvhMjz2eZks jId4iTGK57q1rXkN5FKuXNwBNlp8nAbBLWCGfGMh7cFWVM1LxjlDNsxH1pZhSJQO/eP7CCnP7SEhO pFDTJNdg411F8rBXBXoE+eTKaM52MP27xSQB2Hm8ZzfXivL4ReL/bCpmThnNoMWnqHD5dLjWUPKg8 ep1Uh2+4n7ftO8B9BlOLpw7+kWBgEi3D4z8A+7G3e9teaw0sIOdfa59YmLamMdrhvcK0YYZb8a30r DTsLGoe/2QHtQg==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Greg Hogan Subject: Re: bug#74475: [PATCH core-team] packages: 'package-input-rewriting/spec' optionally replace hidden. In-Reply-To: <7daac6d4cf5c0934236b37b39a112971a0ee0610.1732284490.git.code@greghogan.com> (Greg Hogan's message of "Fri, 22 Nov 2024 14:29:39 +0000") References: <7daac6d4cf5c0934236b37b39a112971a0ee0610.1732284490.git.code@greghogan.com> Date: Mon, 02 Dec 2024 12:02:06 +0100 Message-ID: <87zflewdox.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74475-done Cc: Josselin Poiret , Maxim Cournoyer , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 74475-done@debbugs.gnu.org, Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Greg Hogan skribis: > Commit eee95b5a879b7096dffd533f24107cf8926b621e changed package > rewriting to ignore hidden packages. This patch permits the previous use > by adding an option to rewrite hidden packages. > > * guix/packages.scm (package-input-rewriting/spec)[rewrite]: When P is > hidden, return it as-is unless #:replace-hidden? has been enabled. > * tests/packages.scm ("package-input-rewriting/spec, replace hidden > package"): New test. > * doc/guix.texi (Defining Package Variants): Update. > > Change-Id: I0a7988cac70e0c6b88b0fe6e27c1036fa723e030 Applied, thanks! ------------=_1733137382-3127-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 22 Nov 2024 14:29:50 +0000 Received: from localhost ([127.0.0.1]:53771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEUfO-00051M-AV for submit@debbugs.gnu.org; Fri, 22 Nov 2024 09:29:50 -0500 Received: from lists.gnu.org ([209.51.188.17]:34882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEUfN-00051F-3T for submit@debbugs.gnu.org; Fri, 22 Nov 2024 09:29:49 -0500 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 1tEUfM-0003pJ-Sr for guix-patches@gnu.org; Fri, 22 Nov 2024 09:29:48 -0500 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEUfK-0006GJ-Ka for guix-patches@gnu.org; Fri, 22 Nov 2024 09:29:48 -0500 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7b14df8f821so156123185a.2 for ; Fri, 22 Nov 2024 06:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greghogan-com.20230601.gappssmtp.com; s=20230601; t=1732285785; x=1732890585; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1V5+H53BIfpIVQMYDL+X9jt66teXyyJ9gA1oiNR9W00=; b=vFh++7GiIk2cPoLb9Oul+bbgBUBnMNr4Przzqh3NlrEGpLvMSFc1FkSGdRIt7elbBR hOd8GlOPdGsUt/5AKA8kk9Zp0LKxKzkP6GWs/zLrluzUEAqfOpfNxteyk8QrA/YC3ZIi mlD1OnwP7isrCbtj5jjL0C5U0QRvo+nigI/8hopWKST2sJlu5AOcclsQTR0LhPZdnImf QXm/Bf4gClgvrPSA5HRuWKRQhs5rrK8UkV87V1T1hJrY23i84cNf3AVS1iwjMilZBXsC m9U4ECiQAkogGb+y60rLEe6IhXY4+5Up03WGTcj9l6sFIk0e6abNpDLVMjkzu/gTWWJA 9RHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732285785; x=1732890585; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1V5+H53BIfpIVQMYDL+X9jt66teXyyJ9gA1oiNR9W00=; b=X/UG+O4Z4MnhSB7sv5NM3mb74AcpywX+sGnyaEeGu6Xk7luul146ketfCZu7Ss8C6u 28v4KPOkyKTiJ0zCuyOgmj8L6fijiQqyMbIGY5EKsACCEGB+AU6on4IXegHBvEgjqhuc JvVCKQBB9jwJmkNhT94oHGrhI/vKacdp3CMVnwjDNioD8RBzwiMRtl5ev3e+uEAu6rZ9 afpc2SyyyC/oV/TOMSMHV3mP7RrVOdPJd45Hlwz5/RxNqWTgVZOQAZwDaXemrOKteBfm GRKmSKjm7DqH/YLbV3ImXyRJAdN455y/VjfPJo/yc6XQUDr1zUl3N9+R9lT/oG5u+rNi gkAw== X-Gm-Message-State: AOJu0YzGpyifGKxCo/3lJzXwUyeWQH9J6shbzgsx52u+SisypmrdGxer gmO+045OBRPCSIuK2s0Bcg20r8nLAgdYgXn5O1q25HaTAZBRMB9sVOmooa21zZFJYVWuFMltQIu kIs4= X-Gm-Gg: ASbGnctxDY1caaGZw+MRyBuT2FDQoOWeMHUkQNj9li6d9u6V8P0qm29+ugiRr9KvFUp yTFNmvO2+G4USysbntPz6uw0FEfgmKk3jenV2+c8E100hXQ/HXRhvTpF1ask8HFX8YBen90PPUn KL3f1OFlVAHSSuDGLnJkeZepc6k319LaVZYXQNADzCuqR+FNyGFAD/cKCshY1uh7J17+0Ur/846 WqH8UGiUSKaLm1Kw5YHaAbYzJ2PLHNphLJoLLVyqRADjlWw+x9u3XsNeO7HtH+2eCej4gdkswsp egaElAro65sYXiLugyoYi0exuEDZ7LnMP2iPJTolUyeqjCijAQ== X-Google-Smtp-Source: AGHT+IFiiCld9lsovlNLZiyZG15O1UKwLEyIwPDJ6UpC/n/pGYRSzHptckgGrB9jfZF2kgKFBnwzhw== X-Received: by 2002:a05:620a:1917:b0:7a9:b914:279c with SMTP id af79cd13be357-7b5143dff90mr487051385a.0.1732285784859; Fri, 22 Nov 2024 06:29:44 -0800 (PST) Received: from ip-10-114-89-186.evoforge.org (ec2-52-70-167-183.compute-1.amazonaws.com. [52.70.167.183]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b513f9063csm91144885a.8.2024.11.22.06.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 06:29:44 -0800 (PST) From: Greg Hogan To: guix-patches@gnu.org Subject: [PATCH core-team] packages: 'package-input-rewriting/spec' optionally replace hidden. Date: Fri, 22 Nov 2024 14:29:39 +0000 Message-ID: <7daac6d4cf5c0934236b37b39a112971a0ee0610.1732284490.git.code@greghogan.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:20::72b; envelope-from=code@greghogan.com; helo=mail-qk1-x72b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: Greg Hogan X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Commit eee95b5a879b7096dffd533f24107cf8926b621e changed package rewriting to ignore hidden packages. This patch permits the previous use by adding an option to rewrite hidden packages. * guix/packages.scm (package-input-rewriting/spec)[rewrite]: When P is hidden, return it as-is unless #:replace-hidden? has been enabled. * tests/packages.scm ("package-input-rewriting/spec, replace hidden package"): New test. * doc/guix.texi (Defining Package Variants): Update. Change-Id: I0a7988cac70e0c6b88b0fe6e27c1036fa723e030 --- doc/guix.texi | 5 +++-- guix/packages.scm | 9 ++++++--- tests/packages.scm | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1c39628ffa..e22bb693d7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8619,7 +8619,8 @@ Defining Package Variants The following variant of @code{package-input-rewriting} can match packages to be replaced by name rather than by identity. -@deffn {Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t] +@deffn {Procedure} package-input-rewriting/spec @var{replacements} @ + [#:deep? #t] [#:replace-hidden? #t] Return a procedure that, given a package, applies the given @var{replacements} to all the package graph, including implicit inputs unless @var{deep?} is false. @@ -8628,7 +8629,7 @@ Defining Package Variants package specification such as @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching package and returns a replacement for that package. Matching packages that have the @code{hidden?} property -set are not replaced. +set are not replaced unless @var{replace-hidden?} is set to true. @end deffn The example above could be rewritten this way: diff --git a/guix/packages.scm b/guix/packages.scm index f373136d22..dbb8597488 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1611,14 +1611,16 @@ (define* (package-input-rewriting replacements (package-mapping rewrite cut? #:deep? deep?)) -(define* (package-input-rewriting/spec replacements #:key (deep? #t)) +(define* (package-input-rewriting/spec replacements + #:key (deep? #t) (replace-hidden? #f)) "Return a procedure that, given a package, applies the given REPLACEMENTS to all the package graph, including implicit inputs unless DEEP? is false. REPLACEMENTS is a list of spec/procedures pair; each spec is a package specification such as \"gcc\" or \"guile@2\", and each procedure takes a matching package and returns a replacement for that package. Matching -packages that have the 'hidden?' property set are not replaced." +packages that have the 'hidden?' property set are not replaced unless +REPLACE-HIDDEN? is set to true." (define table (fold (lambda (replacement table) (match replacement @@ -1647,7 +1649,8 @@ (define* (package-input-rewriting/spec replacements #:key (deep? #t)) (define (rewrite p) (if (or (assq-ref (package-properties p) replacement-property) - (hidden-package? p)) + (and (not replace-hidden?) + (hidden-package? p))) p (match (find-replacement p) (#f p) diff --git a/tests/packages.scm b/tests/packages.scm index a623628447..7c28e75c45 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1628,6 +1628,21 @@ (define compressors '(("gzip" . "gz") (match (delete-duplicates pythons eq?) ((p) (eq? p python))))) +(test-assert "package-input-rewriting/spec, replace hidden package" + ;; Rewrite hidden packages when requested. + (let* ((python (hidden-package python)) + (p0 (dummy-package "chbouib" + (build-system trivial-build-system) + (inputs (list python)))) + (rewrite (package-input-rewriting/spec + `(("python" . ,(const sed))) + #:replace-hidden? #t)) + (p1 (rewrite p0))) + (match (package-inputs p1) + ((("python" python)) + (and (string=? (package-full-name python) + (package-full-name sed))))))) + (test-equal "package-input-rewriting/spec, graft" (derivation-file-name (package-derivation %store sed)) base-commit: ba3a03151e6971bdfa9a86af5179055601042ff8 -- 2.46.0 ------------=_1733137382-3127-1--