diff mbox series

[bug#47824,v2,3/3] gnu: tsukundere: Update to 0.3.0.

Message ID 20210419081744.7247-3-leo.prikler@student.tugraz.at
State Accepted
Headers show
Series [bug#47824,v2,1/3] gnu: guile-sdl2: Update to 0.6.0. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Leo Prikler April 19, 2021, 8:17 a.m. UTC
* gnu/packages/game-development.scm (tsukundere): Update to 0.3.0.
[patch-command]: Patch path to guile.  Construct load paths directly from
inputs.
[propagated-inputs]: Remove.
[inputs]: Add guile (as guile-runtime) and guile-sdl2.
---
 gnu/packages/game-development.scm | 51 +++++++++++++++++++------------
 1 file changed, 32 insertions(+), 19 deletions(-)

Comments

Ludovic Courtès May 5, 2021, 2:16 p.m. UTC | #1
Hi Leo,

On a cursory look, all three patches LGTM.

One nit:

> +                   "exec "
> +                   (assoc-ref inputs "guile-runtime")
> +                   "/bin/guile " args)))

[...]

>         ("guile" ,guile-3.0)
>         ("pkg-config" ,pkg-config)
>         ("texinfo" ,texinfo)))
> -    (propagated-inputs
> -     `(("guile-sdl2" ,guile3.0-sdl2)))
> +    (inputs
> +     `(("guile-sdl2" ,guile3.0-sdl2)
> +       ("guile-runtime" ,guile-3.0)))

I think it’s best to not play trick with labels, and to always use the
package name as the label (to facilitate migration on the day where we
get rid of labels, who knows…).

A common pattern for the case above is to provide “guile” both as native
input and input, and to write:

  (assoc-ref (or native-inputs inputs) "guile")

Thanks, and congrats to the Lisp Game Jam participants!

Ludo’.
Leo Prikler May 5, 2021, 3 p.m. UTC | #2
Hi Ludo,

Am Mittwoch, den 05.05.2021, 16:16 +0200 schrieb Ludovic Courtès:
> Hi Leo,
> 
> On a cursory look, all three patches LGTM.
> 
> One nit:
> 
> > +                   "exec "
> > +                   (assoc-ref inputs "guile-runtime")
> > +                   "/bin/guile " args)))
> 
> [...]
> 
> >         ("guile" ,guile-3.0)
> >         ("pkg-config" ,pkg-config)
> >         ("texinfo" ,texinfo)))
> > -    (propagated-inputs
> > -     `(("guile-sdl2" ,guile3.0-sdl2)))
> > +    (inputs
> > +     `(("guile-sdl2" ,guile3.0-sdl2)
> > +       ("guile-runtime" ,guile-3.0)))
> 
> I think it’s best to not play trick with labels, and to always use
> the
> package name as the label (to facilitate migration on the day where
> we
> get rid of labels, who knows…).
> 
> A common pattern for the case above is to provide “guile” both as
> native
> input and input, and to write:
> 
>   (assoc-ref (or native-inputs inputs) "guile")
What I'm doing here is the exact opposite.  I don't want the
omnipresent native-input guile to shadow the guile I use as input, so I
assign a "unique" label to the input guile to refer to it.  As a neat
side effect, this label allows me to construct GUILE_LOAD_PATH more
easily.

We already have a number of issues related to the "native-input as
input" thing, "which" returning the wrong binary, and so on, and I
didn't want to add another one on top.  The code I wrote certainly
looks and feels ugly, but I don't see any other way with what Guix
currently provides.  Maybe for the next c-u merge we can do proper
separation of inputs and native-inputs, hopefully using that to clean
up some of our recipes.  

Regards,
Leo
Ludovic Courtès May 6, 2021, 10:52 a.m. UTC | #3
Hi,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

