From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id YKF/GpTAKGVnxgAA9RJhRA:P1 (envelope-from ) for ; Fri, 13 Oct 2023 05:59:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id YKF/GpTAKGVnxgAA9RJhRA (envelope-from ) for ; Fri, 13 Oct 2023 05:59:16 +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 3AC7258CCD for ; Fri, 13 Oct 2023 05:59:16 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tilde.club header.s=mail header.b=BF83EKto; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=tilde.club (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697169556; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=zjDhJ9ZQSDrsFscF7993NLrM4Lyhu2DjonTQ4ll9cI4=; b=BMKK7/6qzkUsRNDhr74uqdBMHOVNjxxyHqCE8JNOePgAS46hXFVhzDnmO9Hwu9EqpCiwBh O/hpHY8a5PvAA5vkypE4geTUi7SnS9HlLdnRO2Vjqp/rw0yGRgzZ6+sk3nUHlYbCLwdX48 q6bIBFbWQ1aK/z0p69GaefoC/9qX/uQio07r+0DU+OCC3OO5/gh5zkotF+r2nc6fxMSrKn T+D3afUXJWleHo7dr2HoD/hZBhgrqnSyc2l5eQCCGZ+TAJ4dJOvsI6iqdaow+kBWf1+ONh oLOge0CYOiwyI3SjyskRIPPa6t4yIGfA+OrWvfeF5nDpzX7BBtEOofKhCEegsw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tilde.club header.s=mail header.b=BF83EKto; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=tilde.club (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697169556; a=rsa-sha256; cv=none; b=mt3ZTVp0jLrhwAbVi0ivNkYl/Y6Bn4QtJqoPbCatT4lxY5sYJIxshKcOkwk+jGJPSnQQWq 5st0/8Jf+aOTD/IvJZIBapxyhwgLTAh2l9aIaDOnoySYCOMP3qCDAxZbMFivUjc5SvM0zt DFG5hl9qmEw0P9OxmDlHXdOBN2fT4/MZYPyzT+4FHcutBJodqCKJylQrB0pL63zRJO17cP UWH/Vg09iwudHHFTRVQ09obvRFm0K+S9YpsIWGoS86tCOUSBa0/+d9L058aVK8XZ+j8Pxo YQ5aDcLcj3XIDZ2StjHEqJIKdcQ3smT174COQC4eMGnsBQJPcKTea2E9fxjr6A== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qr9Jz-0007fu-IN; Thu, 12 Oct 2023 23:58:43 -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 1qr9Jw-0007fX-9y for bug-guix@gnu.org; Thu, 12 Oct 2023 23:58:41 -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 1qr9Jw-0004Te-0r for bug-guix@gnu.org; Thu, 12 Oct 2023 23:58:40 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qr9KI-00008S-Cg for bug-guix@gnu.org; Thu, 12 Oct 2023 23:59:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#66510: `this-package' references reintroduce pre-transformation packages. Resent-From: Ulf Herrman Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 13 Oct 2023 03:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66510 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 66510@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1697169494435 (code B ref -1); Fri, 13 Oct 2023 03:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 Oct 2023 03:58:14 +0000 Received: from localhost ([127.0.0.1]:44555 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qr9JV-00006x-Iv for submit@debbugs.gnu.org; Thu, 12 Oct 2023 23:58:13 -0400 Received: from lists.gnu.org ([2001:470:142::17]:43776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qr9JP-00006Q-CQ for submit@debbugs.gnu.org; Thu, 12 Oct 2023 23:58:11 -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 1qr9Iw-0007RA-LQ for bug-guix@gnu.org; Thu, 12 Oct 2023 23:57:38 -0400 Received: from tilde.club ([142.44.150.184]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qr9Iu-0004Ja-QY for bug-guix@gnu.org; Thu, 12 Oct 2023 23:57:38 -0400 Received: by tilde.club (Postfix, from userid 5378) id DF6682204ECD3; Fri, 13 Oct 2023 03:57:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club DF6682204ECD3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail; t=1697169454; bh=RaFJNMUOZZsOrjAEtX8icDj5e5J61xMnM57nBSGgeUU=; h=From:To:Subject:Date:From; b=BF83EKtoeVxE/FIQSjskKpTtfdPPQjYq/fVBjHFIVsdwwK6QQQZjLxyrU7Jdh5IG5 yxjnwDuelVPrDyHR2Tnp5EemacjK0N9pZyYpl0Hje6GbeTgSL80EI7B2brGHMJTMxL XMchUjiQoWPKzqffzD+WWZ4ZBIoQt3G04+xLgQY8= From: Ulf Herrman Date: Thu, 12 Oct 2023 22:57:14 -0500 Message-ID: <87sf6fdvj9.fsf@tilde.club> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=142.44.150.184; envelope-from=striness@tilde.club; helo=tilde.club X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.74 X-Spam-Score: 0.74 X-Migadu-Queue-Id: 3AC7258CCD X-Migadu-Scanner: mx2.migadu.com X-TUID: 7fS2OQnTE359 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Suppose you have a package that is using a gexp in its argument list and, like a good citizen of the gexp world, it uses this-package-input to refer to its own input packages. In fact, let's suppose that it's the model citizen depicted in https://guix.gnu.org/en/blog/2021/the-big-change/ under the "G-expressions and self-referential records" heading: (define hello (package (name "hello") ;; =E2=80=A6 (arguments (list #:configure-flags #~(list (string-append "--with-gawk=3D" #$(this-package-input "gawk"))))) (inputs `(("gawk" ,gawk))))) If we define a variant like so: (define hello-variant (package (inherit hello) (name "hello-variant") (inputs `(("gawk" ,gawk-4.0))))) it will work just fine. But if we define a variant like SO: (define hello-variant (package (inherit hello) (name "hello-variant") (inputs `(("gawk" ,gawk-4.0))) (arguments (substitute-keyword-arguments (package-arguments hello) ((#:configure-flags flags #~'()) #~(cons "--with-hospitality=3Dice-cream" #$flags)))))) it will NOT work just fine. When (package-arguments hello) is evaluated, it will execute the field definition for `hello' with `this-package' bound to `hello', rather than `hello-variant'. Consequently, `this-package-input' will return gawk rather than gawk-4.0. We need a way to access the "parent" package's fields while keeping `this-package' bound to its current value. The most general form of this would look something like this: (define (package-arguments-with-package p0 p) (match p0 (($ _ _ _ _ arguments-proc) (arguments-proc p)))) Then hello-variant could be changed to use (package-arguments-with-package hello this-package) instead of (package-arguments hello). This may be needlessly general, though; the problem could also be solved with an interface more along the lines of (parent-package-arguments hello) which expands into the aforementioned package-arguments-with-package call. Another option would be to, yet again, extend the record syntax. It's always bugged me a bit to have to explicitly reference the original record in more than one place when using derived fields, so this might be generally useful as well: (define hello-variant (package (inherit hello (arguments hello-arguments)) (name "hello-variant") (inputs `(("gawk" ,gawk-4.0))) (arguments (substitute-keyword-arguments hello-arguments ((#:configure-flags flags #~'()) #~(cons "--with-hospitality=3Dice-cream" #$flags)))))) This would create a macro named `hello-arguments' within the scope of the (package ...) form which expands into something equivalent to a `parent-package-arguments' call. Adjust syntax to taste. Thoughts? =2D Ulf --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHIBAEBCAAyFiEEn6BUn0yca1D9JsMa1lV76sJM9mgFAmUowBoUHHN0cmluZXNz QHRpbGRlLmNsdWIACgkQ1lV76sJM9mhMggv+KB3jA1cTdS9iUoGC2tJWHNvWYAjp tq6kaKJgop/2hgxcdPuhB37Lcx3TOCTJoVFzL7Mpni6o4k2UolgERYMy9hUCzXul XZhqoLrSvDWfQEpoKzFNMZaVGC6PSirFdFb3XteyrfiWyjH/INgL/IX+V91g93Si /ZR7Ks6CiRuQ5MReW2LzyhiDx64KXEnE3oUCnqKUfDJgLtHD/bFqqK3ZqjIPeIir 4pPDfq2pyH8MqQAx5cQjfmQwVoX1RNKITISHlvIAZvTVsp7oCJV0Rvg/Pg+8kpFI P6eKyzsJJbZx4NYVRpXAXXpfcn5D02CjGErOYrFolK+HLT5KlyNc6FYFQstOyoB2 vAu/WYaSBD4rfaT6iSL4m9zH4kMb6pl2sLkgMP5QPYK2i0zsnvjAqBc+2SPOwpvE n52+uq7w/WtqzcZCYzmezunTK9VvGy50+HkfC2aVDpckpC3HSklotkDhJkn8PHwy bxxxDRP9nfcG9YirGPJrJ+Y5G0UmBvAniMkR =8Su+ -----END PGP SIGNATURE----- --=-=-=--