GNU bug report logs - #66510
`this-package' references reintroduce pre-transformation packages.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Ulf Herrman <striness@HIDDEN>; merged with #50335; dated Fri, 13 Oct 2023 03:59:02 UTC; Maintainer for guix is bug-guix@HIDDEN.
Forcibly Merged 50335 66510. Request was from Ulf Herrman <striness@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Oct 2023 03:58:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 12 23:58:14 2023
Received: from localhost ([127.0.0.1]:44555 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qr9JV-00006x-Iv
	for submit <at> 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 <striness@HIDDEN>) id 1qr9JP-00006Q-CQ
 for submit <at> 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 <striness@HIDDEN>)
 id 1qr9Iw-0007RA-LQ
 for bug-guix@HIDDEN; 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 <striness@HIDDEN>)
 id 1qr9Iu-0004Ja-QY
 for bug-guix@HIDDEN; 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 <striness@HIDDEN>
To: bug-guix@HIDDEN
Subject: `this-package' references reintroduce pre-transformation packages.
Date: Thu, 12 Oct 2023 22:57:14 -0500
Message-ID: <87sf6fdvj9.fsf@HIDDEN>
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@HIDDEN;
 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-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
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
    (($ <package> _ _ _ _ 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-----
--=-=-=--




Acknowledgement sent to Ulf Herrman <striness@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#66510; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 21 Oct 2023 22:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.