> Am Mittwoch, den 05.05.2021, 16:16 +0200 schrieb Ludovic Courtès:
>> Hi Leo,
>> 
>> On a cursory look, all three patches LGTM.
>> 
>> One nit:
>> 
>> > +                   "exec "
>> > +                   (assoc-ref inputs "guile-runtime")
>> > +                   "/bin/guile " args)))
>> 
>> [...]
>> 
>> >         ("guile" ,guile-3.0)
>> >         ("pkg-config" ,pkg-config)
>> >         ("texinfo" ,texinfo)))
>> > -    (propagated-inputs
>> > -     `(("guile-sdl2" ,guile3.0-sdl2)))
>> > +    (inputs
>> > +     `(("guile-sdl2" ,guile3.0-sdl2)
>> > +       ("guile-runtime" ,guile-3.0)))
>> 
>> I think it’s best to not play trick with labels, and to always use
>> the
>> package name as the label (to facilitate migration on the day where
>> we
>> get rid of labels, who knows…).
>> 
>> A common pattern for the case above is to provide “guile” both as
>> native
>> input and input, and to write:
>> 
>>   (assoc-ref (or native-inputs inputs) "guile")
> What I'm doing here is the exact opposite.  I don't want the
> omnipresent native-input guile to shadow the guile I use as input,

In that case, you can unconditionally do:

  (assoc-ref inputs "guile")

Unless I’m mistaken, it won’t be shadowed by the native input “guile”
when cross-compiling.

Or am I missing something?

Ludo’.
Leo Prikler May 6, 2021, 11:03 a.m. UTC | #4
Am Donnerstag, den 06.05.2021, 12:52 +0200 schrieb Ludovic Courtès:
> Hi,
> 
> Leo Prikler <leo.prikler@student.tugraz.at> skribis:
> 
> > Am Mittwoch, den 05.05.2021, 16:16 +0200 schrieb Ludovic Courtès:
> > > Hi Leo,
> > > 
> > > On a cursory look, all three patches LGTM.
> > > 
> > > One nit:
> > > 
> > > > +                   "exec "
> > > > +                   (assoc-ref inputs "guile-runtime")
> > > > +                   "/bin/guile " args)))
> > > 
> > > [...]
> > > 
> > > >         ("guile" ,guile-3.0)
> > > >         ("pkg-config" ,pkg-config)
> > > >         ("texinfo" ,texinfo)))
> > > > -    (propagated-inputs
> > > > -     `(("guile-sdl2" ,guile3.0-sdl2)))
> > > > +    (inputs
> > > > +     `(("guile-sdl2" ,guile3.0-sdl2)
> > > > +       ("guile-runtime" ,guile-3.0)))
> > > 
> > > I think it’s best to not play trick with labels, and to always
> > > use
> > > the
> > > package name as the label (to facilitate migration on the day
> > > where
> > > we
> > > get rid of labels, who knows…).
> > > 
> > > A common pattern for the case above is to provide “guile” both as
> > > native
> > > input and input, and to write:
> > > 
> > >   (assoc-ref (or native-inputs inputs) "guile")
> > What I'm doing here is the exact opposite.  I don't want the
> > omnipresent native-input guile to shadow the guile I use as input,
> 
> In that case, you can unconditionally do:
> 
>   (assoc-ref inputs "guile")
> 
> Unless I’m mistaken, it won’t be shadowed by the native input “guile”
> when cross-compiling.
> 
> Or am I missing something?
Perhaps it's an implementation detail, that when performing native
builds, inputs are merged as (append inputs native-inputs), but they
could as well be (append native-inputs inputs).  I'd have to check, and
I'm not sure whether I want to rely on that detail. 

Regards,
Leo
Leo Prikler May 15, 2021, 8:35 a.m. UTC | #5
Ping.
For the record, I've pushed guile-sdl and chickadee already, any hints
w.r.t. the problem in Tsukundere?

