all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ulf Herrman <striness@tilde.club>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: Ulf Herrman <striness@tilde.club>, 65665@debbugs.gnu.org
Subject: bug#65665: [PATCH] Really get all the implicit inputs.
Date: Fri, 06 Oct 2023 02:37:26 -0500	[thread overview]
Message-ID: <874jj45hhl.fsf@tilde.club> (raw)
In-Reply-To: <87a5swlbnp.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 05 Oct 2023 22:36:42 -0400")


[-- Attachment #1.1: Type: text/plain, Size: 697 bytes --]

I've also been using this patch, which rebinds `this-package' within
package variants to refer instead to the variant rather than the
original.  When I tried applying a deep transformation to icecat, it
failed to reach icecat-minimal or something like that.  Or maybe it was
some input of icecat - might have been my local version of mesa that had
breakage.  Anyway, I've since forgotten exactly what happened and why (I
didn't actually write the commit message until quite some time later),
but I do know that this patch fixed it.

I might try to rediscover what the problem was later, but thought it
would be good to make you aware of this so as to hopefully consolidate
world rebuilds.

- Ulf


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-guix-packages-rebind-this-package-for-package-varian.patch --]
[-- Type: text/x-patch, Size: 6882 bytes --]

From 06245c37fc0ee21144279682223dff01f3e6dbf4 Mon Sep 17 00:00:00 2001
Message-Id: <06245c37fc0ee21144279682223dff01f3e6dbf4.1696574074.git.striness@tilde.club>
From: Ulf Herrman <striness@tilde.club>
Date: Wed, 4 Oct 2023 03:17:25 -0500
Subject: [PATCH] guix: packages: rebind `this-package' for package variants.

Background: there is a `this-package' identifier that can be used within any
of the thunked fields of <package>.  This is implemented by passing the
package in question as an argument to the "thunk" that is called to get the
field value.  `this-package' is used to implement macros like
`this-package-input'.  Consequently, there is a subtle difference between a
package that inherits another package's thunked field and one that wraps it:
in the former, the `this-package' of the thunked field will refer to the
inheriting package, while in the latter case it will refer to the original
package.

Use of `this-package' tends to cause lots of subtle and hard-to-debug breakage
when package transformations are used.  In `package-mapping', it makes more
sense to have `this-package' refer to the transformed package (that is, the
package after being transformed by the user-provided procedure and having all
of its applicable inputs transformed, recursively), since otherwise
untransformed inputs may be reintroduced via `this-package'.

There's still one place where `this-package' can cause problems, though, and
that's in the user-specified transformation procedure itself.  Whether it's
appropriate to have the thunks of the original refer to the original package
or the transformed package is only really known by the author of the
transformation.  We therefore expose procedures for invoking the field thunks
with arbitrary packages.

In my experience, this has led to far more consistent and predictable
package-transforming.

If we really need the ability to refer to the lexically enclosing package
instead of "whichever package ends up using this field definition" - which
seems to be unnecessary at present, since the overwhelming majority of uses of
'this-package' are in the context of 'this-package-input', etc - we could
introduce a 'this-literal-package' identifier.  Or we could rename all current
uses of 'this-package' to use 'this-package-variant' or something like that,
though that sounds like more work.

* guix/packages.scm (package-inputs-with-package,
  package-native-inputs-with-package, package-propagated-inputs-with-package,
  package-arguments-with-package):
  new procedures.
  (package-mapping): use them.
---
 guix/packages.scm | 61 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 47 insertions(+), 14 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 1334def142..288867b911 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -138,6 +138,11 @@ (define-module (guix packages)
             package-transitive-propagated-inputs
             package-transitive-native-search-paths
             package-transitive-supported-systems
+            package-inputs-with-package
+            package-native-inputs-with-package
+            package-propagated-inputs-with-package
+            package-arguments-with-package
+
             package-mapping
             package-input-rewriting
             package-input-rewriting/spec
@@ -1451,6 +1456,31 @@ (define (build-system-with-package-mapping bs rewrite-input rewrite-argument)
     (inherit bs)
     (lower lower*)))
 
