Subject: [PATCH gnome-team v2 3/4] gnu: bootstrap glib and gobject against each other.

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 5 Oct 2024 09:55:46 +0200

As of GLib 2.82, introspection data in GLib is built as part of the package,
requiring gobject-introspection.

* gnu/packages/gnome.scm (glib-minimal, gobject-introspection-minimal): New
variables.
(glib): Use gobject-introspection-minimal for bootstrap.
(gobject-introspection-minimal): Use glib-minimal for bootstrap.
(gobject-introspection): Fix propagations.
---
 gnu/packages/glib.scm | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index b13b2c659a..15b0c03de6 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -242,7 +242,7 @@ (define-public dbus-verbose
 the @code{DBUS_VERBOSE} environment variable is set to @samp{1}.  For more
 information, refer to the @samp{dbus-daemon(1)} man page.")))
 
-(define glib
+(define glib-minimal
   (package
     (name "glib")
     (version "2.82.1")
@@ -524,6 +524,21 @@ (define glib
     (license license:lgpl2.1+)
     (properties '((hidden? . #t)))))
 
+(define glib
+  (let ((base glib-minimal))
+    (package/inherit base
+      (native-inputs
+       (modify-inputs (package-native-inputs base)
+         (prepend gobject-introspection-minimal)))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases)
+          #~(modify-phases #$phases
+              ;; GI tests require installed libraries
+              (delete 'check)
+              (add-after 'install 'check
+                (assoc-ref #$phases 'check)))))))))
+
 (define-public glib-with-documentation
   ;; glib's doc must be built in a separate package since it requires gtk-doc,
   ;; which in turn depends on glib.
@@ -602,7 +617,7 @@ (define (correct-library-name-phase python name)
         (string-append name target-suffix))
       (rename-file native-name target-name)))
 
-(define gobject-introspection
+(define gobject-introspection-minimal
   (package
     (name "gobject-introspection")
     (version "1.82.0")
@@ -659,15 +674,14 @@ (define gobject-introspection
      `(,@(if (%current-target-system)
            `(("python" ,python))
            '())
-       ("glib" ,glib "bin")
+       ("glib" ,glib-minimal "bin")
        ("pkg-config" ,pkg-config)
        ("bison" ,bison)
        ("flex" ,flex)))
     (inputs
-     `(("python" ,python)
-       ("zlib" ,zlib)))
+     (list python zlib))
     (propagated-inputs
-     (list glib
+     (list glib-minimal
            ;; In practice, GIR users will need libffi when using
            ;; gobject-introspection.
            libffi))
@@ -691,6 +705,16 @@ (define gobject-introspection
       ;; For tools.
       license:gpl2+))))
 
+(define gobject-introspection
+  (let ((base gobject-introspection-minimal))
+    (package/inherit base
+      (native-inputs
+       (modify-inputs (package-native-inputs base)
+         (replace "glib" glib)))
+      (propagated-inputs
+       (modify-inputs (package-propagated-inputs base)
+         (replace "glib" glib))))))
+
 (define intltool
   (package
     (name "intltool")
-- 
2.46.0