Subject: Re: [bug#47824] [PATCH 3/3] gnu: tsukundere: Update to 0.3.0.

From: Leo Prikler <[email-masked]>
Date: Mon, 19 Apr 2021 10:24:37 +0200

Am Montag, den 19.04.2021, 10:56 +0300 schrieb Efraim Flashner:
> On Fri, Apr 16, 2021 at 01:07:23PM +0200, Leo Prikler wrote:
> > * 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 | 45 +++++++++++++++++++------
> > ------
> >  1 file changed, 28 insertions(+), 17 deletions(-)
> > 
> > diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-
> > development.scm
> > index 0d4855d275..98ef88971a 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,11 @@ clone.")
> >                (file-name (git-file-name name version))
> >                (sha256
> >                 (base32
> > -                "05ckds2df810441wfavllx9lsw5jsc9h3nb7m31df01nsj56a
> > zdw"))))
> > +                "06jiaylbnx8khicsaq2gwnd8wspjhjymbb5z6x5445krklk0j
> > x18"))))
> >      (build-system gnu-build-system)
> >      (arguments
> > -     `(#:modules (((guix build guile-build-system)
> > +     `(#:modules ((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 +514,31 @@ 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* ((version (target-guile-effective-version))
> 
> I see that the code before uses version but I wouldn't overwrite the
> version variable which normally points to the package's version. I
> suggest guile-version or something similar.
Good point.  Since it's only used to construct scm and go (now ccache),
I've decided to inline (target-guile-effective-version).

> > +                    (scm (lambda (in)
> > +                           (string-append in "/share/guile/site/"
> > +                                          version)))
> > +                    (go (lambda (in)
> 
> Perhaps go-cache would be more descriptive
> (I see that it was also 'go' before)
Decided on ccache, YMMV.

> > +                          (string-append in "/lib/guile/" version
> > +                                         "/site-ccache")))
> > +                    (pkgs
> > +                     (cons
> > +                      (assoc-ref outputs "out")
> > +                      (filter-map
> > +                       (lambda (input)
> > +                         (and (string-prefix? "guile-" (car
> > input)) (cdr input)))
> 
> I'm not in love with this, I personally find it a bit hard to parse.
> I'm
> not really sure what the (cdr input) is there for. (without testing
> it
> myself) I'd suggest borrowing the filter-map code from guile-studio
> in
> (gnu packages guile-xyz) where it searches for emacs packages.
I wanted to avoid needing ice-9 match, but you're right, that looks
better.

> > +                       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"))
> > +                           "\"~{~a~^:~}\"" (map scm pkgs))
> >                     (format #f "export
> > GUILE_LOAD_COMPILED_PATH=~@?~%"
> > -                           "\"~a:~a\"" go (getenv
> > "GUILE_LOAD_COMPILED_PATH"))
> > -                   all)))
> > +                           "\"~{~a~^:~}\"" (map go pkgs))
> > +                   "exec "
> > +                   (assoc-ref inputs "guile-runtime")
> > +                   "/bin/guile " args)))
> >                 #t))))))
> 
> (Again without really testing it) Perhaps it would be better to
> remove
> this whole phase and to replace it with wrap-script.
> 
> Actually, forget all of that. There's a comment in (guix build utils)
> saying that Guile scripts are not supported.
That's why I'm implementing my custom wrapper here.  I'm not sure if
this is a general solution for guile scripts, but for those, that use
the "exec guile" trick, the phase I wrote should act similar to wrap-
program without needing to construct a wrapper script.

Regards,
Leo