Subject: [bug#76246] [PATCH 0/5] Add G-Golf's GTK-4 examples.

From: Florian Pelz <[email-masked]>
Date: Mon, 17 Feb 2025 00:50:12 +0100

Thank you Liliana and Maxim for the feedback.  Also G-Golf author
David Pirotte's feedback from [1].

I hope you are fine with the changes.  In v2:

* Added a patch to remove the expat input from guile-cairo and
  guile2.2-cairo, which is not needed or not needed anymore.
  They have few dependents and the build result does not change
  except the /gnu/store file name and files containing it.

* Liliana asked about why I changed inputs, native inputs in
  guile-cairo-next.  It is because autogen needs them when built from
  git.  Except I now followed Liliana’s suggestion to use the normal
  autoconf instead of autoconf-2.71.

  Even though Gettext is never called, gettext-minimal is used similar
  to what was done for guile-fibers
  <https://github.com/wingo/fibers/issues/17>.

* As Maxim suggested, I got YaSnippet to work and now use idiomatic
  git-file-name and git-version.

* About David’s patch, which I now removed.

  Liliana disliked carrying a large patch to guile-cairo also with
  changes not relevant to Guix.  Therefore I extracted the two
  relevant changes from the patch into build phases.

  Details what the patch did, as I understand:

  Guile-Cairo encodes the path to its own libguile-cairo library in
  its (cairo config) module, but unidiomatically the path in said
  module was local to the build tree during `make check' and
  substituted by the install location during install. [2]  Upstream
  then after the 1.11.2 release took on a patch to be more idiomatic,
  [3] but then install had to be run before check.  David then
  submitted a patch to just dynamic-link the libguile-cairo library by
  its base file name and set LTDL_LIBRARY_PATH during tests [4] along
  with unrelated cleanups not important to Guix.  Previously, I had
  included this patch with all cleanings, but did not list its source.
  Upstream was unhappy with the patch [1][5] not treating guile-cairo
  as a foreign extension and thus using GUILE_EXTENSIONS_PATH.
  Despite the guile-cairo README instructing to “build against this
  library in your C program”, so guile-cairo actually is not a Guile
  foreign extension?  Maybe I misunderstand.  Does not matter here.

* Added a patch to document the --no-grafts requirement to the
  guile-g-golf package description, namely:

Note: Currently, when developing with G-Golf in `guix shell', there is
a grafts bug in Guix (https://bugs.gnu.org/75157).  To avoid it, use
Guix' `--no-grafts' option.  Guix packages that use `wrap-program' are
unaffected.

* g-golf-gtk-4-examples:

  David suggested not to install to /bin but to $prefix/share/doc.

  But that would not be in $PATH automatically.

  My expected usage is *not* like `apt install` but rather:

    guix shell --pure g-golf-gtk-4-examples
    hello-world

  to run the hello-world example.  It is more idiomatic to Guix.

  With share/doc, usage could only be

    $(guix build g-golf-gtk-4-examples)/share/doc/hello-world

  This seems unidiomatic to me.

  For reading the source code, I would not install a doc package.
  Idiomatic usage would be like:

    cd $(guix build --source g-golf-gtk-4-examples)
    cd examples/gtk-4
    less hello-world

  I rather have the examples in $PATH.  Similar to how the gtk4-demo
  is in $PATH when gtk:bin is installed.

  A downside is that G-Golf expects PNG, CSS, UI files in the same
  directory.  Still I rather continue placing them all in
  /gnu/store/2i34kis6z42dgg6awv29w1yjvgnign95-g-golf-gtk-4-examples-0.8.0/bin.

  I do not want to separate PNG, CSS, UI files, which would deviate
  too much from upstream G-Golf.

* Synopsis and description were:

    (synopsis "Example GTK apps written in Guile with G-Golf")
    (description
     "Example applications to show what can be done in G-Golf and how to wrap
the applications in a Guix package.")))

  David suggested a different synopsis and description.

>         (synopsis "G-Golf Gtk-4 Examples")
>          ;; the -4 is essential here above, we will have -5 ...

  I agree with GTK 4.  I would rather keep the words “in Guile”.

>         (description "G-Golf port of (a subset of) the upstream gtk4-demo 
> examples")
>         ;; no need to add anything, with all due respect, "show how to ..."
>         ;; is redundant here, as examples do 'show how to' by definition

  I now have:

    (synopsis "Example GTK 4 apps written in Guile with G-Golf")
    (description
     "G-Golf port of (a subset of) the upstream @code{gtk4-demo} examples in
the @code{gtk:bin} Guix package output.  They also show how to wrap G-Golf
applications in a Guix package.")))

* All examples work now, with new phases to patch them.  My Makefile
  changes now use the cp command rather than install to retain the
  file permission mode, so the PNG files do not have the executable
  bit set.

* Added a reftest in an installcheck phase.  It is not in the upstream
  repo, but I wanted it to prevent G-Golf from breaking without notice
  in the future.  The cost is that it depends on Python, which cannot
  be cross-compiled.

* Added a patch which adds g-golf-adw-1-examples to Guix.  But
  adwaita-1-demo needs AdwBottomSheet from [email-masked].  The
  master branch is at [email-masked].  Therefore, 1 out of 2 demos
  is broken when applied to the master branch.  It works on the
  gnome-team branch.  Nonetheless, I would like to apply
  g-golf-adw-1-examples on the master branch.  For some time, that one
  important demo won’t work, but eventually it will.

[1] <https://lists.gnu.org/archive/html/guix-devel/2025-02/msg00261.html>.
[2] https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/cairo/Makefile.am?id=00aa4358ed7953feb21d1e1d5969bbe6bdd5d190
[3] https://lists.gnu.org/archive/html/guile-user/2020-06/msg00021.html
https://git.savannah.nongnu.org/cgit/guile-cairo.git/commit/?id=345a2de3f78d34ffb448c5cb4860869621583495
[4] https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html
[5] https://lists.gnu.org/archive/html/guile-user/2023-03/msg00029.html

Florian Pelz (5):
  gnu: guile-cairo: Remove expat from inputs.
  gnu: Add guile-cairo-next.
  gnu: guile-g-golf: Document --no-grafts requirement.
  gnu: Add G-Golf's GTK-4 examples.
  gnu: Add G-Golf's Adw-1 examples.

 gnu/packages/gtk.scm       |  42 ++++-
 gnu/packages/guile-xyz.scm | 309 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 348 insertions(+), 3 deletions(-)

base-commit: 5e3e1b782b87d5bfe903f978490955cc20a70e5a
-- 
2.48.1