unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* using package-for-guile2.0 outside of guile.scm
@ 2019-01-27 21:29 Ricardo Wurmus
  2019-01-28 12:48 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Wurmus @ 2019-01-27 21:29 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

I tried to move most of the packages in gnu/packages/guile.scm to a new
module gnu/packages/guile-xyz.scm.

The only problem with this is that package-for-guile2.0 cannot be used
in guile-xyz.scm.  I cannot compile the module when there’s a reference
to package-for-guile2.0, even when the definition is in guile-xyz.scm.
The definition of package-for-guile2.0 refers to guile-2.2, which is
located in guile.scm.

What to do?

--
Ricardo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using package-for-guile2.0 outside of guile.scm
  2019-01-27 21:29 using package-for-guile2.0 outside of guile.scm Ricardo Wurmus
@ 2019-01-28 12:48 ` Ludovic Courtès
  2019-01-29 22:15   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2019-01-28 12:48 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 896 bytes --]

Hello,

Ricardo Wurmus <rekado@elephly.net> skribis:

> I tried to move most of the packages in gnu/packages/guile.scm to a new
> module gnu/packages/guile-xyz.scm.
>
> The only problem with this is that package-for-guile2.0 cannot be used
> in guile-xyz.scm.  I cannot compile the module when there’s a reference
> to package-for-guile2.0, even when the definition is in guile-xyz.scm.
> The definition of package-for-guile2.0 refers to guile-2.2, which is
> located in guile.scm.
>
> What to do?

The problem is that ‘package-with-guile-2.0’ needs to resolve
‘guile-2.0’.  So if you use it at the top-level, then (gnu packages
guile) has to be fully loaded, or you have to be in (gnu packages guile)
itself and ‘guile-2.0’ has been defined above.

I think we can get around it using this cute hack.  I’ll commit it if
that’s fine with you.

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1294 bytes --]

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 1a3069c2fd..5bcb6f4dd7 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -413,7 +413,7 @@ GNU@tie{}Guile.  Use the @code{(ice-9 readline)} module and call its
 (define package-for-guile-2.0
   ;; A procedure that rewrites the dependency tree of the given package to use
   ;; GUILE-2.0 instead of GUILE-2.2.
-  (package-input-rewriting `((,guile-2.2 . ,guile-2.0))
+  (package-input-rewriting (delay `((,guile-2.2 . ,guile-2.0)))
                            (guile-variant-package-name "guile2.0")))
 
 (define-public guile-for-guile-emacs
diff --git a/guix/packages.scm b/guix/packages.scm
index f191327718..f4ce406f00 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -861,7 +861,10 @@ package to replace, and the second one is the replacement.
 Optionally, REWRITE-NAME is a one-argument procedure that takes the name of a
 package and returns its new name after rewrite."
   (define (rewrite p)
-    (match (assq-ref replacements p)
+    (match (assq-ref (if (promise? replacements)
+                         (force replacements)
+                         replacements)
+                     p)
       (#f  (package
              (inherit p)
              (name (rewrite-name (package-name p)))))

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: using package-for-guile2.0 outside of guile.scm
  2019-01-28 12:48 ` Ludovic Courtès
@ 2019-01-29 22:15   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2019-01-29 22:15 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Hi!

Ludovic Courtès <ludo@gnu.org> skribis:

> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> I tried to move most of the packages in gnu/packages/guile.scm to a new
>> module gnu/packages/guile-xyz.scm.
>>
>> The only problem with this is that package-for-guile2.0 cannot be used
>> in guile-xyz.scm.  I cannot compile the module when there’s a reference
>> to package-for-guile2.0, even when the definition is in guile-xyz.scm.
>> The definition of package-for-guile2.0 refers to guile-2.2, which is
>> located in guile.scm.
>>
>> What to do?
>
> The problem is that ‘package-with-guile-2.0’ needs to resolve
> ‘guile-2.0’.  So if you use it at the top-level, then (gnu packages
> guile) has to be fully loaded, or you have to be in (gnu packages guile)
> itself and ‘guile-2.0’ has been defined above.
>
> I think we can get around it using this cute hack.  I’ll commit it if
> that’s fine with you.

As you found out, that’s not enough.  The reason is that
‘package-input-rewriting’ is inherently greedy, not lazy.  For example:

  (let ((rewrite (package-input-rewriting `((,p . ,q)))))
    (eq? q (rewrite p)))
  => #t

This works only because the replacement alist is traversed as soon as
‘rewrite’ is called.

Needs more thought…

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-29 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-27 21:29 using package-for-guile2.0 outside of guile.scm Ricardo Wurmus
2019-01-28 12:48 ` Ludovic Courtès
2019-01-29 22:15   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).