[PATCH 0/2] Add G-Golf's GTK-4 examples.

  • Done
  • quality assurance status badge
Details
4 participants
  • Liliana Marie Prikler
  • Maxim Cournoyer
  • Tobias Geerinckx-Rice
  • Florian Pelz
Owner
unassigned
Submitted by
Florian Pelz
Severity
normal

Debbugs page

Florian Pelz wrote 1 months ago
(address . guix-patches@gnu.org)(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)(name . David Pirotte)(address . david@altosw.be)
cover.1739413638.git.pelzflorian@pelzflorian.de
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>

This is in response to David Pirotte's request [1] to package in Guix
his G-Golf examples. I would be happy to receive feedback on whether
this patch’s direction is okay. Not all examples work fine yet.
hello-world does work, though, and strangely it is unaffected by the
grafts bug [2] that plagues me when I use G-Golf in my Guix Home
configuration...


pelzflorian (Florian Pelz) (2):
gnu: Add guile-cairo-next.
UNFINISHED gnu: Add G-Golf's GTK-4 examples.

gnu/local.mk | 1 +
gnu/packages/gtk.scm | 23 ++
gnu/packages/guile-xyz.scm | 73 ++++
.../patches/guile-cairo-fix-make-check.patch | 352 ++++++++++++++++++
4 files changed, 449 insertions(+)
create mode 100644 gnu/packages/patches/guile-cairo-fix-make-check.patch


base-commit: d59a13b6401e7494d8d5c9c9f66df3318451be79
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH 1/2] gnu: Add guile-cairo-next.
(address . 76246@debbugs.gnu.org)(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)
315e4d5e141cc2cade7b65bd0b6d5ed28a41184d.1739413638.git.pelzflorian@pelzflorian.de
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>

* gnu/packages/patches/guile-cairo-fix-make-check.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register patch.
* gnu/packages/gtk.scm (guile-cairo-next): New variable.

Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
---
gnu/local.mk | 1 +
gnu/packages/gtk.scm | 23 ++
.../patches/guile-cairo-fix-make-check.patch | 352 ++++++++++++++++++
3 files changed, 376 insertions(+)
create mode 100644 gnu/packages/patches/guile-cairo-fix-make-check.patch