Am Donnerstag, den 06.05.2021, 13:03 +0200 schrieb Leo Prikler:
> Am Donnerstag, den 06.05.2021, 12:52 +0200 schrieb Ludovic Courtès:
> > Hi,
> > 
> > Leo Prikler <leo.prikler@student.tugraz.at> skribis:
> > 
> > > Am Mittwoch, den 05.05.2021, 16:16 +0200 schrieb Ludovic Courtès:
> > > > Hi Leo,
> > > > 
> > > > On a cursory look, all three patches LGTM.
> > > > 
> > > > One nit:
> > > > 
> > > > > +                   "exec "
> > > > > +                   (assoc-ref inputs "guile-runtime")
> > > > > +                   "/bin/guile " args)))
> > > > 
> > > > [...]
> > > > 
> > > > >         ("guile" ,guile-3.0)
> > > > >         ("pkg-config" ,pkg-config)
> > > > >         ("texinfo" ,texinfo)))
> > > > > -    (propagated-inputs
> > > > > -     `(("guile-sdl2" ,guile3.0-sdl2)))
> > > > > +    (inputs
> > > > > +     `(("guile-sdl2" ,guile3.0-sdl2)
> > > > > +       ("guile-runtime" ,guile-3.0)))
> > > > 
> > > > I think it’s best to not play trick with labels, and to always
> > > > use
> > > > the
> > > > package name as the label (to facilitate migration on the day
> > > > where
> > > > we
> > > > get rid of labels, who knows…).
> > > > 
> > > > A common pattern for the case above is to provide “guile” both
> > > > as
> > > > native
> > > > input and input, and to write:
> > > > 
> > > >   (assoc-ref (or native-inputs inputs) "guile")
> > > What I'm doing here is the exact opposite.  I don't want the
> > > omnipresent native-input guile to shadow the guile I use as
> > > input,
> > 
> > In that case, you can unconditionally do:
> > 
> >   (assoc-ref inputs "guile")
> > 
> > Unless I’m mistaken, it won’t be shadowed by the native input
> > “guile”
> > when cross-compiling.
> > 
> > Or am I missing something?
> Perhaps it's an implementation detail, that when performing native
> builds, inputs are merged as (append inputs native-inputs), but they
> could as well be (append native-inputs inputs).  I'd have to check,
> and
> I'm not sure whether I want to rely on that detail. 
> 
> Regards,
> Leo
Ludovic Courtès May 15, 2021, 1:45 p.m. UTC | #6
Hi Leo,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

> For the record, I've pushed guile-sdl and chickadee already, any hints
> w.r.t. the problem in Tsukundere?

[...]

>> > > > I think it’s best to not play trick with labels, and to always
>> > > > use
>> > > > the
>> > > > package name as the label (to facilitate migration on the day
>> > > > where
>> > > > we
>> > > > get rid of labels, who knows…).
>> > > > 
>> > > > A common pattern for the case above is to provide “guile” both
>> > > > as
>> > > > native
>> > > > input and input, and to write:
>> > > > 
>> > > >   (assoc-ref (or native-inputs inputs) "guile")
>> > > What I'm doing here is the exact opposite.  I don't want the
>> > > omnipresent native-input guile to shadow the guile I use as
>> > > input,
>> > 
>> > In that case, you can unconditionally do:
>> > 
>> >   (assoc-ref inputs "guile")
>> > 
>> > Unless I’m mistaken, it won’t be shadowed by the native input
>> > “guile”
>> > when cross-compiling.
>> > 
>> > Or am I missing something?
>> Perhaps it's an implementation detail, that when performing native
>> builds, inputs are merged as (append inputs native-inputs), but they
>> could as well be (append native-inputs inputs).  I'd have to check,
>> and
>> I'm not sure whether I want to rely on that detail. 

I didn’t see a question mark, which is why I didn’t answer.  :-)

I fail to see why (assoc-ref inputs …) wouldn’t work.

Thanks,
Ludo’.
Leo Prikler May 15, 2021, 2:02 p.m. UTC | #7
Hi Ludo’,

