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> Full text available.

Message received at submit <at>

Received: (at submit) by; 13 Oct 2023 03:58:14 +0000
From debbugs-submit-bounces <at> Thu Oct 12 23:58:14 2023
Received: from localhost ([]:44555
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1qr9JV-00006x-Iv
	for submit <at>; Thu, 12 Oct 2023 23:58:13 -0400
Received: from ([2001:470:142::17]:43776)
 by with esmtp (Exim 4.84_2)
 (envelope-from <striness@HIDDEN>) id 1qr9JP-00006Q-CQ
 for submit <at>; Thu, 12 Oct 2023 23:58:11 -0400
Received: from ([2001:470:142:3::10])
 by 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 ([])
 by 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 (Postfix, from userid 5378)
 id DF6682204ECD3; Fri, 13 Oct 2023 03:57:34 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 DF6682204ECD3
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;; s=mail;
 t=1697169454; bh=RaFJNMUOZZsOrjAEtX8icDj5e5J61xMnM57nBSGgeUU=;
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=; envelope-from=striness@HIDDEN;
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,
 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>
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <>
List-Unsubscribe: <>, 
 <mailto:debbugs-submit-request <at>>
List-Archive: <>
List-Post: <mailto:debbugs-submit <at>>
List-Help: <mailto:debbugs-submit-request <at>>
List-Subscribe: <>, 
 <mailto:debbugs-submit-request <at>>
Errors-To: debbugs-submit-bounces <at>
Sender: "Debbugs-submit" <debbugs-submit-bounces <at>>
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 under the
"G-expressions and self-referential records" heading:

(define hello
    (name "hello")
    ;; =E2=80=A6
     (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
    (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
    (inherit hello)
    (name "hello-variant")
    (inputs `(("gawk" ,gawk-4.0)))
     (substitute-keyword-arguments (package-arguments hello)
       ((#:configure-flags flags #~'())
        #~(cons "--with-hospitality=3Dice-cream"

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

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
    (inherit hello
     (arguments hello-arguments))
    (name "hello-variant")
    (inputs `(("gawk" ,gawk-4.0)))
     (substitute-keyword-arguments hello-arguments
       ((#:configure-flags flags #~'())
        #~(cons "--with-hospitality=3Dice-cream"

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.


=2D Ulf

Content-Type: application/pgp-signature; name="signature.asc"



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.