+(define (package-inputs-with-package p0 p)
+  (match p0
+    (($ <package> _ _ _ _ args-proc
+                   inputs-proc
+                   propagated-inputs-proc
+                   native-inputs-proc)
+     (inputs-proc p))))
+
+(define (package-native-inputs-with-package p0 p)
+  (match p0
+    (($ <package> _ _ _ _ _ _ _
+                   native-inputs-proc)
+     (native-inputs-proc p))))
+
+(define (package-propagated-inputs-with-package p0 p)
+  (match p0
+    (($ <package> _ _ _ _ _ _
+                   propagated-inputs-proc)
+     (propagated-inputs-proc p))))
+
+(define (package-arguments-with-package p0 p)
+  (match p0
+    (($ <package> _ _ _ _ arguments-proc)
+     (arguments-proc p))))
+
 (define* (package-mapping proc #:optional (cut? (const #f))
                           #:key deep?)
   "Return a procedure that, given a package, applies PROC to all the packages
@@ -1525,22 +1555,25 @@ (define* (package-mapping proc #:optional (cut? (const #f))
                                     rewrite-input
                                     rewrite-argument)
                                    (package-build-system p)))
-                 (inputs (map rewrite-input (package-inputs p)))
-                 (native-inputs (map rewrite-input (package-native-inputs p)))
+                 (inputs (map rewrite-input
+                              (package-inputs-with-package p this-package)))
+                 (native-inputs (map rewrite-input
+                                     (package-native-inputs-with-package
+                                      p this-package)))
                  (propagated-inputs
-                  (map rewrite-input (package-propagated-inputs p)))
+                  (map rewrite-input
+                       (package-propagated-inputs-with-package
+                        p this-package)))
                  (arguments
-                  (match p
-                       (($ <package> _ _ _ _ args-proc)
-                        ;; If we let ARGS-PROC be passed its original package,
-                        ;; we somehow end up in an infinite (or maybe just
-                        ;; exponential? Never seen it end...) loop.  Should
-                        ;; probably figure out what's causing that at some
-                        ;; point.
-                        (let ((args (args-proc this-package)))
-                          (if deep?
-                              (map rewrite-argument args)
-                              args)))))
+                  ;; If we let ARGS-PROC be passed its original package,
+                  ;; we somehow end up in an infinite (or maybe just
+                  ;; exponential? Never seen it end...) loop.  Should
+                  ;; probably figure out what's causing that at some
+                  ;; point.
+                  (if deep?
+                      (map rewrite-argument (package-arguments-with-package
+                                             p this-package))
+                      (package-arguments-with-package p this-package)))
                  (replacement (and=> (package-replacement p) replace))
                  (properties `((,mapping-property . #t)
                                ,@(package-properties p)))))))))

-- 
2.40.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  reply	other threads:[~2023-10-06  7:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 20:14 bug#65665: package-mapping with #:deep? #t doesn't get all the implicit inputs Ulf Herrman
2023-09-01 18:08 ` Csepp
2023-09-03 13:02 ` Maxim Cournoyer
2023-09-05 14:57 ` Simon Tournier
2023-09-16  9:45 ` bug#65665: [PATCH] Really " Ulf Herrman
2023-10-06  2:36   ` Maxim Cournoyer
2023-10-06  7:37     ` Ulf Herrman [this message]
2023-10-07  3:47       ` Ulf Herrman
2023-10-12 13:47       ` bug#65665: package-mapping with #:deep? #t doesn't " Ludovic Courtès
2023-10-12  7:07     ` bug#65665: [PATCH] Really " Ludovic Courtès
2023-10-12 14:22     ` Simon Tournier
2023-10-12 14:06   ` bug#65665: package-mapping with #:deep? #t doesn't " Ludovic Courtès
2023-10-12 16:00     ` Maxim Cournoyer
2023-10-14 14:47       ` Ludovic Courtès
2023-10-13  3:11     ` Ulf Herrman
2023-10-14 15:18       ` Ludovic Courtès
2023-10-15  7:12         ` Ulf Herrman
2023-10-21 14:31           ` Ludovic Courtès
2023-10-21 22:22             ` Ulf Herrman
2023-10-23 13:53               ` Simon Tournier
2023-10-12 13:53 ` Ludovic Courtès
2023-10-12 15:53   ` Maxim Cournoyer
2023-10-13  1:49     ` Ulf Herrman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jj45hhl.fsf@tilde.club \
    --to=striness@tilde.club \
    --cc=65665@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.