Am Samstag, den 15.05.2021, 15:45 +0200 schrieb Ludovic Courtès:
> Hi Leo,
> 
> Leo Prikler <leo.prikler@student.tugraz.at> skribis:
> 
> > For the record, I've pushed guile-sdl and chickadee already, any
> > hints
> > w.r.t. the problem in Tsukundere?
> 
> [...]
> 
> > > > In that case, you can unconditionally do:
> > > > 
> > > >   (assoc-ref inputs "guile")
> > > > 
> > > > Unless I’m mistaken, it won’t be shadowed by the native input
> > > > “guile” when cross-compiling.
> > > > 
> > > > Or am I missing something?
> > > Perhaps it's an implementation detail, that when performing
> > > native
> > > builds, inputs are merged as (append inputs native-inputs), but
> > > they
> > > could as well be (append native-inputs inputs).  I'd have to
> > > check,
> > > and
> > > I'm not sure whether I want to rely on that detail. 
> 
> I didn’t see a question mark, which is why I didn’t answer.  :-)
> 
> I fail to see why (assoc-ref inputs …) wouldn’t work.
Ahh, my bad, it appears I was just confused.  If both native-inputs and
inputs refer to "the same" guile and are on the same architecture, they
should have the same hash, so it doesn't matter, which one is picked. 
I'll try to rewrite the package with that in mind.

Thanks,
Leo
diff mbox series

Patch

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 0d4855d275..ccf1fbdc5d 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -493,7 +493,7 @@  clone.")
 (define-public tsukundere
   (package
     (name "tsukundere")
-    (version "0.2.3")
+    (version "0.3.0")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -502,10 +502,12 @@  clone.")
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "05ckds2df810441wfavllx9lsw5jsc9h3nb7m31df01nsj56azdw"))))
+                "06jiaylbnx8khicsaq2gwnd8wspjhjymbb5z6x5445krklk0jx18"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:modules (((guix build guile-build-system)
+     `(#:modules ((ice-9 match)
+                  (srfi srfi-1)
+                  ((guix build guile-build-system)
                    #:select (target-guile-effective-version))
                   ,@%gnu-build-system-modules)
        #:imported-modules ((guix build guile-build-system)
@@ -513,22 +515,32 @@  clone.")
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-command
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (version (target-guile-effective-version))
-                    (scm (string-append out "/share/guile/site/"
-                                        version))
-                    (go (string-append out "/lib/guile/"
-                                       version "/site-ccache")))
-
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((scm (lambda (in)
+                           (string-append in "/share/guile/site/"
+                                          (target-guile-effective-version))))
+                    (ccache (lambda (in)
+                              (string-append in "/lib/guile/"
+                                             (target-guile-effective-version)
+                                             "/site-ccache")))
+                    (pkgs
+                     (cons
+                      (assoc-ref outputs "out")
+                      (filter-map
+                       (match-lambda
+                         ((label . pkg)
+                          (and (string-prefix? "guile-" label) pkg)))
+                       inputs))))
                (substitute* "bin/tsukundere"
-                 (("exec guile .*" all)
+                 (("exec guile (.*)" _ args)
                   (string-append
-                   (format #f "export GUILE_LOAD_PATH=~@?~%"
-                           "\"~a:~a\"" scm (getenv "GUILE_LOAD_PATH"))
-                   (format #f "export GUILE_LOAD_COMPILED_PATH=~@?~%"
-                           "\"~a:~a\"" go (getenv "GUILE_LOAD_COMPILED_PATH"))
-                   all)))
+                   (format #f "export GUILE_LOAD_PATH=\"~@?\"~%"
+                           "\"~{~a~^:~}\"" (map scm pkgs))
+                   (format #f "export GUILE_LOAD_COMPILED_PATH=\"~@?\"~%"
+                           "\"~{~a~^:~}\"" (map ccache pkgs))
+                   "exec "
+                   (assoc-ref inputs "guile-runtime")
+                   "/bin/guile " args)))
                #t))))))
     (native-inputs
      `(("autoconf" ,autoconf)
@@ -536,8 +548,9 @@  clone.")
        ("guile" ,guile-3.0)
        ("pkg-config" ,pkg-config)
        ("texinfo" ,texinfo)))
-    (propagated-inputs
-     `(("guile-sdl2" ,guile3.0-sdl2)))
+    (inputs
+     `(("guile-sdl2" ,guile3.0-sdl2)
+       ("guile-runtime" ,guile-3.0)))
     (home-page "https://gitlab.com/leoprikler/tsukundere")
     (synopsis "Visual novel engine")
     (description "Tsukundere is a game engine geared heavily towards the