[bug#77735] gnu: flatpak: Fix "No GSettings schemas are installed on the system".

Message ID ab0f4a4e16f8aec1f1bfd64fa9ea7739936b89c0.1744371253.git.Rostislav.Svoboda@gmail.com
State New
Headers
Series [bug#77735] gnu: flatpak: Fix "No GSettings schemas are installed on the system". |

Commit Message

Rostislav Svoboda April 11, 2025, 11:36 a.m. UTC
  * gnu/packages/package-management.scm (flatpak)[inputs]: Add
gsettings-desktop-schemas.
<#:phases>: Set GSETTINGS_SCHEMA_DIR in wrap-phase.

This fixes an error that appeared when running system-wide Flatpak
operations such as 'sudo flatpak update':

  GLib-GIO-ERROR [...] No GSettings schemas are installed on the system

The missing schemas from gsettings-desktop-schemas prevented proper GLib
configuration lookups (e.g., org.gnome.system.proxy). By setting
GSETTINGS_SCHEMA_DIR to point to gsettings-desktop-schemas' schema directory,
we ensure Flatpak can access required GLib configuration templates.

Change-Id: I9522c07b6c8ccf20a86ee966effb73eb61a2abc7
---
 gnu/packages/package-management.scm | 261 ++++++++++++++--------------
 1 file changed, 135 insertions(+), 126 deletions(-)


base-commit: 772b70455d0d5972fdad80d8529647dce20f409a
  

Comments

Ludovic Courtès April 16, 2025, 3:31 p.m. UTC | #1
Rostislav Svoboda <rostislav.svoboda@gmail.com> writes:

> * gnu/packages/package-management.scm (flatpak)[inputs]: Add
> gsettings-desktop-schemas.
> <#:phases>: Set GSETTINGS_SCHEMA_DIR in wrap-phase.
>
> This fixes an error that appeared when running system-wide Flatpak
> operations such as 'sudo flatpak update':
>
>   GLib-GIO-ERROR [...] No GSettings schemas are installed on the system
>
> The missing schemas from gsettings-desktop-schemas prevented proper GLib
> configuration lookups (e.g., org.gnome.system.proxy). By setting
> GSETTINGS_SCHEMA_DIR to point to gsettings-desktop-schemas' schema directory,
> we ensure Flatpak can access required GLib configuration templates.
>
> Change-Id: I9522c07b6c8ccf20a86ee966effb73eb61a2abc7

[...]

> +  (let ((release "1.16.0")
> +        (revision "1"))
> +    (package
> +      (name "flatpak")
> +      (version (string-append release "-" revision))

That’s not something we do; just keep the ‘version’ field unchanged.

> +            (add-after 'install 'wrap-flatpak
> +              (lambda* (#:key inputs #:allow-other-keys)
> +                (let ((flatpak (string-append #$output "/bin/flatpak"))
> +                      (glib-networking (assoc-ref inputs "glib-networking")))
> +                  (wrap-program flatpak
> +                    ;; Prevent error:
> +                    ;; "No GSettings schemas are installed on the system"
> +                    `("GSETTINGS_SCHEMA_DIR" =

Should it be ‘prefix’ instead of ‘=’?

Apart from that it LGTM, thanks!

Ludo’.
  
Rostislav Svoboda April 16, 2025, 4:59 p.m. UTC | #2
Hello Ludo

> > +  (let ((release "1.16.0")
> > +        (revision "1"))
> > +    (package
> > +      (name "flatpak")
> > +      (version (string-append release "-" revision))
>
> That’s not something we do; just keep the ‘version’ field unchanged.

I've seen some examples like:

```
$ sed -n "5695,5725p" gnu/packages/maths.scm
(define-public muparser
  ;; When switching download sites, muparser re-issued a 2.2.5 release with a
  ;; different hash. In order to make `guix package --upgrade` work correctly,
  ;; we set a Guix packaging revision.
  ;; When the next version of muparser is released, we can remove
  ;; UPSTREAM-VERSION and REVISION and use the plain VERSION.
  (let ((upstream-version "2.2.5")
        (revision "2"))
    (package
      (name "muparser")
      (version (string-append upstream-version "-" revision))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/beltoforion/muparser")
               (commit (string-append "v" upstream-version))))
         (file-name (git-file-name name version))
         (sha256
          (base32 "0f0g4995xngf1pp3zr4p6ai2f8v6f8bxwa0k8ayjjiv1l8h44m24"))))
      (build-system gnu-build-system)
      (arguments
       `(#:configure-flags '("--enable-samples=no")
         #:tests? #f)) ;no "check" target
      (home-page "http://muparser.beltoforion.de/")
      (synopsis "Fast parser library for mathematical expressions")
      (description
       "muParser is an extensible high performance math parser library.  It is
based on transforming an expression into a bytecode and precalculating constant
parts of it.")
      (license license:expat))))
```

Run `rg --type=lisp --before-context=5 --after-context=2
'version.*string-append.*revision'` to get some more.

(But if you insist then I changed that - see attachment)

> > +            (add-after 'install 'wrap-flatpak
> > +              (lambda* (#:key inputs #:allow-other-keys)
> > +                (let ((flatpak (string-append #$output "/bin/flatpak"))
> > +                      (glib-networking (assoc-ref inputs "glib-networking")))
> > +                  (wrap-program flatpak
> > +                    ;; Prevent error:
> > +                    ;; "No GSettings schemas are installed on the system"
> > +                    `("GSETTINGS_SCHEMA_DIR" =
>
> Should it be ‘prefix’ instead of ‘=’?

I found plenty of examples using '='. E.g.:

```
gnu/packages/containers.scm
682:              (wrap-program (string-append #$output "/bin/buildah")
683-                `("CONTAINERS_HELPER_BINARY_DIR" =
684-                  (,(string-append #$output "/_guix")))

gnu/packages/sawfish.scm
157:                  (wrap-program (string-append out script)
158-                    `("REP_DL_LOAD_PATH" =
159-                      ,(list (getenv "REP_DL_LOAD_PATH")
```

Run `rg --type=lisp --after-context=2 '\(wrap-program'` get some more.

Cheers
Bost
  
Ludovic Courtès April 17, 2025, 8:31 p.m. UTC | #3
Hey Bost,

Rostislav Svoboda <rostislav.svoboda@gmail.com> writes:

> I've seen some examples like:

I don’t doubt there are counterexamples, but! this one:

> (define-public muparser
>   ;; When switching download sites, muparser re-issued a 2.2.5 release with a
>   ;; different hash. In order to make `guix package --upgrade` work correctly,
>   ;; we set a Guix packaging revision.
>   ;; When the next version of muparser is released, we can remove
>   ;; UPSTREAM-VERSION and REVISION and use the plain VERSION.

… apparently had a good reason to do so.  :-)

Not sure about the others.

> (But if you insist then I changed that - see attachment)

Applied, thanks!

Ludo’.
  

Patch

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 81dcf24857..798930588b 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -2040,135 +2040,144 @@  (define-public libostree
     (license license:lgpl2.0+)))
 
 (define-public flatpak
-  (package
-    (name "flatpak")
-    (version "1.16.0")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://github.com/flatpak/flatpak/releases/download/"
-                           version "/flatpak-" version ".tar.xz"))
-       (sha256
-        (base32 "0ajbz8ms4h5nyjr59hv9z8vaimj4f3p51v8idmy14qnbmmjwa2nb"))
-       (patches
-        (search-patches "flatpak-fix-fonts-icons.patch"
-                        "flatpak-fix-path.patch"
-                        "flatpak-fix-icon-validation.patch"
-                        "flatpak-unset-gdk-pixbuf-for-sandbox.patch"))))
-    (build-system meson-build-system)
-    (arguments
-     (list
-      #:configure-flags
-      #~(list
-         "-Dsystem_helper=disabled"
-         "-Dlocalstatedir=/var"
-         (string-append "-Dsystem_bubblewrap="
-                        (assoc-ref %build-inputs "bubblewrap")
-                        "/bin/bwrap")
-         (string-append "-Dsystem_dbus_proxy="
-                        (assoc-ref %build-inputs "xdg-dbus-proxy")
-                        "/bin/xdg-dbus-proxy"))
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'unpack 'disable-failing-tests
-            (lambda _
-              (substitute* "tests/test-matrix/meson.build"
-                ;; The following tests fail with error message related to fusermount3
-                ;; failing an unmount operation ("No such file or directory").
-                (("^.*test-http-utils.*$") "")
-                (("^.*test-summaries@system.wrap.*$") "")
-                (("^.*test-prune.*$") ""))))
-          (add-after 'unpack 'fix-tests
-            (lambda* (#:key inputs #:allow-other-keys)
-              (copy-recursively
-               (search-input-directory inputs "lib/locale")
-               "/tmp/locale")
-              (for-each make-file-writable (find-files "/tmp"))
-              (substitute* "tests/make-test-runtime.sh"
-                (("cp `which.*") "echo guix\n")
-                (("cp -r /usr/lib/locale/C\\.\\*")
-                 (string-append "mkdir ${DIR}/usr/lib/locale/en_US; \
+  (let ((release "1.16.0")
+        (revision "1"))
+    (package
+      (name "flatpak")
+      (version (string-append release "-" revision))
+      (source
+       (origin
+         (method url-fetch)
+         (uri (string-append "https://github.com/flatpak/flatpak/releases/download/"
+                             release "/flatpak-" release ".tar.xz"))
+         (sha256
+          (base32 "0ajbz8ms4h5nyjr59hv9z8vaimj4f3p51v8idmy14qnbmmjwa2nb"))
+         (patches
+          (search-patches "flatpak-fix-fonts-icons.patch"
+                          "flatpak-fix-path.patch"
+                          "flatpak-fix-icon-validation.patch"
+                          "flatpak-unset-gdk-pixbuf-for-sandbox.patch"))))
+      (build-system meson-build-system)
+      (arguments
+       (list
+        #:configure-flags
+        #~(list
+           "-Dsystem_helper=disabled"
+           "-Dlocalstatedir=/var"
+           (string-append "-Dsystem_bubblewrap="
+                          (assoc-ref %build-inputs "bubblewrap")
+                          "/bin/bwrap")
+           (string-append "-Dsystem_dbus_proxy="
+                          (assoc-ref %build-inputs "xdg-dbus-proxy")
+                          "/bin/xdg-dbus-proxy"))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'disable-failing-tests
+              (lambda _
+                (substitute* "tests/test-matrix/meson.build"
+                  ;; The following tests fail with error message related to fusermount3
+                  ;; failing an unmount operation ("No such file or directory").
+                  (("^.*test-http-utils.*$") "")
+                  (("^.*test-summaries@system.wrap.*$") "")
+                  (("^.*test-prune.*$") ""))))
+            (add-after 'unpack 'fix-tests
+              (lambda* (#:key inputs #:allow-other-keys)
+                (copy-recursively
+                 (search-input-directory inputs "lib/locale")
+                 "/tmp/locale")
+                (for-each make-file-writable (find-files "/tmp"))
+                (substitute* "tests/make-test-runtime.sh"
+                  (("cp `which.*") "echo guix\n")
+                  (("cp -r /usr/lib/locale/C\\.\\*")
+                   (string-append "mkdir ${DIR}/usr/lib/locale/en_US; \
 cp -r /tmp/locale/*/en_US.*")))
-              (substitute* "tests/libtest.sh"
-                (("/bin/kill") (which "kill"))
-                (("/usr/bin/python3") (which "python3")))
-              #t))
-          (add-after 'unpack 'p11-kit-fix
-            (lambda* (#:key inputs #:allow-other-keys)
-              (let ((p11-path (search-input-file inputs "/bin/p11-kit")))
-                (substitute* "session-helper/flatpak-session-helper.c"
-                  (("\"p11-kit\",")
-                   (string-append "\"" p11-path "\","))
-                  (("if \\(g_find_program_in_path \\(\"p11-kit\"\\)\\)")
-                   (string-append "if (g_find_program_in_path (\""
-                                  p11-path "\"))"))))))
-          (add-after 'unpack 'fix-icon-validation
-            (lambda* (#:key outputs #:allow-other-keys)
-              (let* ((out (assoc-ref outputs "out"))
-                     (store (dirname out)))
-                (substitute* "icon-validator/validate-icon.c"
-                  (("@storeDir@") store)))))
-          (add-before 'check 'pre-check
-            (lambda _
-              ;; Set $HOME to writable location for testcommon tests.
-              (setenv "HOME" "/tmp")))
-          (add-after 'install 'wrap-flatpak
-            (lambda* (#:key inputs #:allow-other-keys)
-              (let ((flatpak (string-append #$output "/bin/flatpak"))
-                    (glib-networking (assoc-ref inputs "glib-networking")))
-                (wrap-program flatpak
-                  ;; Allow GIO to find TLS backend.
-                  `("GIO_EXTRA_MODULES" prefix
-                    (,(string-append glib-networking "/lib/gio/modules"))))))))))
-    (native-inputs
-     (list bison
-           dbus ; for dbus-daemon
-           gettext-minimal
-           `(,glib "bin") ; for glib-mkenums + gdbus-codegen
-           gtk-doc
-           (libc-utf8-locales-for-target)
-           gobject-introspection
-           libcap
-           pkg-config
-           python
-           python-pyparsing
-           socat
-           which))
-    (inputs
-     (list appstream
-           appstream-glib
-           bash-minimal
-           bubblewrap
-           curl
-           fuse
-           gdk-pixbuf
-           libcap
-           libostree
-           libsoup-minimal-2
-           libxml2
-           p11-kit
-           polkit
-           util-linux
-           xdg-dbus-proxy
-           zstd))
-    (propagated-inputs (list glib-networking
-                             gnupg
-                             gsettings-desktop-schemas
-                             ;; The following are listed in Requires.private of
-                             ;; `flatpak.pc'.
-                             curl
-                             dconf
-                             gpgme
-                             json-glib
-                             libarchive
-                             libseccomp
-                             libxau))
-    (home-page "https://flatpak.org")
-    (synopsis "System for building, distributing, and running sandboxed desktop
+                (substitute* "tests/libtest.sh"
+                  (("/bin/kill") (which "kill"))
+                  (("/usr/bin/python3") (which "python3")))
+                #t))
+            (add-after 'unpack 'p11-kit-fix
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((p11-path (search-input-file inputs "/bin/p11-kit")))
+                  (substitute* "session-helper/flatpak-session-helper.c"
+                    (("\"p11-kit\",")
+                     (string-append "\"" p11-path "\","))
+                    (("if \\(g_find_program_in_path \\(\"p11-kit\"\\)\\)")
+                     (string-append "if (g_find_program_in_path (\""
+                                    p11-path "\"))"))))))
+            (add-after 'unpack 'fix-icon-validation
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let* ((out (assoc-ref outputs "out"))
+                       (store (dirname out)))
+                  (substitute* "icon-validator/validate-icon.c"
+                    (("@storeDir@") store)))))
+            (add-before 'check 'pre-check
+              (lambda _
+                ;; Set $HOME to writable location for testcommon tests.
+                (setenv "HOME" "/tmp")))
+            (add-after 'install 'wrap-flatpak
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((flatpak (string-append #$output "/bin/flatpak"))
+                      (glib-networking (assoc-ref inputs "glib-networking")))
+                  (wrap-program flatpak
+                    ;; Prevent error:
+                    ;; "No GSettings schemas are installed on the system"
+                    `("GSETTINGS_SCHEMA_DIR" =
+                      (, (string-append
+                          #$(this-package-input "gsettings-desktop-schemas")
+                          "/share/glib-2.0/schemas")))
+                    ;; Allow GIO to find TLS backend.
+                    `("GIO_EXTRA_MODULES" prefix
+                      (,(string-append glib-networking "/lib/gio/modules"))))))))))
+      (native-inputs
+       (list bison
+             dbus ; for dbus-daemon
+             gettext-minimal
+             `(,glib "bin") ; for glib-mkenums + gdbus-codegen
+             gtk-doc
+             (libc-utf8-locales-for-target)
+             gobject-introspection
+             libcap
+             pkg-config
+             python
+             python-pyparsing
+             socat
+             which))
+      (inputs
+       (list appstream
+             appstream-glib
+             bash-minimal
+             bubblewrap
+             curl
+             fuse
+             gsettings-desktop-schemas
+             gdk-pixbuf
+             libcap
+             libostree
+             libsoup-minimal-2
+             libxml2
+             p11-kit
+             polkit
+             util-linux
+             xdg-dbus-proxy
+             zstd))
+      (propagated-inputs (list glib-networking
+                               gnupg
+                               gsettings-desktop-schemas
+                               ;; The following are listed in Requires.private of
+                               ;; `flatpak.pc'.
+                               curl
+                               dconf
+                               gpgme
+                               json-glib
+                               libarchive
+                               libseccomp
+                               libxau))
+      (home-page "https://flatpak.org")
+      (synopsis "System for building, distributing, and running sandboxed desktop
 applications")
-    (description "Flatpak is a system for building, distributing, and running
+      (description "Flatpak is a system for building, distributing, and running
 sandboxed desktop applications on GNU/Linux.")
-    (license license:lgpl2.1+)))
+      (license license:lgpl2.1+))))
 
 (define-public fpm
   (package