Guile GI - Guile Scheme GTK bindings

Been doing a bit of research on whether to build an app using Common Lisp or Guile Scheme, was actually leaning more towards Common Lisp as it seems to have more support overall… but just recently stumbled on the fact that Guile Scheme has GTK Bindings Support. For me this is a game changer, would also like to play around with Hoot on possibly making a web app version as well.

Wasn’t able to get their example working out of the box, but was wondering if anyone has experience with this and could share some more resources (personal tips/tricks, blogs/literature, etc) on this topic. Thanks!

3 Likes

Yes, actually I am trying to create a React-like GUI framework using Guile Scheme, and I chose Guile-GI for the Gtk bindings. I install it using the Guix package manager on Ubuntu. Here is my Guix manifest.scm for my Guile GI project:

(specifications->manifest
 '("guile"
   "guile-gi"
   "glib"
   "gtk+"))

EDIT: I had originally listed “guile-lib” as a dependency, but it is not required for Guile-GI.

And I install this with the command:

guix package --profile=./.guix-profile --manifest=./manifest.scm --install 

This creates a Guix profile directory in the same directory as my source code. I use a script called ./guile.sh to launch Guile (and I have to configure Emacs Geiser to use this script):

#!/bin/sh
guix shell --pure -p ./.guix-profile -- guile --r7rs  --fresh-auto-compile

The documentation for Guile-GI is also installed into the Guix profile in the ./.guix-profile/share/info directory. To read it in Emacs using Info-mode, navigate to that directory with Dired and find the file guile-gi.info.gz, then press I (capital I) to open that document in Info mode.

I have used Guile-GI with both Gtk3 and Gtk4 on Guix OS, but unfortunately Gtk4 started freezing after I recently did a software update, and I have yet to investigate. Currently I can confirm that Gtk3 on Guix OS and Ubuntu works just fine.

I have also been able to get Guile-GI to build on Ubuntu 23.10, but I had to install the dependencies using apt-get (I can’t remember exactly what they are right now). The packages install into /usr/lib/x86_64-linux-gnu/guile/3.0, and it works with both Gtk3 and Gtk4.

I have also tried installing Guile G-Golf but their Guix package has a sort of bug in it: G-Golf requires GLib version 2.72.3, but Guix OS (at least most of their desktop environments, like Gnome and Xfce) require Glib version 2.72. So I am forced to install a whole other copy of libgtk, libgio, libgobject, and libglib just to get G-Golf to work, which means I have to patch the Guix packages for Gtk and anything else that depends on GLib, and then rebuild all of them from source, which of course takes a very long time and a lot of disk space as well. This also makes it impossible to install both Guile G-Golf and Guile-GI into the same profile with the same manifest, so I cannot easily switch between the two in the same project, I must use separate profiles instead, which is cumbersome.

I am thinking of filing a bug report to Guix OS for them to upgrade to libglib 2.73, so I can offer a choice between using Guile G-Golf and Guile-GI.

3 Likes

Thank you @ramin_hal9001 - really appreciate your feedback! I am still new to Guix and Guile and just recently setup my Guix Home, but was still unsure how to use manifests, so your post helped enlighten me on two fronts!

I’ll see if those packages help me run the tutorial script that is presented on GTK’s Website for Guile GI - I was getting warnings regarding GTK+ typelibs and once I installed GTK+ guile was seg. faulting… I didn’t explicity install guile-lib or glib, so will give that a try.

I will have to figure out how to integrate in manifests with Guix system/home, but I like the modular concept, i.e. manifests for packages needed for projects etc, home config for day-to-day workflow packages, and system for critical/essential packages.

I currently use Ares/Arei for my Guile nREPL system, would it be possible to see how you setup your Geiser, I have used Geiser in the past but wanted to give Andrew Tropin’s package a try!

1 Like

Oh yes, glib will be installed as a dependency for Guile-GI but you will not be able to use it in your own .guix-profile or part of your own software if you do not yourself list it as a package dependency, and it is quite likely you will need one or two of the APIs in glib when programming Gtk applications.

You reminded me that I listed guile-lib as a dependency also, but I realize now that it is not actually required to run Guile-GI, so you can probably remove that one. Guile-GI only requires Guile, and GOOPS but that is bundled into the guile package.

1 Like