Toggle diff (413 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 9e192f1e4f..70cc51152f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1535,6 +1535,7 @@ dist_patch_DATA = \
%D%/packages/patches/guile-linux-syscalls.patch \
%D%/packages/patches/guile-3.0-linux-syscalls.patch \
%D%/packages/patches/guile-ac-d-bus-fix-tests.patch \
+ %D%/packages/patches/guile-cairo-fix-make-check.patch \
%D%/packages/patches/guile-lib-fix-tests-for-guile2.2.patch \
%D%/packages/patches/guile-fibers-cross-build-fix.patch \
%D%/packages/patches/guile-fibers-destroy-peer-schedulers.patch \
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 7ed7d7b7df..4d2356d8cf 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1495,6 +1496,28 @@ (define-public guile2.2-cairo
,@(fold alist-delete (package-inputs guile-cairo)
'("guile" "guile-lib"))))))
+(define-public guile-cairo-next
+ (package
+ (inherit guile-cairo)
+ (name "guile-cairo-next")
+ ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
+ ;; and needed by animated-paintable from g-golf-gtk-4-examples.
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "git://git.savannah.nongnu.org/guile-cairo.git")
+ (commit "30da459d7a4380174ff243b1560d5512a4bca86e")))
+ (sha256
+ (base32
+ "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))
+ ;; A patch to allow running the check phase before install.
+ (patches (search-patches "guile-cairo-fix-make-check.patch"))
+ (file-name (string-append "guile-cairo-next"))))
+ (inputs
+ (list guile-lib guile-3.0 gettext-minimal))
+ (native-inputs
+ (list autoconf-2.71 automake libtool pkg-config texinfo))))
+
(define-public guile-rsvg
;; Use a recent snapshot that supports Guile 2.2 and beyond.
(let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
diff --git a/gnu/packages/patches/guile-cairo-fix-make-check.patch b/gnu/packages/patches/guile-cairo-fix-make-check.patch
new file mode 100644
index 0000000000..d14de7717e
--- /dev/null
+++ b/gnu/packages/patches/guile-cairo-fix-make-check.patch
@@ -0,0 +1,352 @@
+From 1de7b5e994fd99e20849d9372963c2aadf782ed1 Mon Sep 17 00:00:00 2001
+From: David Pirotte <david@altosw.be>
+Date: Tue, 21 Mar 2023 01:54:04 -0300
+Subject: [PATCH] Fixing make check and make distcheck
+
+ Notes: the main goal of this patch is to remove the hard coded
+ libguile-cairo path, which makes it impossible to run 'make check',
+ unless you actualy first install the version you are working
+ on/checking [which is 'none sense'].
+
+ Also, even with the above problem fixed, there were still a few
+ nitpick things to solve so that make distcheck pass.
+
+ Finally, while workig on this patch, I also made a few cosmetic
+ changes, mostly adding a space before and after '=' in Makefile.am
+ targets, as well as having each filename on its own line for targets
+ that requires filenames. Those changes are not commented here below.
+
+* Makefile.am: (1) removing the env target, as we update env.in
+ this is not only not necessary anymore, but would actually
+ raise an error; (2) the CLEANFILES target misses $(GOBJECTS);
+ (3) using $(AM_V_GEN) in .scm.go target; (4) the EXTRA_DIST
+ target misses $(SOURCES), and does not need to ship autogen.sh
+ nor build-aux/git-version-gen.
+
+* cairo.scm: Call (dynamic-link "libguile-cairo"),
+ not (dynamic-link *cairo-lib-path*).
+
+* cairo/Makefile.am: (1) using $(AM_V_GEN) in .scm.go target; (2) in the
+ config.scm target, removing the @cairolibpath@ substitution; (3) the
+ EXTRA_DIST target misses vector-types.scm and $(NOCOMP_SOURCES).
+
+* cairo/config.scm.in: Removing the *cairo-lib-path* definition.
+
+* env.in: (1) define and use abs_top_srcdir and abs_top_builddir; (2)
+ define and export GUILE_LOAD_PATH, GUILE_LOAD_COMPILED_PATH and
+ LTDL_LIBRARY_PATH.
+
+* tests/unit-tests/Makefile.am: (1) add context-pointer.scm to the TESTS
+ target; (2) add a TEST_EXTENSIONS = .scm target; (3) update the
+ TESTS_ENVIRONMENT to use $(abs_top_builddir); (4) remove the %.check
+ target (unecessary in 'modern' autotools).
+---
+ Makefile.am | 26 ++++++++-----
+ cairo.scm | 4 +-
+ cairo/Makefile.am | 30 ++++++++++-----
+ cairo/config.scm.in | 8 ++--
+ env.in | 75 +++++++++++++++++++++++++++++++++---
+ tests/unit-tests/Makefile.am | 21 +++++-----
+ 6 files changed, 125 insertions(+), 39 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 82e41b2..514b758 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,5 +1,6 @@
+ # guile-cairo
+ # Copyright (C) 2007,2011 Andy Wingo <wingo@pobox.com>
++# Copyright (C) 2023 David Pirotte <david@altosw.be>
+ #
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as
+@@ -15,18 +16,20 @@
+ # License along with this program. If not, see
+ # <http://www.gnu.org/licenses/>.
+
+-SUBDIRS = guile-cairo cairo examples tests doc
+-
+-env: Makefile env.in
+- sed -e "s|@top_srcdir\@|$(shell cd $(top_srcdir) && pwd)|" \
+- $(srcdir)/env.in > env
+- chmod +x env
++SUBDIRS = \
++ guile-cairo \
++ cairo \
++ examples \
++ tests \
++ doc
+
+ BUILT_SOURCES = env
+
+ ACLOCAL_AMFLAGS = -I m4
+
+-CLEANFILES = env
++CLEANFILES = \
++ env \
++ $(GOBJECTS)
+
+ GOBJECTS = $(SOURCES:%.scm=%.go)
+
+@@ -39,7 +42,8 @@ nobase_nodist_obj_DATA = $(GOBJECTS)
+ GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
+ SUFFIXES = .scm .go
+ .scm.go:
+- $(top_builddir)/env $(GUILD) compile $(GUILE_TARGET) $(GUILE_WARNINGS) -o "$@" "$<"
++ $(AM_V_GEN) $(top_builddir)/env \
++ $(GUILD) compile $(GUILE_TARGET) $(GUILE_WARNINGS) -o "$@" "$<"
+
+ SOURCES = cairo.scm
+
+@@ -58,4 +62,8 @@ gen-ChangeLog:
+ mv $(distdir)/cl-t $(distdir)/ChangeLog; \
+ fi
+
+-EXTRA_DIST = env.in autogen.sh build-aux/git-version-gen HACKING COPYING.LESSER $(scm_DATA)
++EXTRA_DIST = \
++ env.in \
++ HACKING \
++ COPYING.LESSER \
++ $(SOURCES)
+diff --git a/cairo.scm b/cairo.scm
+index 1361d85..2cb2793 100644
+--- a/cairo.scm
++++ b/cairo.scm
+@@ -1,5 +1,6 @@
+ ;; guile-cairo
+ ;; Copyright (C) 2007, 2011 Andy Wingo <wingo at pobox dot com>
++;; Copyright (C) 2023 David Pirotte <david@altosw.be>
+
+ ;; This program is free software; you can redistribute it and/or modify
+ ;; it under the terms of the GNU Lesser General Public License as
+@@ -31,9 +32,10 @@
+ (module-use! (module-public-interface (current-module))
+ (resolve-interface '(cairo vector-types)))
+
++
+ ;; This will export many things
+ (dynamic-call "scm_init_cairo"
+- (dynamic-link *cairo-lib-path*))
++ (dynamic-link "libguile-cairo"))
+
+ (if (not (member *cairo-documentation-path* documentation-files))
+ (set! documentation-files (cons *cairo-documentation-path*
+diff --git a/cairo/Makefile.am b/cairo/Makefile.am
+index 05b5973..0299d34 100644
+--- a/cairo/Makefile.am
++++ b/cairo/Makefile.am
+@@ -1,5 +1,6 @@
+ # guile-cairo
+ # Copyright (C) 2007,2011 Andy Wingo <wingo@pobox.com>
++# Copyright (C) 2023 David Pirotte <david@altosw.be>
+ #
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as
+@@ -15,11 +16,15 @@
+ # License along with this program. If not, see
+ # <http://www.gnu.org/licenses/>.
+
+-moddir=$(datadir)/guile/site/$(GUILE_EFFECTIVE_VERSION)/cairo
+-objdir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache/cairo
++moddir = $(datadir)/guile/site/$(GUILE_EFFECTIVE_VERSION)/cairo
++objdir = $(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache/cairo
+
+-SOURCES = config.scm vector-types.scm
+-NOCOMP_SOURCES = cairo-procedures.txt
++SOURCES = \
++ config.scm \
++ vector-types.scm
++
++NOCOMP_SOURCES = \
++ cairo-procedures.txt
+
+ GOBJECTS = $(SOURCES:%.scm=%.go)
+
+@@ -29,12 +34,12 @@ nobase_nodist_obj_DATA = $(GOBJECTS)
+ GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
+ SUFFIXES = .scm .go
+ .scm.go:
+- $(top_builddir)/env $(GUILD) compile $(GUILE_TARGET) $(GUILE_WARNINGS) -o "$@" "$<"
++ $(AM_V_GEN) $(top_builddir)/env \
++ $(GUILD) compile $(GUILE_TARGET) $(GUILE_WARNINGS) -o "$@" "$<"
+
+ config.scm: Makefile config.scm.in
+- sed -e "s|@cairolibpath\@|$(libdir)/libguile-cairo|" \
+- -e "s|@cairodocumentationpath\@|$(moddir)/cairo-procedures.txt|" \
+- $(srcdir)/config.scm.in > config.scm
++ sed -e "s|\@cairodocumentationpath\@|$(moddir)/cairo-procedures.txt|" \
++ $(srcdir)/config.scm.in > config.scm
+
+ cairo-procedures.txt.update:
+ echo "Generated from upstream documentation; see COPYING.docs for info." \
+@@ -42,6 +47,11 @@ cairo-procedures.txt.update:
+ $(top_srcdir)/doc/docbook-to-guile-doc $(CAIRO_XML_DIR)/*.xml \
+ >> $(srcdir)/cairo-procedures.txt
+
+-CLEANFILES = config.scm $(GOBJECTS)
++CLEANFILES = \
++ config.scm \
++ $(GOBJECTS)
+
+-EXTRA_DIST = config.scm.in
++EXTRA_DIST = \
++ config.scm.in \
++ vector-types.scm \
++ $(NOCOMP_SOURCES)
+diff --git a/cairo/config.scm.in b/cairo/config.scm.in
+index ab008fb..92895b9 100644
+--- a/cairo/config.scm.in
++++ b/cairo/config.scm.in
+@@ -1,5 +1,6 @@
+ ;; guile-cairo
+ ;; Copyright (C) 2007, 2011 Andy Wingo <wingo pobox.com>
++;; Copyright (C) 2023 David Pirotte <david@altosw.be>
+
+ ;; This program is free software; you can redistribute it and/or modify
+ ;; it under the terms of the GNU Lesser General Public License as
+@@ -22,8 +23,7 @@
+ ;;; Code:
+
+ (define-module (cairo config)
+- :export (*cairo-lib-path*
+- *cairo-documentation-path*))
++ :export (*cairo-documentation-path*))
+
+-(define *cairo-lib-path* "@cairolibpath@")
+-(define *cairo-documentation-path* "@cairodocumentationpath@")
++(define *cairo-documentation-path*
++ "@cairodocumentationpath@")
+diff --git a/env.in b/env.in
+index eb9d020..e93d212 100644
+--- a/env.in
++++ b/env.in
+@@ -2,6 +2,7 @@
+
+ # guile-cairo
+ # Copyright (C) 2007,2011 Andy Wingo <wingo@pobox.com>
++# Copyright (C) 2023 David Pirotte <david@altosw.be>
+ #
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as
+@@ -17,15 +18,77 @@
+ # License along with this program. If not, see
+ # <http://www.gnu.org/licenses/>.
+
+-this_dir=$(cd $(dirname $0) && pwd)
+-src_dir="@top_srcdir@"
+
+-if [ "$src_dir" != "$this_dir" ]; then
+- GUILE_LOAD_PATH=$src_dir/$pkg:$this_dir/$pkg:$GUILE_LOAD_PATH
++abs_top_srcdir="@abs_top_srcdir@"
++abs_top_builddir="@abs_top_builddir@"
++
++[ x"$abs_top_srcdir" = x -o ! -d "$abs_top_srcdir" -o \
++ x"$abs_top_builddir" = x -o ! -d "$abs_top_builddir" ] && {
++ echo $0: bad environment
++ echo abs_top_srcdir=$abs_top_srcdir
++ echo abs_top_builddir=$abs_top_builddir
++ exit 1
++}
++
++
++###
++### GUILE_LOAD_PATH
++###
++
++if [ x"$GUILE_LOAD_PATH" = x ]
++then
++ GUILE_LOAD_PATH="${abs_top_srcdir}"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ GUILE_LOAD_PATH="${abs_top_builddir}:$GUILE_LOAD_PATH"
++ fi
+ else
+- GUILE_LOAD_PATH=$this_dir/$pkg:$GUILE_LOAD_PATH
++ GUILE_LOAD_PATH="${abs_top_srcdir}:$GUILE_LOAD_PATH"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ GUILE_LOAD_PATH="${abs_top_builddir}:$GUILE_LOAD_PATH"
++ fi
+ fi
+-
++## echo $GUILE_LOAD_PATH
+ export GUILE_LOAD_PATH
+
++
++###
++### GUILE_LOAD_COMPILED_PATH
++###
++
++if [ x"$GUILE_LOAD_COMPILED_PATH" = x ]
++then
++ GUILE_LOAD_COMPILED_PATH="${abs_top_srcdir}"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ GUILE_LOAD_COMPILED_PATH="${abs_top_builddir}:$GUILE_LOAD_COMPILED_PATH"
++ fi
++else
++ GUILE_LOAD_COMPILED_PATH="${abs_top_srcdir}:$GUILE_LOAD_COMPILED_PATH"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ GUILE_LOAD_COMPILED_PATH="${abs_top_builddir}:$GUILE_LOAD_COMPILED_PATH"
++ fi
++fi
++
++## echo $GUILE_LOAD_COMPILED_PATH
++export GUILE_LOAD_COMPILED_PATH
++
++
++###
++### LTDL_LIBRARY_PATH
++###
++
++if [ x"$LTDL_LIBRARY_PATH" = x ]
++then
++ LTDL_LIBRARY_PATH="${abs_top_srcdir}/guile-cairo:${abs_top_srcdir}/guile-cairo/.libs"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ LTDL_LIBRARY_PATH="${abs_top_builddir}/guile-cairo:${abs_top_builddir}/guile-cairo/.libs:$LTDL_LIBRARY_PATH"
++ fi
++else
++ LTDL_LIBRARY_PATH="${abs_top_srcdir}/guile-cairo:${abs_top_srcdir}/guile-cairo/.libs:$LTDL_LIBRARY_PATH"
++ if test "${abs_top_srcdir}" != "${abs_top_builddir}"; then
++ LTDL_LIBRARY_PATH="${abs_top_builddir}/guile-cairo:${abs_top_builddir}/guile-cairo/.libs:$LTDL_LIBRARY_PATH"
++ fi
++fi
++## echo $LTDL_LIBRARY_PATH
++export LTDL_LIBRARY_PATH
++
+ exec "$@"
+diff --git a/tests/unit-tests/Makefile.am b/tests/unit-tests/Makefile.am
+index 3ba6af9..9b13bbd 100644
+--- a/tests/unit-tests/Makefile.am
++++ b/tests/unit-tests/Makefile.am
+@@ -16,18 +16,21 @@
+ # License along with this program. If not, see
+ # <http://www.gnu.org/licenses/>.
+
+-TESTS= \
+- context-pointer.scm \
++TESTS = \
+ api-stability.scm \
++ context-pointer.scm \
+ version.scm
+
+-TESTS_ENVIRONMENT=\
+- API_FILE=$(srcdir)/cairo.api $(top_builddir)/env guile -s
++TEST_EXTENSIONS = .scm
+
+-%.api.update:
+- $(top_builddir)/env $(srcdir)/update-api $(subst ., ,$*) > $(srcdir)/$*.api
++TESTS_ENVIRONMENT = \
++ API_FILE=$(srcdir)/cairo.api \
++ $(abs_top_builddir)/env $(GUILE) --no-auto-compile
+
+-%.check: %
+- $(TESTS_ENVIRONMENT) $*
++%.api.update:
++ $(abs_top_builddir)/env \
++ $(srcdir)/update-api $(subst ., ,$*) > $(srcdir)/$*.api
+
+-EXTRA_DIST=$(TESTS) cairo.api
++EXTRA_DIST = \
++ $(TESTS) \
++ cairo.api
+--
+2.39.2
+
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH 2/2] UNFINISHED gnu: Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)
3e44e34b7a32f6c1adad22ab36c303e93226f320.1739413638.git.pelzflorian@pelzflorian.de
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>

* gnu/packages/guile-xyz.scm (g-golf-gtk-4-examples): New variable.

Change-Id: I19b182eb71095ca2deacdb4011c8f50dfcfc8476
---
gnu/packages/guile-xyz.scm | 73 ++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)

Toggle diff (93 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 92d5d90194..520d1b9f87 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -53,6 +53,7 @@
;;; Copyright © 2024 Alec Barreto <mrh57@posteo.net>
;;; Copyright © 2024 Josep Bigorra <jjbigorra@gmail.com>
;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2618,6 +2619,78 @@ (define-public guile2.2-g-golf
(replace "guile" guile-2.2)
(replace "guile-lib" guile2.2-lib)))))
+(define-public g-golf-gtk-4-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-gtk-4-examples")
+ (arguments
+ (list
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ ,@%default-gnu-modules)
+ #:tests? #f ;there are no tests for examples
+ ;; XXX: Maybe Guix should ship a reftest on its own?
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/gtk-4")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)
+ for f in $(EXTRA_DIST); do \\
+ install $$f $(bindir); \\
+ done
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;only executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ ;; The `current-filename' calls in examples are broken.
+ (system* "sed" "-i" "s/(add-to-load-path.*//g" binary)
+ ;;TODO DOES NOT WORK (substitute* binary
+ ;; (("add-to-load-path.*")
+ ;; "")) DOES NOT WORK NEITHER
+ (wrap-program (string-append #$output "/bin/" binary)
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)
+ ));,(string-append #$output "/bin"))) ;not nice,
+ ; ;but better than `add-to-load-path'
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))))
+ binaries))))))))
+ (inputs
+ (list bash-minimal gtk guile-3.0 guile-cairo-next guile-g-golf))
+ (native-inputs (list))
+ (propagated-inputs (list))
+ (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.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Liliana Marie Prikler wrote 1 months ago
Re: [bug#76246] [PATCH 1/2] gnu: Add guile-cairo-next.
(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)(address . 76246@debbugs.gnu.org)(name . Vivien Kraus)(address . vivien@planete-kraus.eu)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
32a050da05dc90d4e69d0c8419e6372c97bfca86.camel@gmail.com
Am Donnerstag, dem 13.02.2025 um 03:55 +0100 schrieb Florian Pelz:
Toggle quote (69 lines)
> From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
>
> * gnu/packages/patches/guile-cairo-fix-make-check.patch: New patch.
> * gnu/local.mk (dist_patch_DATA): Register patch.
> * gnu/packages/gtk.scm (guile-cairo-next): New variable.
>
> Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
> ---
>  gnu/local.mk                                  |   1 +
>  gnu/packages/gtk.scm                          |  23 ++
>  .../patches/guile-cairo-fix-make-check.patch  | 352
> ++++++++++++++++++
>  3 files changed, 376 insertions(+)
>  create mode 100644 gnu/packages/patches/guile-cairo-fix-make-
> check.patch
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 9e192f1e4f..70cc51152f 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1535,6 +1535,7 @@ dist_patch_DATA
> =                                         \
>    %D%/packages/patches/guile-linux-syscalls.patch              \
>    %D%/packages/patches/guile-3.0-linux-syscalls.patch          \
>    %D%/packages/patches/guile-ac-d-bus-fix-tests.patch          \
> +  %D%/packages/patches/guile-cairo-fix-make-check.patch        \
>    %D%/packages/patches/guile-lib-fix-tests-for-
> guile2.2.patch          \
>    %D%/packages/patches/guile-fibers-cross-build-fix.patch      \
>    %D%/packages/patches/guile-fibers-destroy-peer-schedulers.patch \
> diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
> index 7ed7d7b7df..4d2356d8cf 100644
> --- a/gnu/packages/gtk.scm
> +++ b/gnu/packages/gtk.scm
> @@ -37,6 +37,7 @@
>  ;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
>  ;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
>  ;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
> +;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -1495,6 +1496,28 @@ (define-public guile2.2-cairo
>         ,@(fold alist-delete (package-inputs guile-cairo)
>                 '("guile" "guile-lib"))))))
>  
> +(define-public guile-cairo-next
> +  (package
> +    (inherit guile-cairo)
> +    (name "guile-cairo-next")
> +    ;; A commit with cairo-pointer->context, missing from
> guile-cairo@1.11.2
> +    ;; and needed by animated-paintable from g-golf-gtk-4-examples.
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "git://git.savannah.nongnu.org/guile-
> cairo.git")
> +                    (commit
> "30da459d7a4380174ff243b1560d5512a4bca86e")))
> +              (sha256
> +               (base32
> +               
> "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))
> +              ;; A patch to allow running the check phase before
> install.
> +              (patches (search-patches "guile-cairo-fix-make-
> check.patch"))
> +              (file-name (string-append "guile-cairo-next"))))
You probably want git-file-name.
Toggle quote (4 lines)
> +    (inputs
> +     (list guile-lib guile-3.0 gettext-minimal))
> +    (native-inputs
> +     (list autoconf-2.71 automake libtool pkg-config texinfo))))
Is there a reason for changed inputs? Does plain autoconf not work?

Toggle quote (63 lines)
> +
>  (define-public guile-rsvg
>    ;; Use a recent snapshot that supports Guile 2.2 and beyond.
>    (let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
> diff --git a/gnu/packages/patches/guile-cairo-fix-make-check.patch
> b/gnu/packages/patches/guile-cairo-fix-make-check.patch
> new file mode 100644
> index 0000000000..d14de7717e
> --- /dev/null
> +++ b/gnu/packages/patches/guile-cairo-fix-make-check.patch
> @@ -0,0 +1,352 @@
> +From 1de7b5e994fd99e20849d9372963c2aadf782ed1 Mon Sep 17 00:00:00
> 2001
> +From: David Pirotte <david@altosw.be>
> +Date: Tue, 21 Mar 2023 01:54:04 -0300
> +Subject: [PATCH] Fixing make check and make distcheck
> +
> +  Notes: the main goal of this patch is to remove the hard coded
> +  libguile-cairo path, which makes it impossible to run 'make
> check',
> +  unless you actualy first install the version you are working
> +  on/checking [which is 'none sense'].
> +
> +  Also, even with the above problem fixed, there were still a few
> +  nitpick things to solve so that make distcheck pass.
> +
> +  Finally, while workig on this patch, I also made a few cosmetic
> +  changes, mostly adding a space before and after '=' in Makefile.am
> +  targets, as well as having each filename on its own line for
> targets
> +  that requires filenames. Those changes are not commented here
> below.
> +
> +* Makefile.am: (1) removing the env target, as we update env.in
> +  this is not only not necessary anymore, but would actually
> +  raise an error; (2) the CLEANFILES target misses $(GOBJECTS);
> +  (3) using $(AM_V_GEN) in .scm.go target; (4) the EXTRA_DIST
> +  target misses $(SOURCES), and does not need to ship autogen.sh
> +  nor build-aux/git-version-gen.
> +
> +* cairo.scm: Call (dynamic-link "libguile-cairo"),
> +  not (dynamic-link *cairo-lib-path*).
> +
> +* cairo/Makefile.am: (1) using $(AM_V_GEN) in .scm.go target; (2) in
> the
> +  config.scm target, removing the @cairolibpath@ substitution; (3)
> the
> +  EXTRA_DIST target misses vector-types.scm and $(NOCOMP_SOURCES).
> +
> +* cairo/config.scm.in: Removing the *cairo-lib-path* definition.
> +
> +* env.in: (1) define and use abs_top_srcdir and abs_top_builddir;
> (2)
> +  define and export GUILE_LOAD_PATH, GUILE_LOAD_COMPILED_PATH and
> +  LTDL_LIBRARY_PATH.
> +
> +* tests/unit-tests/Makefile.am: (1) add context-pointer.scm to the
> TESTS
> +  target; (2) add a TEST_EXTENSIONS = .scm target; (3) update the
> +  TESTS_ENVIRONMENT to use $(abs_top_builddir); (4) remove the
> %.check
> +  target (unecessary in 'modern' autotools).
> +---
Is this an upstreamed patch? There are too many cosmetic changes (of
dubious quality) mixed with actual code changes for my personal liking.

Cheers
Maxim Cournoyer wrote 1 months ago
(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)(name . Vivien Kraus)(address . vivien@planete-kraus.eu)(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 76246@debbugs.gnu.org)
87wmdub51h.fsf@gmail.com
Hi,

Florian Pelz <pelzflorian@pelzflorian.de> writes:

Toggle quote (6 lines)
> From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
>
> * gnu/packages/patches/guile-cairo-fix-make-check.patch: New patch.
> * gnu/local.mk (dist_patch_DATA): Register patch.
> * gnu/packages/gtk.scm (guile-cairo-next): New variable.

[...]

Toggle quote (5 lines)
> +(define-public guile-cairo-next
> + (package
> + (inherit guile-cairo)
> + (name "guile-cairo-next")

Typicall when using a specific commit, we let-bind REVISION and COMMIT
variables, so that any reworked package can have revision bumped (I
think that's useful to select the latest version in case multiple
same-named packages exist?).

The version would be computed via

Toggle snippet (3 lines)
(version (git-version "last-release-version-string" revision commit))

Toggle quote (14 lines)
> + ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
> + ;; and needed by animated-paintable from g-golf-gtk-4-examples.
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "git://git.savannah.nongnu.org/guile-cairo.git")
> + (commit "30da459d7a4380174ff243b1560d5512a4bca86e")))
> + (sha256
> + (base32
> + "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))
> + ;; A patch to allow running the check phase before install.
> + (patches (search-patches "guile-cairo-fix-make-check.patch"))
> + (file-name (string-append "guile-cairo-next"))))

There's also a git-file-name helper to compute file-name. If you use
Emacs + yasnippet, you should be able to do:

origin...TAB

to have it expanded into the idiomatic form.

Toggle quote (3 lines)
> + (inputs
> + (list guile-lib guile-3.0 gettext-minimal))

Please sort lexicographically.

The rest LGTM.

--
Thanks,
Maxim
Florian Pelz wrote 1 months ago
[PATCH 0/5] Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
cover.1739748248.git.pelzflorian@pelzflorian.de
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

* 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.

Toggle quote (3 lines)
> (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”.

Toggle quote (5 lines)
> (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 libadwaita@1.6.0. The
master branch is at libadwaita@1.5.2. 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.


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
Florian Pelz wrote 1 months ago
[PATCH 1/5] gnu: guile-cairo: Remove expat from inputs.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ef3b2b2e54ee7a8d6c5562c747c5824b95cad0cb.1739749706.git.pelzflorian@pelzflorian.de
expat is not needed by guile-cairo nor guile2.2-cairo.

* gnu/packages/gtk.scm (guile-cairo)[inputs]: Remove expat.

Change-Id: Ie8f2c35c52725326cc8f103c45125e4378d29793
---
gnu/packages/gtk.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 011a1db687..8e893d66c3 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -1454,7 +1454,7 @@ (define-public guile-cairo
(find-files module-dir "\\.scm$"))
#t))))))
(inputs
- (list guile-lib expat guile-3.0))
+ (list guile-lib guile-3.0))
(propagated-inputs
;; The .pc file refers to 'cairo'.
(list cairo))

base-commit: 5e3e1b782b87d5bfe903f978490955cc20a70e5a
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH 2/5] gnu: Add guile-cairo-next.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
565889c10a90c95361aa0b4a58751b710bda207b.1739749706.git.pelzflorian@pelzflorian.de
* gnu/packages/gtk.scm (guile-cairo-next): New variable.

Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
---
gnu/packages/gtk.scm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

Toggle diff (60 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 8e893d66c3..2698fdb1c7 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1481,6 +1482,45 @@ (define-public guile2.2-cairo
,@(fold alist-delete (package-inputs guile-cairo)
'("guile" "guile-lib"))))))
+(define-public guile-cairo-next
+ ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
+ ;; and needed by animated-paintable from g-golf-gtk-4-examples.
+ (let ((commit "30da459d7a4380174ff243b1560d5512a4bca86e")
+ (revision "0"))
+ (package
+ (inherit guile-cairo)
+ (name "guile-cairo-next")
+ (version (git-version "1.11.2" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "git://git.savannah.nongnu.org/guile-cairo.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))))
+ ;; To allow running the check phase before install, use a libtool path
+ ;; similar to David Pirotte's suggested patch
+ ;; <https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html>.
+ (arguments
+ (substitute-keyword-arguments (package-arguments guile-cairo)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'build 'fix-dynamic-link-path
+ (lambda _
+ ;; Make libguile-cairo foreign extension usable in tests.
+ (substitute* "cairo/config.scm"
+ (("\\(define \\*cairo-lib-path\\* .*")
+ "\(define *cairo-lib-path* \"libguile-cairo\")\n"))))
+ (add-before 'check 'set-libtool-path
+ (lambda _
+ (setenv "LTDL_LIBRARY_PATH" "../../guile-cairo/.libs")))))))
+ (inputs
+ (list gettext-minimal guile-3.0 guile-lib))
+ (native-inputs
+ (list autoconf automake libtool pkg-config texinfo)))))
+
(define-public guile-rsvg
;; Use a recent snapshot that supports Guile 2.2 and beyond.
(let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH 3/5] gnu: guile-g-golf: Document --no-grafts requirement.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ede7bc546e491a7e0b8f6bcd9c6cc4f8da1236ac.1739749706.git.pelzflorian@pelzflorian.de
Note that packages are unaffected.

* gnu/packages/guile-xyz.scm: Tell about grafts bug.

Change-Id: Ic0b2c63daa07c693171965d90410aef5a2e41d49
---
gnu/packages/guile-xyz.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (20 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 921d8b46d6..9877e01748 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2603,7 +2603,12 @@ (define-public guile-g-golf
modern applications in Guile Scheme. It comprises a direct binding to the
GObject Introspection API and higher-level functionality for importing Gnome
libraries and making GObject classes (and methods) available in Guile's
-object-oriented programming system, GOOPS.")
+object-oriented programming system, GOOPS.
+
+Note: Currently, when developing with G-Golf in @code{guix shell}, there is a
+@uref{https://bugs.gnu.org/75157, grafts bug in Guix}. To avoid it, use Guix'
+@code{--no-grafts} option. Guix packages that use @code{wrap-program} are
+unaffected.")
(license license:lgpl3+)))
(define-public g-golf
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH 4/5] gnu: Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
9b62b633066ceb34b6ceed7534fa6527171dc50c.1739749706.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-gtk-4-examples): New variable.

Change-Id: I19b182eb71095ca2deacdb4011c8f50dfcfc8476
---
gnu/packages/guile-xyz.scm | 182 ++++++++++++++++++++++++++++++++++++-
1 file changed, 181 insertions(+), 1 deletion(-)

Toggle diff (206 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 9877e01748..7ca6a1bd75 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -1,4 +1,4 @@
-;;; GNU Guix --- Functional package management for GNU
+;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015, 2017, 2022 Christine Lemmer-Webber <cwebber@dustycloud.org>
@@ -53,6 +53,7 @@
;;; Copyright © 2024 Alec Barreto <mrh57@posteo.net>
;;; Copyright © 2024 Josep Bigorra <jjbigorra@gmail.com>
;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2623,6 +2624,185 @@ (define-public guile2.2-g-golf
(replace "guile" guile-2.2)
(replace "guile-lib" guile2.2-lib)))))
+(define-public g-golf-gtk-4-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-gtk-4-examples")
+ (arguments
+ (list
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/gtk-4")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/css
+ mkdir -p $(bindir)/demos
+ mkdir -p $(bindir)/images
+ mkdir -p $(bindir)/ui
+ for f in $(EXTRA_DIST); do \\
+ cp $$f $(bindir)/$$f; \\
+ done
+ install demos/libfpt.so $(bindir)/demos
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; The layout-manager-2 example calls `make', GCC at run-time.
+ ;; But since it would compile to the read-only /gnu/store, we
+ ;; deviate by compiling in advance in the build phase,
+ ;; ignoring failing `make' calls. We do not propagate `make'.
+ (with-directory-excursion "demos"
+ (when #$(%current-target-system)
+ (substitute* "Makefile"
+ (("^CC = gcc$")
+ (string-append "CC = " #$(cc-for-target) "\n"))))
+ (system* "make"))))
+ ;; There are no tests for examples, but we do an installcheck phase,
+ ;; which respects when #:tests? is turned off. So delete 'check.
+ (delete 'check)
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("\\(getcwd\\)")
+ (string-append "\"" #$output "/bin\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (gcairo (assoc-ref inputs "guile-cairo-next"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)
+ ,(string-append gcairo scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)
+ ,(string-append gcairo go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ ;; Library path for libraries loaded by binaries.
+ `("LD_LIBRARY_PATH" prefix
+ (,(string-append gcairo "/lib")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append adwaita-icons "/share"))))))
+ binaries))))
+ ;; Add installcheck to ensure nothing breaks.
+ (add-after 'strip 'installcheck
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (cond
+ ((not tests?)
+ (display "test suite not run\n"))
+ (#$(%current-target-system)
+ (display "cross-compiling; reftest skipped\n"))
+ (else
+ ;; Start an X server.
+ (system "Xvfb :1 &")
+ (setenv "DISPLAY" ":1")
+ (let* ((g-golf-drawing (string-append
+ #$output "/bin/drawing-widget"))
+ (pid (spawn g-golf-drawing `(,g-golf-drawing)
+ #:search-path? #f)))
+ (sleep 10) ;2s is enough on my machine
+ (display "Taking a screenshot with G-Golf.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.out.png")
+ (sleep 5) ;1s is enough on my machine
+ (kill pid SIGINT)
+ (waitpid pid))
+ (let* ((python (search-input-file inputs "/bin/python3"))
+ (pygobject-drawing #$(this-package-native-input
+ "drawing-widget.py"))
+ (pid (spawn python `(,python ,pygobject-drawing)
+ #:search-path? #f)))
+ (sleep 5) ;1s is enough on my machine
+ (display "Taking a screenshot with Pygobject.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.ref.png")
+ (sleep 5)
+ (kill pid SIGINT)
+ (waitpid pid))
+ (if (= (pk (system* "compare" "-metric" "AE" "-fuzz" "1%"
+ "drawing-widget.out.png"
+ "drawing-widget.ref.png"
+ "drawing-widget.dif.png")) 0)
+ (display "All good; they look the same.\n")
+ (error "Reftest failed; screenshots differ."))))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ gtk
+ guile-3.0
+ guile-cairo-next
+ guile-g-golf))
+ (native-inputs
+ (list pkg-config
+ which
+ ;; For installcheck:
+ imagemagick
+ python-minimal
+ python-pygobject
+ xorg-server-for-tests
+ ;; Python version of drawing-widget from
+ ;; https://lists.gnu.org/archive/html/guile-user/2024-05/msg00032.html
+ (origin
+ (method url-fetch)
+ (uri "\
+https://lists.gnu.org/archive/html/guile-user/2024-05/txtT_80XuINsX.txt")
+ (sha256
+ (base32
+ "07j2v159a3bb99i8kwbqrcgslcmhhnqa5ah53q2b9bdk8042grsx"))
+ (file-name "drawing-widget.py"))))
+ (propagated-inputs (list))
+ (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.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v2 5/5] gnu: Add G-Golf's Adw-1 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ce4e15bdcd5d641683663ab68027305090a6e9ac.1739749706.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-adw-1-examples): New variable.

Change-Id: I160e58ceaeb4867f9b21a0a32f198113e36b5c88
---
gnu/packages/guile-xyz.scm | 125 +++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)

Toggle diff (138 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 7ca6a1bd75..1ceb25be7d 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2803,6 +2803,131 @@ (define-public g-golf-gtk-4-examples
the @code{gtk:bin} Guix package output. They also show how to wrap G-Golf
applications in a Guix package.")))
+(define-public g-golf-adw-1-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-adw-1-examples")
+ (build-system glib-or-gtk-build-system)
+ (arguments
+ (list
+ #:tests? #f ;there are no tests for examples
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (guix build glib-or-gtk-build-system)
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/adw-1")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ (substitute* "Makefile"
+ ;; Fix syntax error.
+ (("hello-world")
+ "hello-world \\"))
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/demo/icons
+ mkdir -p $(bindir)/demo/pages
+ for f in $(EXTRA_DIST); do \\
+ cp -r $$f $(bindir)/$$f; \\
+ done
+ cp demo/g-resources $(bindir)/demo/g-resources
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; Create files for adwaita-1-demo needed in install phase.
+ (with-directory-excursion "demo"
+ (system* "make")
+ (system* "glib-compile-resources"
+ "--target" "g-resources"
+ "g-resources.xml"))))
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (libadwaita-icons (assoc-ref inputs "libadwaita"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ `("GUIX_GDK_PIXBUF_MODULE_FILES" suffix
+ (,(getenv "GUIX_GDK_PIXBUF_MODULE_FILES")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append #$output "/bin/demo")
+ ,(string-append adwaita-icons "/share")
+ ,(string-append libadwaita-icons "/share"))))))
+ binaries))))
+ (add-after 'wrap-binaries 'move-binaries
+ (lambda _
+ ;; Move the adwaita-1-demo wrapper to place it directly in /bin.
+ (rename-file (string-append
+ #$output "/bin/demo/adwaita-1-demo")
+ (string-append
+ #$output "/bin/adwaita-1-demo"))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ libadwaita
+ (librsvg-for-system)
+ gtk
+ guile-3.0
+ guile-g-golf))
+ (native-inputs (list `(,glib "bin") ;for glib-compile-resources
+ guile-3.0))
+ (propagated-inputs (list))
+ (synopsis "Example Adwaita 1 apps written in Guile with G-Golf")
+ (description
+ "G-Golf port of (a subset of) the upstream @code{adwaita-1-demo} examples
+in the @code{libadwaita} Guix package. They also show how to wrap G-Golf
+applications in a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
pelzflorian (Florian Pelz) wrote 1 months ago
Re: [PATCH v2 0/5] Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)
87h64te8pp.fsf@pelzflorian.de
Sorry I forgot to write revision v2 in [PATCH v2 x/5] subject
lines... Argh!
Maxim Cournoyer wrote 1 months ago
Re: [bug#76246] [PATCH 2/5] gnu: Add guile-cairo-next.
(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)(name . Vivien Kraus)(address . vivien@planete-kraus.eu)(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 76246@debbugs.gnu.org)
87tt8t1hdv.fsf@gmail.com
Hi,

Florian Pelz <pelzflorian@pelzflorian.de> writes:

Toggle quote (2 lines)
> * gnu/packages/gtk.scm (guile-cairo-next): New variable.

[...]

Toggle quote (14 lines)
> +(define-public guile-cairo-next
> + ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
> + ;; and needed by animated-paintable from g-golf-gtk-4-examples.
> + (let ((commit "30da459d7a4380174ff243b1560d5512a4bca86e")
> + (revision "0"))
> + (package
> + (inherit guile-cairo)
> + (name "guile-cairo-next")
> + (version (git-version "1.11.2" revision commit))
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "git://git.savannah.nongnu.org/guile-cairo.git")

Prefer https://to git://, for privacy and the extra authenticity check.

Toggle quote (9 lines)
> + (commit commit)))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))))
> + ;; To allow running the check phase before install, use a libtool path
> + ;; similar to David Pirotte's suggested patch
> + ;; <https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html>.

This comment should be nested inside the set-libtool-path phase, which
is the one it relates to.

Toggle quote (18 lines)
> + (arguments
> + (substitute-keyword-arguments (package-arguments guile-cairo)
> + ((#:phases phases)
> + `(modify-phases ,phases
> + (add-after 'build 'fix-dynamic-link-path
> + (lambda _
> + ;; Make libguile-cairo foreign extension usable in tests.
> + (substitute* "cairo/config.scm"
> + (("\\(define \\*cairo-lib-path\\* .*")
> + "\(define *cairo-lib-path* \"libguile-cairo\")\n"))))
> + (add-before 'check 'set-libtool-path
> + (lambda _
> + (setenv "LTDL_LIBRARY_PATH" "../../guile-cairo/.libs")))))))
> + (inputs
> + (list gettext-minimal guile-3.0 guile-lib))
> + (native-inputs
> + (list autoconf automake libtool pkg-config texinfo)))))

Otherwise, it LGTM.

Could you please send a new revision?

--
Thanks,
Maxim
Florian Pelz wrote 1 months ago
[PATCH v3 0/5] Add G-Golf’s GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
cover.1739785883.git.pelzflorian@pelzflorian.de
In v3, changes are only in
[PATCH v3 2/5] gnu: Add guile-cairo-next.
to use an https URL for privacy and improve comments,
in response to Maxim.

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 | 44 +++++-
gnu/packages/guile-xyz.scm | 314 ++++++++++++++++++++++++++++++++++++-
2 files changed, 355 insertions(+), 3 deletions(-)


base-commit: 5e3e1b782b87d5bfe903f978490955cc20a70e5a
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v3 1/5] gnu: guile-cairo: Remove expat from inputs.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ef3b2b2e54ee7a8d6c5562c747c5824b95cad0cb.1739785883.git.pelzflorian@pelzflorian.de
expat is not needed by guile-cairo nor guile2.2-cairo.

* gnu/packages/gtk.scm (guile-cairo)[inputs]: Remove expat.

Change-Id: Ie8f2c35c52725326cc8f103c45125e4378d29793
---
gnu/packages/gtk.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 011a1db687..8e893d66c3 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -1454,7 +1454,7 @@ (define-public guile-cairo
(find-files module-dir "\\.scm$"))
#t))))))
(inputs
- (list guile-lib expat guile-3.0))
+ (list guile-lib guile-3.0))
(propagated-inputs
;; The .pc file refers to 'cairo'.
(list cairo))
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v3 2/5] gnu: Add guile-cairo-next.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ff938c049e25a090e06a52ef79bd14751f494f32.1739785883.git.pelzflorian@pelzflorian.de
* gnu/packages/gtk.scm (guile-cairo-next): New variable.

Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
---
gnu/packages/gtk.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 8e893d66c3..ba515b84ec 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1481,6 +1482,47 @@ (define-public guile2.2-cairo
,@(fold alist-delete (package-inputs guile-cairo)
'("guile" "guile-lib"))))))
+(define-public guile-cairo-next
+ ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
+ ;; and needed by animated-paintable from g-golf-gtk-4-examples.
+ (let ((commit "30da459d7a4380174ff243b1560d5512a4bca86e")
+ (revision "0"))
+ (package
+ (inherit guile-cairo)
+ (name "guile-cairo-next")
+ (version (git-version "1.11.2" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.savannah.gnu.org/git/guile-cairo.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments guile-cairo)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; To allow running the check phase before install, add two phases
+ ;; similar to David Pirotte's suggested patch:
+ ;; <https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html>.
+ (add-after 'build 'fix-dynamic-link-path
+ (lambda _
+ ;; Dynamic-link libguile-cairo foreign extension by name, not
+ ;; path.
+ (substitute* "cairo/config.scm"
+ (("\\(define \\*cairo-lib-path\\* .*")
+ "\(define *cairo-lib-path* \"libguile-cairo\")\n"))))
+ (add-before 'check 'set-libtool-path
+ (lambda _
+ ;; Use appropriate pre-install libtool path in tests.
+ (setenv "LTDL_LIBRARY_PATH" "../../guile-cairo/.libs")))))))
+ (inputs
+ (list gettext-minimal guile-3.0 guile-lib))
+ (native-inputs
+ (list autoconf automake libtool pkg-config texinfo)))))
+
(define-public guile-rsvg
;; Use a recent snapshot that supports Guile 2.2 and beyond.
(let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v3 3/5] gnu: guile-g-golf: Document --no-grafts requirement.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
a7b66e6a5d7bfc91d85e04025c5dd755a9bb79df.1739785883.git.pelzflorian@pelzflorian.de
Note that packages are unaffected.

* gnu/packages/guile-xyz.scm: Tell about grafts bug.

Change-Id: Ic0b2c63daa07c693171965d90410aef5a2e41d49
---
gnu/packages/guile-xyz.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (20 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 921d8b46d6..9877e01748 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2603,7 +2603,12 @@ (define-public guile-g-golf
modern applications in Guile Scheme. It comprises a direct binding to the
GObject Introspection API and higher-level functionality for importing Gnome
libraries and making GObject classes (and methods) available in Guile's
-object-oriented programming system, GOOPS.")
+object-oriented programming system, GOOPS.
+
+Note: Currently, when developing with G-Golf in @code{guix shell}, there is a
+@uref{https://bugs.gnu.org/75157, grafts bug in Guix}. To avoid it, use Guix'
+@code{--no-grafts} option. Guix packages that use @code{wrap-program} are
+unaffected.")
(license license:lgpl3+)))
(define-public g-golf
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v3 4/5] gnu: Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
fed0ab3b675f6059faf737bb0fefe26c5a3fd6e3.1739785883.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-gtk-4-examples): New variable.

Change-Id: I19b182eb71095ca2deacdb4011c8f50dfcfc8476
---
gnu/packages/guile-xyz.scm | 182 ++++++++++++++++++++++++++++++++++++-
1 file changed, 181 insertions(+), 1 deletion(-)

Toggle diff (206 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 9877e01748..7ca6a1bd75 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -1,4 +1,4 @@
-;;; GNU Guix --- Functional package management for GNU
+;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015, 2017, 2022 Christine Lemmer-Webber <cwebber@dustycloud.org>
@@ -53,6 +53,7 @@
;;; Copyright © 2024 Alec Barreto <mrh57@posteo.net>
;;; Copyright © 2024 Josep Bigorra <jjbigorra@gmail.com>
;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2623,6 +2624,185 @@ (define-public guile2.2-g-golf
(replace "guile" guile-2.2)
(replace "guile-lib" guile2.2-lib)))))
+(define-public g-golf-gtk-4-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-gtk-4-examples")
+ (arguments
+ (list
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/gtk-4")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/css
+ mkdir -p $(bindir)/demos
+ mkdir -p $(bindir)/images
+ mkdir -p $(bindir)/ui
+ for f in $(EXTRA_DIST); do \\
+ cp $$f $(bindir)/$$f; \\
+ done
+ install demos/libfpt.so $(bindir)/demos
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; The layout-manager-2 example calls `make', GCC at run-time.
+ ;; But since it would compile to the read-only /gnu/store, we
+ ;; deviate by compiling in advance in the build phase,
+ ;; ignoring failing `make' calls. We do not propagate `make'.
+ (with-directory-excursion "demos"
+ (when #$(%current-target-system)
+ (substitute* "Makefile"
+ (("^CC = gcc$")
+ (string-append "CC = " #$(cc-for-target) "\n"))))
+ (system* "make"))))
+ ;; There are no tests for examples, but we do an installcheck phase,
+ ;; which respects when #:tests? is turned off. So delete 'check.
+ (delete 'check)
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("\\(getcwd\\)")
+ (string-append "\"" #$output "/bin\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (gcairo (assoc-ref inputs "guile-cairo-next"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)
+ ,(string-append gcairo scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)
+ ,(string-append gcairo go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ ;; Library path for libraries loaded by binaries.
+ `("LD_LIBRARY_PATH" prefix
+ (,(string-append gcairo "/lib")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append adwaita-icons "/share"))))))
+ binaries))))
+ ;; Add installcheck to ensure nothing breaks.
+ (add-after 'strip 'installcheck
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (cond
+ ((not tests?)
+ (display "test suite not run\n"))
+ (#$(%current-target-system)
+ (display "cross-compiling; reftest skipped\n"))
+ (else
+ ;; Start an X server.
+ (system "Xvfb :1 &")
+ (setenv "DISPLAY" ":1")
+ (let* ((g-golf-drawing (string-append
+ #$output "/bin/drawing-widget"))
+ (pid (spawn g-golf-drawing `(,g-golf-drawing)
+ #:search-path? #f)))
+ (sleep 10) ;2s is enough on my machine
+ (display "Taking a screenshot with G-Golf.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.out.png")
+ (sleep 5) ;1s is enough on my machine
+ (kill pid SIGINT)
+ (waitpid pid))
+ (let* ((python (search-input-file inputs "/bin/python3"))
+ (pygobject-drawing #$(this-package-native-input
+ "drawing-widget.py"))
+ (pid (spawn python `(,python ,pygobject-drawing)
+ #:search-path? #f)))
+ (sleep 5) ;1s is enough on my machine
+ (display "Taking a screenshot with Pygobject.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.ref.png")
+ (sleep 5)
+ (kill pid SIGINT)
+ (waitpid pid))
+ (if (= (pk (system* "compare" "-metric" "AE" "-fuzz" "1%"
+ "drawing-widget.out.png"
+ "drawing-widget.ref.png"
+ "drawing-widget.dif.png")) 0)
+ (display "All good; they look the same.\n")
+ (error "Reftest failed; screenshots differ."))))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ gtk
+ guile-3.0
+ guile-cairo-next
+ guile-g-golf))
+ (native-inputs
+ (list pkg-config
+ which
+ ;; For installcheck:
+ imagemagick
+ python-minimal
+ python-pygobject
+ xorg-server-for-tests
+ ;; Python version of drawing-widget from
+ ;; https://lists.gnu.org/archive/html/guile-user/2024-05/msg00032.html
+ (origin
+ (method url-fetch)
+ (uri "\
+https://lists.gnu.org/archive/html/guile-user/2024-05/txtT_80XuINsX.txt")
+ (sha256
+ (base32
+ "07j2v159a3bb99i8kwbqrcgslcmhhnqa5ah53q2b9bdk8042grsx"))
+ (file-name "drawing-widget.py"))))
+ (propagated-inputs (list))
+ (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.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v3 5/5] gnu: Add G-Golf's Adw-1 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
58722c56454c0dfc94d39c5340bd1db35e0a79bc.1739785883.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-adw-1-examples): New variable.

Change-Id: I160e58ceaeb4867f9b21a0a32f198113e36b5c88
---
gnu/packages/guile-xyz.scm | 125 +++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)

Toggle diff (138 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 7ca6a1bd75..1ceb25be7d 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2803,6 +2803,131 @@ (define-public g-golf-gtk-4-examples
the @code{gtk:bin} Guix package output. They also show how to wrap G-Golf
applications in a Guix package.")))
+(define-public g-golf-adw-1-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-adw-1-examples")
+ (build-system glib-or-gtk-build-system)
+ (arguments
+ (list
+ #:tests? #f ;there are no tests for examples
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (guix build glib-or-gtk-build-system)
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/adw-1")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ (substitute* "Makefile"
+ ;; Fix syntax error.
+ (("hello-world")
+ "hello-world \\"))
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/demo/icons
+ mkdir -p $(bindir)/demo/pages
+ for f in $(EXTRA_DIST); do \\
+ cp -r $$f $(bindir)/$$f; \\
+ done
+ cp demo/g-resources $(bindir)/demo/g-resources
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; Create files for adwaita-1-demo needed in install phase.
+ (with-directory-excursion "demo"
+ (system* "make")
+ (system* "glib-compile-resources"
+ "--target" "g-resources"
+ "g-resources.xml"))))
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (libadwaita-icons (assoc-ref inputs "libadwaita"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ `("GUIX_GDK_PIXBUF_MODULE_FILES" suffix
+ (,(getenv "GUIX_GDK_PIXBUF_MODULE_FILES")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append #$output "/bin/demo")
+ ,(string-append adwaita-icons "/share")
+ ,(string-append libadwaita-icons "/share"))))))
+ binaries))))
+ (add-after 'wrap-binaries 'move-binaries
+ (lambda _
+ ;; Move the adwaita-1-demo wrapper to place it directly in /bin.
+ (rename-file (string-append
+ #$output "/bin/demo/adwaita-1-demo")
+ (string-append
+ #$output "/bin/adwaita-1-demo"))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ libadwaita
+ (librsvg-for-system)
+ gtk
+ guile-3.0
+ guile-g-golf))
+ (native-inputs (list `(,glib "bin") ;for glib-compile-resources
+ guile-3.0))
+ (propagated-inputs (list))
+ (synopsis "Example Adwaita 1 apps written in Guile with G-Golf")
+ (description
+ "G-Golf port of (a subset of) the upstream @code{adwaita-1-demo} examples
+in the @code{libadwaita} Guix package. They also show how to wrap G-Golf
+applications in a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 0/5] Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
cover.1739789645.git.pelzflorian@pelzflorian.de
Sorry for mistakes in v3. In v4:

* Fixed guile-cairo-next URL to appease guix lint.
* Fixed messed up guile-xyz.scm's first line in patch 4/5.
* Improved descriptions of examples packages.

Previously,
In v3, changes are only in
[PATCH v3 2/5] gnu: Add guile-cairo-next.
to use an https URL for privacy and improve comments,
in response to Maxim.

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 | 44 +++++-
gnu/packages/guile-xyz.scm | 314 ++++++++++++++++++++++++++++++++++++-
2 files changed, 356 insertions(+), 2 deletions(-)


base-commit: 5e3e1b782b87d5bfe903f978490955cc20a70e5a
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 1/5] gnu: guile-cairo: Remove expat from inputs.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ef3b2b2e54ee7a8d6c5562c747c5824b95cad0cb.1739789645.git.pelzflorian@pelzflorian.de
expat is not needed by guile-cairo nor guile2.2-cairo.

* gnu/packages/gtk.scm (guile-cairo)[inputs]: Remove expat.

Change-Id: Ie8f2c35c52725326cc8f103c45125e4378d29793
---
gnu/packages/gtk.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 011a1db687..8e893d66c3 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -1454,7 +1454,7 @@ (define-public guile-cairo
(find-files module-dir "\\.scm$"))
#t))))))
(inputs
- (list guile-lib expat guile-3.0))
+ (list guile-lib guile-3.0))
(propagated-inputs
;; The .pc file refers to 'cairo'.
(list cairo))
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 2/5] gnu: Add guile-cairo-next.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
04aef89d602a509d635059fa48b7cdf85c7ddf97.1739789645.git.pelzflorian@pelzflorian.de
* gnu/packages/gtk.scm (guile-cairo-next): New variable.

Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
---
gnu/packages/gtk.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 8e893d66c3..15b43da636 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1481,6 +1482,47 @@ (define-public guile2.2-cairo
,@(fold alist-delete (package-inputs guile-cairo)
'("guile" "guile-lib"))))))
+(define-public guile-cairo-next
+ ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
+ ;; and needed by animated-paintable from g-golf-gtk-4-examples.
+ (let ((commit "30da459d7a4380174ff243b1560d5512a4bca86e")
+ (revision "0"))
+ (package
+ (inherit guile-cairo)
+ (name "guile-cairo-next")
+ (version (git-version "1.11.2" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.savannah.gnu.org/git/guile-cairo.git/")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments guile-cairo)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; To allow running the check phase before install, add two phases
+ ;; similar to David Pirotte's suggested patch:
+ ;; <https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html>.
+ (add-after 'build 'fix-dynamic-link-path
+ (lambda _
+ ;; Dynamic-link libguile-cairo foreign extension by name, not
+ ;; path.
+ (substitute* "cairo/config.scm"
+ (("\\(define \\*cairo-lib-path\\* .*")
+ "\(define *cairo-lib-path* \"libguile-cairo\")\n"))))
+ (add-before 'check 'set-libtool-path
+ (lambda _
+ ;; Use appropriate pre-install libtool path in tests.
+ (setenv "LTDL_LIBRARY_PATH" "../../guile-cairo/.libs")))))))
+ (inputs
+ (list gettext-minimal guile-3.0 guile-lib))
+ (native-inputs
+ (list autoconf automake libtool pkg-config texinfo)))))
+
(define-public guile-rsvg
;; Use a recent snapshot that supports Guile 2.2 and beyond.
(let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 3/5] gnu: guile-g-golf: Document --no-grafts requirement.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
8c8860248595b0fdcdaddf40836fac887fce7210.1739789645.git.pelzflorian@pelzflorian.de
Note that packages are unaffected.

* gnu/packages/guile-xyz.scm: Tell about grafts bug.

Change-Id: Ic0b2c63daa07c693171965d90410aef5a2e41d49
---
gnu/packages/guile-xyz.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (20 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 921d8b46d6..9877e01748 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2603,7 +2603,12 @@ (define-public guile-g-golf
modern applications in Guile Scheme. It comprises a direct binding to the
GObject Introspection API and higher-level functionality for importing Gnome
libraries and making GObject classes (and methods) available in Guile's
-object-oriented programming system, GOOPS.")
+object-oriented programming system, GOOPS.
+
+Note: Currently, when developing with G-Golf in @code{guix shell}, there is a
+@uref{https://bugs.gnu.org/75157, grafts bug in Guix}. To avoid it, use Guix'
+@code{--no-grafts} option. Guix packages that use @code{wrap-program} are
+unaffected.")
(license license:lgpl3+)))
(define-public g-golf
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 4/5] gnu: Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
5fa527731786e0f55f3e76f08b82ea41c084d631.1739789645.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-gtk-4-examples): New variable.

Change-Id: I19b182eb71095ca2deacdb4011c8f50dfcfc8476
---
gnu/packages/guile-xyz.scm | 181 +++++++++++++++++++++++++++++++++++++
1 file changed, 181 insertions(+)

Toggle diff (201 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 9877e01748..6e53bc291f 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -53,6 +53,7 @@
;;; Copyright © 2024 Alec Barreto <mrh57@posteo.net>
;;; Copyright © 2024 Josep Bigorra <jjbigorra@gmail.com>
;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2623,6 +2624,186 @@ (define-public guile2.2-g-golf
(replace "guile" guile-2.2)
(replace "guile-lib" guile2.2-lib)))))
+(define-public g-golf-gtk-4-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-gtk-4-examples")
+ (arguments
+ (list
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/gtk-4")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/css
+ mkdir -p $(bindir)/demos
+ mkdir -p $(bindir)/images
+ mkdir -p $(bindir)/ui
+ for f in $(EXTRA_DIST); do \\
+ cp $$f $(bindir)/$$f; \\
+ done
+ install demos/libfpt.so $(bindir)/demos
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; The layout-manager-2 example calls `make', GCC at run-time.
+ ;; But since it would compile to the read-only /gnu/store, we
+ ;; deviate by compiling in advance in the build phase,
+ ;; ignoring failing `make' calls. We do not propagate `make'.
+ (with-directory-excursion "demos"
+ (when #$(%current-target-system)
+ (substitute* "Makefile"
+ (("^CC = gcc$")
+ (string-append "CC = " #$(cc-for-target) "\n"))))
+ (system* "make"))))
+ ;; There are no tests for examples, but we do an installcheck phase,
+ ;; which respects when #:tests? is turned off. So delete 'check.
+ (delete 'check)
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("\\(getcwd\\)")
+ (string-append "\"" #$output "/bin\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (gcairo (assoc-ref inputs "guile-cairo-next"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)
+ ,(string-append gcairo scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)
+ ,(string-append gcairo go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ ;; Library path for libraries loaded by binaries.
+ `("LD_LIBRARY_PATH" prefix
+ (,(string-append gcairo "/lib")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append adwaita-icons "/share"))))))
+ binaries))))
+ ;; Add installcheck to ensure nothing breaks.
+ (add-after 'strip 'installcheck
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (cond
+ ((not tests?)
+ (display "test suite not run\n"))
+ (#$(%current-target-system)
+ (display "cross-compiling; reftest skipped\n"))
+ (else
+ ;; Start an X server.
+ (system "Xvfb :1 &")
+ (setenv "DISPLAY" ":1")
+ (let* ((g-golf-drawing (string-append
+ #$output "/bin/drawing-widget"))
+ (pid (spawn g-golf-drawing `(,g-golf-drawing)
+ #:search-path? #f)))
+ (sleep 10) ;2s is enough on my machine
+ (display "Taking a screenshot with G-Golf.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.out.png")
+ (sleep 5) ;1s is enough on my machine
+ (kill pid SIGINT)
+ (waitpid pid))
+ (let* ((python (search-input-file inputs "/bin/python3"))
+ (pygobject-drawing #$(this-package-native-input
+ "drawing-widget.py"))
+ (pid (spawn python `(,python ,pygobject-drawing)
+ #:search-path? #f)))
+ (sleep 5) ;1s is enough on my machine
+ (display "Taking a screenshot with Pygobject.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.ref.png")
+ (sleep 5)
+ (kill pid SIGINT)
+ (waitpid pid))
+ (if (= (pk (system* "compare" "-metric" "AE" "-fuzz" "1%"
+ "drawing-widget.out.png"
+ "drawing-widget.ref.png"
+ "drawing-widget.dif.png")) 0)
+ (display "All good; they look the same.\n")
+ (error "Reftest failed; screenshots differ."))))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ gtk
+ guile-3.0
+ guile-cairo-next
+ guile-g-golf))
+ (native-inputs
+ (list pkg-config
+ which
+ ;; For installcheck:
+ imagemagick
+ python-minimal
+ python-pygobject
+ xorg-server-for-tests
+ ;; Python version of drawing-widget from
+ ;; https://lists.gnu.org/archive/html/guile-user/2024-05/msg00032.html
+ (origin
+ (method url-fetch)
+ (uri "\
+https://lists.gnu.org/archive/html/guile-user/2024-05/txtT_80XuINsX.txt")
+ (sha256
+ (base32
+ "07j2v159a3bb99i8kwbqrcgslcmhhnqa5ah53q2b9bdk8042grsx"))
+ (file-name "drawing-widget.py"))))
+ (propagated-inputs (list))
+ (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. Run @command{guix edit
+g-golf-gtk-4-examples} for inspiration how to wrap G-Golf applications when
+writing a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v4 5/5] gnu: Add G-Golf's Adw-1 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
5e935a85a1f3b8727b103905d550c09942788cc2.1739789645.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-adw-1-examples): New variable.

Change-Id: I160e58ceaeb4867f9b21a0a32f198113e36b5c88
---
gnu/packages/guile-xyz.scm | 126 +++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)

Toggle diff (139 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 6e53bc291f..130652fb23 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2804,6 +2804,132 @@ (define-public g-golf-gtk-4-examples
g-golf-gtk-4-examples} for inspiration how to wrap G-Golf applications when
writing a Guix package.")))
+(define-public g-golf-adw-1-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-adw-1-examples")
+ (build-system glib-or-gtk-build-system)
+ (arguments
+ (list
+ #:tests? #f ;there are no tests for examples
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (guix build glib-or-gtk-build-system)
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/adw-1")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ (substitute* "Makefile"
+ ;; Fix syntax error.
+ (("hello-world")
+ "hello-world \\"))
+ ;; Add a rule to install the examples. This also
+ ;; installs UI, CSS and Scheme files to /bin, but
+ ;; better keep how G-Golf packages them.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+.PHONY: install
+install:
+ mkdir -p $(bindir)/demo/icons
+ mkdir -p $(bindir)/demo/pages
+ for f in $(EXTRA_DIST); do \\
+ cp -r $$f $(bindir)/$$f; \\
+ done
+ cp demo/g-resources $(bindir)/demo/g-resources
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; Create files for adwaita-1-demo needed in install phase.
+ (with-directory-excursion "demo"
+ (system* "make")
+ (system* "glib-compile-resources"
+ "--target" "g-resources"
+ "g-resources.xml"))))
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (libadwaita-icons (assoc-ref inputs "libadwaita"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/bin/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ `("GUIX_GDK_PIXBUF_MODULE_FILES" suffix
+ (,(getenv "GUIX_GDK_PIXBUF_MODULE_FILES")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append #$output "/bin/demo")
+ ,(string-append adwaita-icons "/share")
+ ,(string-append libadwaita-icons "/share"))))))
+ binaries))))
+ (add-after 'wrap-binaries 'move-binaries
+ (lambda _
+ ;; Move the adwaita-1-demo wrapper to place it directly in /bin.
+ (rename-file (string-append
+ #$output "/bin/demo/adwaita-1-demo")
+ (string-append
+ #$output "/bin/adwaita-1-demo"))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ libadwaita
+ (librsvg-for-system)
+ gtk
+ guile-3.0
+ guile-g-golf))
+ (native-inputs (list `(,glib "bin") ;for glib-compile-resources
+ guile-3.0))
+ (propagated-inputs (list))
+ (synopsis "Example Adwaita 1 apps written in Guile with G-Golf")
+ (description
+ "G-Golf port of (a subset of) the upstream @code{adwaita-1-demo} examples
+in the @code{libadwaita} Guix package. Run @command{guix edit
+g-golf-adw-1-examples} for inspiration how to wrap G-Golf applications when
+writing a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 0/6] Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
cover.1739898237.git.pelzflorian@pelzflorian.de
In v5:

* In patch 3/5, use @command{guix shell} mark-up and not @code.
* Adhere to David Pirotte’s wish to install not to /bin but
to /share/doc/g-golf/examples/gtk-4. Make a copy of wrapper scripts
in /bin for use with `guix shell'.
* I don't know if David will accept Maxim's suggested resolution of
a naming dispute, [1] but I added a patch for it.


Florian Pelz (6):
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: g-golf: Redefine as a non-deprecated alias.

gnu/packages/gtk.scm | 44 ++++-
gnu/packages/guile-xyz.scm | 336 ++++++++++++++++++++++++++++++++++++-
2 files changed, 377 insertions(+), 3 deletions(-)


base-commit: 5e3e1b782b87d5bfe903f978490955cc20a70e5a
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 1/6] gnu: guile-cairo: Remove expat from inputs.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
ef3b2b2e54ee7a8d6c5562c747c5824b95cad0cb.1739898237.git.pelzflorian@pelzflorian.de
expat is not needed by guile-cairo nor guile2.2-cairo.

* gnu/packages/gtk.scm (guile-cairo)[inputs]: Remove expat.

Change-Id: Ie8f2c35c52725326cc8f103c45125e4378d29793
---
gnu/packages/gtk.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 011a1db687..8e893d66c3 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -1454,7 +1454,7 @@ (define-public guile-cairo
(find-files module-dir "\\.scm$"))
#t))))))
(inputs
- (list guile-lib expat guile-3.0))
+ (list guile-lib guile-3.0))
(propagated-inputs
;; The .pc file refers to 'cairo'.
(list cairo))
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 2/6] gnu: Add guile-cairo-next.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
04aef89d602a509d635059fa48b7cdf85c7ddf97.1739898237.git.pelzflorian@pelzflorian.de
* gnu/packages/gtk.scm (guile-cairo-next): New variable.

Change-Id: I328afe58d46e60243e075edead12afc0d1c4a98a
---
gnu/packages/gtk.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 8e893d66c3..15b43da636 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1481,6 +1482,47 @@ (define-public guile2.2-cairo
,@(fold alist-delete (package-inputs guile-cairo)
'("guile" "guile-lib"))))))
+(define-public guile-cairo-next
+ ;; A commit with cairo-pointer->context, missing from guile-cairo@1.11.2
+ ;; and needed by animated-paintable from g-golf-gtk-4-examples.
+ (let ((commit "30da459d7a4380174ff243b1560d5512a4bca86e")
+ (revision "0"))
+ (package
+ (inherit guile-cairo)
+ (name "guile-cairo-next")
+ (version (git-version "1.11.2" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.savannah.gnu.org/git/guile-cairo.git/")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0dslfldzgxis8g0g3xaffcqnd1njzz23fjy0v3lc0r2694ra4ny4"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments guile-cairo)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; To allow running the check phase before install, add two phases
+ ;; similar to David Pirotte's suggested patch:
+ ;; <https://lists.gnu.org/archive/html/guile-user/2023-03/msg00028.html>.
+ (add-after 'build 'fix-dynamic-link-path
+ (lambda _
+ ;; Dynamic-link libguile-cairo foreign extension by name, not
+ ;; path.
+ (substitute* "cairo/config.scm"
+ (("\\(define \\*cairo-lib-path\\* .*")
+ "\(define *cairo-lib-path* \"libguile-cairo\")\n"))))
+ (add-before 'check 'set-libtool-path
+ (lambda _
+ ;; Use appropriate pre-install libtool path in tests.
+ (setenv "LTDL_LIBRARY_PATH" "../../guile-cairo/.libs")))))))
+ (inputs
+ (list gettext-minimal guile-3.0 guile-lib))
+ (native-inputs
+ (list autoconf automake libtool pkg-config texinfo)))))
+
(define-public guile-rsvg
;; Use a recent snapshot that supports Guile 2.2 and beyond.
(let ((commit "05c6a2fd67e4fea1a7c3ff776729dc931bae6678")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 3/6] gnu: guile-g-golf: Document --no-grafts requirement.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
b75ef56ad3ce31bfc00a7ee26100418ebf546951.1739898237.git.pelzflorian@pelzflorian.de
Note that packages are unaffected.

* gnu/packages/guile-xyz.scm: Tell about grafts bug.

Change-Id: Ic0b2c63daa07c693171965d90410aef5a2e41d49
---
gnu/packages/guile-xyz.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (20 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 921d8b46d6..8fb4448061 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2603,7 +2603,12 @@ (define-public guile-g-golf
modern applications in Guile Scheme. It comprises a direct binding to the
GObject Introspection API and higher-level functionality for importing Gnome
libraries and making GObject classes (and methods) available in Guile's
-object-oriented programming system, GOOPS.")
+object-oriented programming system, GOOPS.
+
+Note: Currently, when developing with G-Golf in @command{guix shell}, there is
+a @uref{https://bugs.gnu.org/75157, grafts bug in Guix}. To avoid it, use
+Guix' @code{--no-grafts} option. Guix packages that use @code{wrap-program}
+are unaffected.")
(license license:lgpl3+)))
(define-public g-golf
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 4/6] gnu: Add G-Golf's GTK-4 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
103b82ca676b12e0098627f703641d0fe5f41dc6.1739898237.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-gtk-4-examples): New variable.

Change-Id: I19b182eb71095ca2deacdb4011c8f50dfcfc8476
---
gnu/packages/guile-xyz.scm | 190 +++++++++++++++++++++++++++++++++++++
1 file changed, 190 insertions(+)

Toggle diff (210 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 8fb4448061..0c7329c7ea 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -53,6 +53,7 @@
;;; Copyright © 2024 Alec Barreto <mrh57@posteo.net>
;;; Copyright © 2024 Josep Bigorra <jjbigorra@gmail.com>
;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
+;;; Copyright © 2025 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2623,6 +2624,195 @@ (define-public guile2.2-g-golf
(replace "guile" guile-2.2)
(replace "guile-lib" guile2.2-lib)))))
+(define-public g-golf-gtk-4-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-gtk-4-examples")
+ (arguments
+ (list
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/gtk-4")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ ;; Add a rule to install the examples. We install to the
+ ;; documentation directory where examples are usually located,
+ ;; but we will later create a copy in /bin for `guix shell'.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+examplesdir = $(prefix)/share/doc/g-golf/examples/gtk-4
+.PHONY: install
+install:
+ mkdir -p $(bindir)
+ mkdir -p $(examplesdir)/css
+ mkdir -p $(examplesdir)/demos
+ mkdir -p $(examplesdir)/images
+ mkdir -p $(examplesdir)/ui
+ for f in $(EXTRA_DIST); do \\
+ cp $$f $(examplesdir)/$$f; \\
+ done
+ install demos/libfpt.so $(examplesdir)/demos
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; The layout-manager-2 example calls `make', GCC at run-time.
+ ;; But since it would compile to the read-only /gnu/store, we
+ ;; deviate by compiling in advance in the build phase,
+ ;; ignoring failing `make' calls. We do not propagate `make'.
+ (with-directory-excursion "demos"
+ (when #$(%current-target-system)
+ (substitute* "Makefile"
+ (("^CC = gcc$")
+ (string-append "CC = " #$(cc-for-target) "\n"))))
+ (system* "make"))))
+ ;; There are no tests for examples, but we do an installcheck phase,
+ ;; which respects when #:tests? is turned off. So delete 'check.
+ (delete 'check)
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "\
+/share/doc/g-golf/examples/gtk-4/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("\\(getcwd\\)")
+ (string-append "\"" #$output "\
+/share/doc/g-golf/examples/gtk-4\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (gcairo (assoc-ref inputs "guile-cairo-next"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "/\
+share/doc/g-golf/examples/gtk-4/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)
+ ,(string-append gcairo scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)
+ ,(string-append gcairo go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ ;; Library path for libraries loaded by binaries.
+ `("LD_LIBRARY_PATH" prefix
+ (,(string-append gcairo "/lib")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append adwaita-icons "/share"))))
+ ;; Also create a copy in /bin for `guix shell'.
+ (copy-file installed-binary
+ (string-append #$output "/bin/" binary))))
+ binaries))))
+ ;; Add installcheck to ensure nothing breaks.
+ (add-after 'strip 'installcheck
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (cond
+ ((not tests?)
+ (display "test suite not run\n"))
+ (#$(%current-target-system)
+ (display "cross-compiling; reftest skipped\n"))
+ (else
+ ;; Start an X server.
+ (system "Xvfb :1 &")
+ (setenv "DISPLAY" ":1")
+ (let* ((g-golf-drawing (string-append
+ #$output "\
+/share/doc/g-golf/examples/gtk-4/drawing-widget"))
+ (pid (spawn g-golf-drawing `(,g-golf-drawing)
+ #:search-path? #f)))
+ (sleep 10) ;2s is enough on my machine
+ (display "Taking a screenshot with G-Golf.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.out.png")
+ (sleep 5) ;1s is enough on my machine
+ (kill pid SIGINT)
+ (waitpid pid))
+ (let* ((python (search-input-file inputs "/bin/python3"))
+ (pygobject-drawing #$(this-package-native-input
+ "drawing-widget.py"))
+ (pid (spawn python `(,python ,pygobject-drawing)
+ #:search-path? #f)))
+ (sleep 5) ;1s is enough on my machine
+ (display "Taking a screenshot with Pygobject.\n")
+ (system* "import" "-window" "root"
+ "drawing-widget.ref.png")
+ (sleep 5)
+ (kill pid SIGINT)
+ (waitpid pid))
+ (if (= (pk (system* "compare" "-metric" "AE" "-fuzz" "1%"
+ "drawing-widget.out.png"
+ "drawing-widget.ref.png"
+ "drawing-widget.dif.png")) 0)
+ (display "All good; they look the same.\n")
+ (error "Reftest failed; screenshots differ."))))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ gtk
+ guile-3.0
+ guile-cairo-next
+ guile-g-golf))
+ (native-inputs
+ (list pkg-config
+ which
+ ;; For installcheck:
+ imagemagick
+ python-minimal
+ python-pygobject
+ xorg-server-for-tests
+ ;; Python version of drawing-widget from
+ ;; https://lists.gnu.org/archive/html/guile-user/2024-05/msg00032.html
+ (origin
+ (method url-fetch)
+ (uri "\
+https://lists.gnu.org/archive/html/guile-user/2024-05/txtT_80XuINsX.txt")
+ (sha256
+ (base32
+ "07j2v159a3bb99i8kwbqrcgslcmhhnqa5ah53q2b9bdk8042grsx"))
+ (file-name "drawing-widget.py"))))
+ (propagated-inputs (list))
+ (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. Run @command{guix edit
+g-golf-gtk-4-examples} for inspiration how to wrap G-Golf applications when
+writing a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 5/6] gnu: Add G-Golf's Adw-1 examples.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
583fb5e4ad1bf844875ecf4c41d9e19afe8067ff.1739898237.git.pelzflorian@pelzflorian.de
* gnu/packages/guile-xyz.scm (g-golf-adw-1-examples): New variable.

Change-Id: I160e58ceaeb4867f9b21a0a32f198113e36b5c88
---
gnu/packages/guile-xyz.scm | 135 +++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)

Toggle diff (148 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 0c7329c7ea..bac21afc4f 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2813,6 +2813,141 @@ (define-public g-golf-gtk-4-examples
g-golf-gtk-4-examples} for inspiration how to wrap G-Golf applications when
writing a Guix package.")))
+(define-public g-golf-adw-1-examples
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf-adw-1-examples")
+ (build-system glib-or-gtk-build-system)
+ (arguments
+ (list
+ #:tests? #f ;there are no tests for examples
+ #:modules `(((guix build guile-build-system)
+ #:select
+ (target-guile-effective-version))
+ (guix build glib-or-gtk-build-system)
+ (srfi srfi-26)
+ ,@%default-gnu-modules)
+ #:phases
+ (with-imported-modules `((guix build guile-build-system)
+ ,@%default-gnu-imported-modules)
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'prepare-examples
+ (lambda _
+ (chdir "examples/adw-1")
+ ;; Re-use the existing Makefile for its wildcard syntax.
+ (rename-file "Makefile.am" "Makefile")
+ (substitute* "Makefile"
+ ;; Fix syntax error.
+ (("hello-world")
+ "hello-world \\"))
+ ;; Add a rule to install the examples. We install to the
+ ;; documentation directory where examples are usually located,
+ ;; but we will later create a copy in /bin for `guix shell'.
+ (let ((port (open-file "Makefile" "al")))
+ (format port "
+prefix = ~a
+bindir = $(prefix)/bin
+examplesdir = $(prefix)/share/doc/g-golf/examples/adw-1
+.PHONY: install
+install:
+ mkdir -p $(bindir)
+ mkdir -p $(examplesdir)/demo/icons
+ mkdir -p $(examplesdir)/demo/pages
+ for f in $(EXTRA_DIST); do \\
+ cp -r $$f $(examplesdir)/$$f; \\
+ done
+ cp demo/g-resources $(examplesdir)/demo/g-resources
+" #$output)
+ (close-port port))))
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ ;; Create files for adwaita-1-demo needed in install phase.
+ (with-directory-excursion "demo"
+ (system* "make")
+ (system* "glib-compile-resources"
+ "--target" "g-resources"
+ "g-resources.xml"))))
+ (add-before 'install 'patch-scm-files
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; `current-filename' calls in examples are broken.
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "\
+/share/doc/g-golf/examples/adw-1/" binary)))
+ (substitute* binary
+ (("\\(current-filename\\)")
+ (string-append "\"" installed-binary "\""))
+ (("^exec guile ")
+ (string-append
+ "exec " (search-input-file inputs "/bin/guile")
+ " ")))))
+ (map (cut string-drop <> 2) ;strip ./ prefix
+ (find-files "." (lambda (file stat)
+ ;executables or .scm modules
+ (or (= (stat:perms stat) #o755)
+ (string-suffix? ".scm"
+ file))))))))
+ (add-after 'install 'wrap-binaries
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((version (target-guile-effective-version))
+ (g-golf (assoc-ref inputs "guile-g-golf"))
+ (adwaita-icons (assoc-ref inputs "adwaita-icon-theme"))
+ (libadwaita-icons (assoc-ref inputs "libadwaita"))
+ (scm (string-append "/share/guile/site/" version))
+ (go (string-append "/lib/guile/"
+ version "/site-ccache"))
+ (binaries
+ (find-files "." (lambda (file stat) ;executables
+ (= (stat:perms stat) #o755)))))
+ (map (lambda (binary)
+ (let ((installed-binary (string-append
+ #$output "\
+/share/doc/g-golf/examples/adw-1/" binary)))
+ (wrap-program installed-binary
+ `("GUILE_LOAD_PATH" prefix
+ (,(string-append g-golf scm)))
+ `("GUILE_LOAD_COMPILED_PATH" prefix
+ (,(string-append g-golf go)))
+ `("GI_TYPELIB_PATH" prefix
+ (,(getenv "GI_TYPELIB_PATH")))
+ `("GUIX_GDK_PIXBUF_MODULE_FILES" suffix
+ (,(getenv "GUIX_GDK_PIXBUF_MODULE_FILES")))
+ `("XDG_DATA_DIRS" suffix
+ (,(string-append #$output "/bin/demo")
+ ,(string-append adwaita-icons "/share")
+ ,(string-append libadwaita-icons "/share"))))))
+ binaries))))
+ (add-after 'wrap-binaries 'copy-binaries
+ (lambda _
+ (copy-file (string-append
+ #$output "\
+/share/doc/g-golf/examples/adw-1/demo/adwaita-1-demo")
+ (string-append
+ #$output "/bin/adwaita-1-demo"))
+ (copy-file (string-append
+ #$output "\
+/share/doc/g-golf/examples/adw-1/hello-world")
+ (string-append
+ #$output "/bin/hello-world"))))))))
+ (inputs
+ (list adwaita-icon-theme
+ bash-minimal
+ libadwaita
+ (librsvg-for-system)
+ gtk
+ guile-3.0
+ guile-g-golf))
+ (native-inputs (list `(,glib "bin") ;for glib-compile-resources
+ guile-3.0))
+ (propagated-inputs (list))
+ (synopsis "Example Adwaita 1 apps written in Guile with G-Golf")
+ (description
+ "G-Golf port of (a subset of) the upstream @code{adwaita-1-demo} examples
+in the @code{libadwaita} Guix package. Run @command{guix edit
+g-golf-adw-1-examples} for inspiration how to wrap G-Golf applications when
+writing a Guix package.")))
+
(define-public g-wrap
(package
(name "g-wrap")
--
2.48.1
Florian Pelz wrote 1 months ago
[PATCH v5 6/6] gnu: g-golf: Redefine as a non-deprecated alias.
(address . 76246@debbugs.gnu.org)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
df547c9baa43532359da24016b711e5f37d13dd0.1739898237.git.pelzflorian@pelzflorian.de
As proposed by Maxim Cournoyer

* gnu/packages/guile-xyz.scm (g-golf: Redefine.

Change-Id: I850e05d46c026d6a27c8765ff3753c1bbe555235
---
gnu/packages/guile-xyz.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index bac21afc4f..0fc6123f1d 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2613,7 +2613,9 @@ (define-public guile-g-golf
(license license:lgpl3+)))
(define-public g-golf
- (deprecated-package "g-golf" guile-g-golf))
+ (package
+ (inherit guile-g-golf)
+ (name "g-golf")))
(define-public guile2.2-g-golf
(package
--
2.48.1
Tobias Geerinckx-Rice wrote 1 months ago
Re: [bug#76246] [PATCH v5 6/6] gnu: g-g olf: Redefine as a non-deprecated alias.
(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)(address . 76246@debbugs.gnu.org)
0614B99B-B409-4D89-928B-D7B5F5BA1399@tobias.gr
Hi Florian,

Thanks. If we do decide to do this (I don't think it's a good idea; just keep ‘guile-g-golf’), then add a comment like

;; Use ‘guile-g-golf’ above in package inputs and other code. This alias exists as a compromise,

so later readers can know why we have two identical packages with different package names.

Kind regards,

T G-R

Sent on the go. Excuse or enjoy my brevity.
Maxim Cournoyer wrote 4 weeks ago
Re: [bug#76246] [PATCH v5 6/6] gnu: g-golf: Redefine as a non-deprecated alias.
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)(address . 76246@debbugs.gnu.org)
871pvpqswf.fsf@gmail.com
Hi Tobias, Florian,

Tobias Geerinckx-Rice <me@tobias.gr> writes:

Toggle quote (8 lines)
> Hi Florian,
>
> Thanks. If we do decide to do this (I don't think it's a good idea;
> just keep ‘guile-g-golf’), then add a comment like
>
> ;; Use ‘guile-g-golf’ above in package inputs and other code. This alias exists as a compromise,
> ;; see <https://lists.gnu.org/archive/html/guix-devel/2025-02/msg00296.html>.

My 2 cents: prefixing a package with '$lang-' is a (somewhat loose, or
at least sparsely documented *guideline*). I think given David is very
sensitive about having their package exposed as 'g-golf' on the command
line of Guix, it is not a big harm to do what is proposed by Florian
above (and I second adding the comment you suggested). We'd loose more
to not have 'g-golf' packaged anymore in Guix, which is the only library
to do GTK with Guile, IIRC.

Guix itself might use it at some point, for a GUI updater say that could
make keeping Guix up-to-date easier on desktop systems.

--
Thanks,
Maxim
pelzflorian (Florian Pelz) wrote 4 weeks ago
(address . 76246-done@debbugs.gnu.org)(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
874j0idhqg.fsf@pelzflorian.de
Pushed as db172d1f64a514babc9a2e4fd11fe8fe248e306e.

* Added Tobias’ comment on the alias g-golf compromise.
I was at first inclined to drop the whole alias patch,
since David Pirotte did not respond on it, but the alias
is in Guix now.

* Changed synopses and descriptions to be closer to what David Pirotte
wrote. This means the synopsis no longer says “in Guile”, but
surprisingly, it does not negatively affect its search score with
“guix search guile gtk”. However, I wrote "G-Golf GTK 4 examples"
instead of David’s "G-Golf Gtk-4 Examples".

* In g-golf-adw-1-examples, I wrapped GDK_PIXBUF_MODULE_FILE rather
than GUIX_GDK_PIXBUF_MODULE_FILES, so it builds on the master
branch. The main demo adwaita-1-demo does not work on master yet,
libadwaita is too old. I plan to rewrite the wrapping when
GUIX_GDK_PIXBUF_MODULE_FILES is on master or rather 宋文武’s GCD [1]
is accepted.

I would much welcome if G-Golf, AFAIK the only currently maintained
and comprehensive library to access GTK and perhaps better Libadwaita
in Guile, were put to use in Guix itself, as Maxim writes, but I will
not be of help.

Regards,
Florian

Closed
Maxim Cournoyer wrote 4 weeks ago
(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(name . David Pirotte)(address . david@altosw.be)(address . 76246-done@debbugs.gnu.org)
87eczmn572.fsf@gmail.com
Hi Florian,

"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> writes:

Toggle quote (25 lines)
> Pushed as db172d1f64a514babc9a2e4fd11fe8fe248e306e.
>
> * Added Tobias’ comment on the alias g-golf compromise.
> I was at first inclined to drop the whole alias patch,
> since David Pirotte did not respond on it, but the alias
> is in Guix now.
>
> * Changed synopses and descriptions to be closer to what David Pirotte
> wrote. This means the synopsis no longer says “in Guile”, but
> surprisingly, it does not negatively affect its search score with
> “guix search guile gtk”. However, I wrote "G-Golf GTK 4 examples"
> instead of David’s "G-Golf Gtk-4 Examples".
>
> * In g-golf-adw-1-examples, I wrapped GDK_PIXBUF_MODULE_FILE rather
> than GUIX_GDK_PIXBUF_MODULE_FILES, so it builds on the master
> branch. The main demo adwaita-1-demo does not work on master yet,
> libadwaita is too old. I plan to rewrite the wrapping when
> GUIX_GDK_PIXBUF_MODULE_FILES is on master or rather 宋文武’s GCD [1]
> is accepted.
>
> I would much welcome if G-Golf, AFAIK the only currently maintained
> and comprehensive library to access GTK and perhaps better Libadwaita
> in Guile, were put to use in Guix itself, as Maxim writes, but I will
> not be of help.

Thanks for your efforts in packaging this library, and for David for
having authored it in the first place!

--
Maxim
Closed
pelzflorian (Florian Pelz) wrote 4 weeks ago
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(name . David Pirotte)(address . david@altosw.be)(address . 76246-done@debbugs.gnu.org)
87eczmqq2f.fsf@pelzflorian.de
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
Toggle quote (3 lines)
> Thanks for your efforts in packaging this library, and for David for
> having authored it in the first place!

:)

Note that I packaged examples but never packaged the guile-g-golf
library, which was done by other fans of G-Golf, namely

commit dfe277a5ce60d487fe44840506206fea8507bc69
Author: Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
Date: Wed Apr 15 07:15:59 2020 +0000
commit 85fcceeea146b2e2e84a063f042893a0c39e9e5f
Author: Mike Rosset <mike.rosset@gmail.com>
Date: Mon Jul 20 12:06:12 2020 -0700
commit 35c96e65a9ea638d5c544257e1917e320c2beca1
Author: Zhu Zihao <all_but_last@163.com>
Date: Thu Feb 3 22:27:40 2022 +0800

Regards,
Florian
Closed
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 76246@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 76246
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help