Subject: bug#75157: Grafting inconsistency with multiple outputs is causing problems

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Thu, 02 Jan 2025 16:20:51 +0100

Hi Dariqq.  Your glib and json bug is indeed different.

Your initial suggestion for a proper fix to the different but similar
troubles we both have:

> I think it would be good if grafts are only applied per output (which 
> might also help resolve #69653).

is the same proposal as in bug#48907.

At https://bugs.gnu.org/48907 Richard Sent wrote:
> One idea I had was to somehow graft each output as a unique derivation
> via repeated calls to graft-derivation. From what I've seen so far
> though that looks much easier said than done. It hasn't progressed
> beyond the "huh, I wonder" phase.

Therefore I will merge the two bugs.

Not entirely sure if this proper fix would currently need changes to the
C++ guix-daemon code.  Anyway, I will not implement it.

Currently we both have workarounds, obviously disabling security updates
with --no-grafts is possible, but also you wrote you can set the
pkgconfig path.  For GTK programs, a workaround is instead of putting

(list gdk-pixbuf
      graphene gtk harfbuzz
      pango)

in your Guix shell manifest or a scheme-file, I could instead rebuild
without grafts, like in Guix’ ungraft manifest.

That is, my previous home configuration for commit
08e0144d2338c8fb51e52e74274554583d0faa69 was:

(service home-sway-service-type
         (sway-configuration
          (startup-programs
           `(,(with-extensions
               (list
                ((options->transformation
                  '((with-commit . "guile-g-golf=v0.8.0-rc9")))
                 guile-g-golf))
               #~(string-append
                  "guile "
                  #$(scheme-file "launcher.scm"
                     #~(begin
                         (eval-when (expand load eval)
                           (use-modules (oop goops))
                           (default-duplicate-binding-handler
                             '(merge-generics replace
                               warn-override-core warn last))
                           (setenv "GI_TYPELIB_PATH"
                                   #$(file-append
                                      (directory-union
                                       "typelibs"
                                       (list gdk-pixbuf
                                             graphene gtk harfbuzz
                                             pango))
                                      "/lib/girepository-1.0"))
                           (use-modules (g-golf))
                           (g-irepository-require
                            "Gtk" #:version "4.0")
                           (for-each (lambda (name)
                                       (gi-import-by-name "Gtk" name))
                                     '("Application"
                                       "ApplicationWindow"
                                       "Builder")))
                         (use-modules (sxml simple))
                         (define ui
                           '(interface
                             (requires (@ (version 4.0) (lib gtk)))

Since then, I have now had to change it to:

(service home-sway-service-type
         (sway-configuration
          (startup-programs
           `(,(with-extensions
               (list
                ((options->transformation
                  '((with-commit . "guile-g-golf=v0.8.0-rc9")))
                 guile-g-golf))
               #~(string-append
                  "guile "
                  #$(scheme-file "launcher.scm"
                     #~(begin
                         (eval-when (expand load eval)
                           (use-modules (oop goops))
                           (default-duplicate-binding-handler
                             '(merge-generics replace
                               warn-override-core warn last))
                           (setenv "GI_TYPELIB_PATH"
                                   #$(file-append
                                      (directory-union
                                       "typelibs"
                                       (let ((ungraft
                                              (package-mapping
                                               (lambda (p)
                                                 (cond
                                                  ;; Ungrafted fails to validate runpath.
                                                  ((string=? (package-name p)
                                                             "gst-plugins-bad")
                                                   (specification->package
                                                    "gst-plugins-bad-minimal"))
                                                  (else
                                                   (let ((old
                                                          (or (package-replacement p) p)))
                                                     (package
                                                      (inherit old)
                                                      (arguments
                                                       (substitute-keyword-arguments
                                                        (package-arguments old)
                                                        ((#:disallowed-references _)  (list))
                                                        ((#:allowed-references _) #f))))))))
                                               #:deep? #t)))
                                         (map ungraft (list gdk-pixbuf
                                                            graphene gtk harfbuzz
                                                            pango))))
                                      "/lib/girepository-1.0"))
                           (use-modules (g-golf))
                           (g-irepository-require
                            "Gtk" #:version "4.0")
                           (for-each (lambda (name)
                                       (gi-import-by-name "Gtk" name))
                                     '("Application"
                                       "ApplicationWindow"
                                       "Builder")))
                         (use-modules (sxml simple))
                         (define ui

Unlike --no-grafts,
this has security updates appropriate for use in production
environments, but rebuilds part of the world, most importantly Rust.
Building bootstrap rust-1.54 fails on my laptop, unless I specify the
common build option --cores=1 in guix build.

I dedicate the above snippet to the public domain as per CC0.
https://creativecommons.org/publicdomain/zero/1.0/legalcode
If someone wishes to use similar code.

Regards,
Florian