Subject: Re: [bug#75688] [PATCH 2/2] gnu: gdk-pixbuf: Respect GUIX_LIBRARY_PATH.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 20 Jan 2025 23:03:55 +0900

Hi,

[email-masked] writes:

> From: 宋文武 <[email-masked]>
>
> This fixes <https://issues.guix.gnu.org/75523>.
>
> * gnu/packages/patches/gdk-pixbuf-respect-GUIX_LIBRARY_PATH.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/gtk.scm (gdk-pixbuf)[source]: Apply patch.
> [native-search-paths]: Remove GDK_PIXBUF_MODULE_FILE.

[...]

> diff --git a/gnu/packages/patches/gdk-pixbuf-respect-GUIX_LIBRARY_PATH.patch b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_LIBRARY_PATH.patch
> new file mode 100644
> index 0000000000..3ec7bc28ab
> --- /dev/null
> +++ b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_LIBRARY_PATH.patch
> @@ -0,0 +1,42 @@
> +diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
> +index e1df590..e553eba 100644
> +--- a/gdk-pixbuf/gdk-pixbuf-io.c
> ++++ b/gdk-pixbuf/gdk-pixbuf-io.c
> +@@ -663,6 +663,19 @@ gdk_pixbuf_io_init_builtin (void)
> + #undef load_one_builtin_module
> + }
> + 
> ++
> ++static gchar **
> ++build_guix_library_path (void)
> ++{
> ++        gchar **dirs = NULL;
> ++        gchar *library_path = g_strdup (g_getenv ("GUIX_LIBRARY_PATH"));
> ++        if (!library_path || !library_path[0])
> ++            library_path = g_build_filename (g_get_home_dir (), ".guix-profile", "lib", NULL);
> ++        dirs = g_strsplit (library_path, G_SEARCHPATH_SEPARATOR_S, 0);
> ++        g_free (library_path);
> ++        return dirs;
> ++}
> ++
> + static gboolean
> + gdk_pixbuf_io_init (void)
> + {
> +@@ -670,6 +683,17 @@ gdk_pixbuf_io_init (void)
> + 	gboolean ret;
> + 
> + 	gdk_pixbuf_io_init_builtin ();
> ++
> ++	/* Load loaders from GUIX_LIBRARY_PATH */
> ++	gchar **guix_libdirs = build_guix_library_path ();
> ++	for (gsize i = 0; guix_libdirs[i] != NULL; i++) {
> ++	    module_file = g_build_filename (guix_libdirs[i], "gdk-pixbuf-2.0",
> ++                                            GDK_PIXBUF_BINARY_VERSION, "loaders.cache", NULL);
> ++	    gdk_pixbuf_io_init_modules (module_file, NULL);
> ++	    g_free (module_file);
> ++	}
> ++	g_strfreev (guix_libdirs);
> ++
> + #ifdef USE_GMODULE
> + 	module_file = gdk_pixbuf_get_module_file ();
> + #endif

As I mentioned in my previous reply, I think having a
GDK_PIXBUF_MODULE_FILES environment variable using similar code as above
would be a nicer solution, since it could probably be upstreamed and
thus no custom patches to maintain on our side indefinitely (and useful
functionality available to others -- a win/win situation)

Do you agree that'd be nicer?

-- 
Thanks,
Maxim