all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
@ 2014-12-18 21:10 Federico Beffa
  2014-12-19 12:56 ` 宋文武
  0 siblings, 1 reply; 17+ messages in thread
From: Federico Beffa @ 2014-12-18 21:10 UTC (permalink / raw
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

I added support for GIO and theming data according to the XDG specifications.

https://developer.gnome.org/gio/stable/running-gio-apps.html
http://www.freedesktop.org/wiki/Specifications/

Regards,
Fede

[-- Attachment #2: 0001-guix-build-glib-or-gtk-build-system-Add-support-for-.patch --]
[-- Type: text/x-patch, Size: 9411 bytes --]

From c726b525111ff2f8055f7f2be98b7a5e61a8a96e Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Thu, 18 Dec 2014 20:58:18 +0100
Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO
 and XDG theming.

* guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
  'schemas-directories' to 'data-directories' and add support for XDG theming
  data.

* guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
  function.

* guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update names to
  reflect that we are dealing with more types of data and not only with
  schemas.  Add handling of GIO modules.

* guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of GLib
  instead of 'out'.  This was an error since we need the program
  'glib-compile-schemas'.  Update the description.
---
 guix/build-system/glib-or-gtk.scm       | 11 ++--
 guix/build/glib-or-gtk-build-system.scm | 99 ++++++++++++++++++++++++++-------
 2 files changed, 84 insertions(+), 26 deletions(-)

diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
index 8091311..ff95ca5 100644
--- a/guix/build-system/glib-or-gtk.scm
+++ b/guix/build-system/glib-or-gtk.scm
@@ -38,11 +38,10 @@
 ;;
 ;; 'glib-or-gtk-wrap' phase:
 ;;
-;; a) This phase looks for GSettings schemas by verifying the existence of
-;; path "datadir/glib-2.0/schemas" in all input packages.  If the path is
-;; found in any package, then all programs in "out/bin" are wrapped in scripts
-;; where the environment variable "XDG_DATA_DIRS" is set and points to the
-;; list of found schemas directories.
+;; a) This phase looks for GSettings schemas, GIO modules and theming data.
+;; If any of these is found in any input package, then all programs in
+;; "out/bin" are wrapped in scripts defining the nedessary environment
+;; variables.
 ;;
 ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all input
 ;; packages.  If any is found, then the environment variable "GTK_PATH" is
@@ -95,7 +94,7 @@
                               `(("source" ,source))
                               '())
                         ,@inputs))
-         (build-inputs `(("glib:bin" ,glib)
+         (build-inputs `(("glib:bin" ,glib "bin")
                          ,@(if implicit-inputs?
                                (standard-packages)
                                '())
diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm
index 9351a70..712087e 100644
--- a/guix/build/glib-or-gtk-build-system.scm
+++ b/guix/build/glib-or-gtk-build-system.scm
@@ -41,6 +41,9 @@
   (fold (lambda (s p) (or (string-ci=? s directory) p))
         #f directories-list))
 
+;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not
+;; want to mix gtk+-2 and gtk+-3 modules.  See
+;; https://developer.gnome.org/gtk3/stable/gtk-running.html
 (define (gtk-module-directories inputs)
   "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a list
 with all found directories."
@@ -64,20 +67,68 @@ with all found directories."
                   prev)))))
     (fold gtk-module '() inputs)))
 
-(define (schemas-directories inputs)
-  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.  Return
-a list with all found directories."
-  (define (glib-schemas input previous)
+;; We include $HOME/.guix-profile/share so that if the user installs a
+;; desktop, a sound or an icon theme, the application should be able to see
+;; it, without having to add the theme to the application inputs.  See
+;; http://www.freedesktop.org/wiki/DesktopThemeSpec
+;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
+;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
+;; 
+;; Currently desktop themes are not well supported and do not honor
+;; XDG_DATA_DIRS.  One example is evince which only looks for desktop themes
+;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which
+;; defaults to $HOME/.local/share).  One way to handle these applications
+;; appears to be by making $HOME/.themes a symlink to
+;; $HOME/.guix-profile/share/themes.
+;;
+;; Note however that GLib's schemas added in $HOME/.guix-profile/share by the
+;; installation of a library or application will not necessarily work.  This
+;; is because GLib only looks for compiled schemas (in a file called
+;; gschemas.compiled) and currently $HOME/.guix-profile/share does not include
+;; such a file comprising all XML schemas visible in that directory.
+(define (data-directories inputs)
+  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data
+in INPUTS.  Return a list with all found directories."
+  (define (data-directory input previous)
     (let* ((in (match input
                  ((_ . dir) dir)
                  (_ "")))
            (datadir (string-append in "/share")))
-      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
+      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
+                   (subdirectory-exists? datadir "/sounds")
+                   (subdirectory-exists? datadir "/themes")
+                   (subdirectory-exists? datadir "/cursors")
+                   (subdirectory-exists? datadir "/wallpapers")
+                   (subdirectory-exists? datadir "/icons"))                   
                (not (directory-included? datadir previous)))
           (cons datadir previous)
           previous)))
 
-  (fold glib-schemas '() inputs))
+  (fold data-directory '("$HOME/.guix-profile/share") inputs))
+
+;; All GIO modules are expected to be installed in GLib's $libdir/gio/modules
+;; directory.  That directory has to include a file called giomodule.cache
+;; listing all available modules.  GIO can be made aware of modules in other
+;; directories with the help of the environment variable GIO_EXTRA_MODULES.
+;; The official GIO documentation states that this environment variable should
+;; only be used for testing and not in a production environment.  However, it
+;; appears that there is no other way of specifying multiple modules
+;; directories (NIXOS also does use this variable). See
+;; https://developer.gnome.org/gio/stable/running-gio-apps.html
+(define (gio-module-directories inputs)
+  "Check for the existence of \"$libdir/gio/modules\" in the INPUTS and
+returns a list with all found directories."
+  (define (gio-module-directory input previous)
+    (let* ((in (match input
+                 ((_ . dir) dir)
+                 (_ "")))
+           (gio-mod-dir (string-append in "/lib/gio/modules")))
+      (if (and (directory-exists? gio-mod-dir)
+               (not (directory-included? gio-mod-dir previous)))
+          (cons gio-mod-dir previous)
+          previous)))
+
+  (fold gio-module-directory '("$HOME/.guix-profile/gio/modules") inputs))
 
 (define* (wrap-all-programs #:key inputs outputs
                             (glib-or-gtk-wrap-excluded-outputs '())
@@ -96,28 +147,36 @@ add a dependency of that output on GLib and GTK+."
       (unless (member output glib-or-gtk-wrap-excluded-outputs)
         (let* ((bindir       (string-append directory "/bin"))
                (bin-list     (find-files bindir ".*"))
-               (schemas      (schemas-directories
+               (datadirs     (data-directories
                               (alist-cons output directory inputs)))
                (gtk-mod-dirs (gtk-module-directories
                               (alist-cons output directory inputs)))
-               (schemas-env-var
-                (if (not (null? schemas))
-                    `("XDG_DATA_DIRS" ":" prefix ,schemas)
+               (gio-mod-dirs (gio-module-directories
+                              (alist-cons output directory inputs)))
+               (data-env-var
+                (if (not (null? datadirs))
+                    `("XDG_DATA_DIRS" ":" prefix ,datadirs)
                     #f))
                (gtk-mod-env-var
                 (if (not (null? gtk-mod-dirs))
                     `("GTK_PATH" ":" prefix ,gtk-mod-dirs)
+                    #f))
+               (gio-mod-env-var 
+                (if (not (null? gio-mod-dirs))
+                    `("GIO_EXTRA_MODULES" ":" prefix ,gio-mod-dirs)
                     #f)))
-          (cond
-           ((and schemas-env-var gtk-mod-env-var)
-            (for-each (cut wrap-program <> schemas-env-var gtk-mod-env-var)
-                      bin-list))
-           (schemas-env-var
-            (for-each (cut wrap-program <> schemas-env-var)
-                      bin-list))
-           (gtk-mod-env-var
-            (for-each (cut wrap-program <> gtk-mod-env-var)
-                      bin-list))))))))
+          ;; Since datadirs and gio-mod-dirs are the result of fold with an
+          ;; initial value, data-env-var and gio-mod-env-var can't be #f
+          (if gtk-mod-env-var 
+              (for-each (cut wrap-program <>
+                             data-env-var
+                             gtk-mod-env-var
+                             gio-mod-env-var)
+                        bin-list)
+              (for-each (cut wrap-program <>
+                             data-env-var
+                             gio-mod-env-var)
+                        bin-list)))))))
 
   (for-each handle-output outputs)
   #t)
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2014-12-18 21:10 [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming Federico Beffa
@ 2014-12-19 12:56 ` 宋文武
  2014-12-21  9:41   ` Federico Beffa
  0 siblings, 1 reply; 17+ messages in thread
From: 宋文武 @ 2014-12-19 12:56 UTC (permalink / raw
  To: Federico Beffa, Guix-devel

Federico Beffa <beffa@ieee.org> writes:

> I added support for GIO and theming data according to the XDG specifications.
>
> https://developer.gnome.org/gio/stable/running-gio-apps.html
> http://www.freedesktop.org/wiki/Specifications/
>
> Regards,
> Fede
> From c726b525111ff2f8055f7f2be98b7a5e61a8a96e Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Thu, 18 Dec 2014 20:58:18 +0100
> Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO
>  and XDG theming.
>
> * guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
>   'schemas-directories' to 'data-directories' and add support for XDG theming
>   data.
>
> * guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
>   function.
>
> * guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update names to
>   reflect that we are dealing with more types of data and not only with
>   schemas.  Add handling of GIO modules.
>
> * guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of GLib
>   instead of 'out'.  This was an error since we need the program
>   'glib-compile-schemas'.  Update the description.
> ---
>  guix/build-system/glib-or-gtk.scm       | 11 ++--
>  guix/build/glib-or-gtk-build-system.scm | 99 ++++++++++++++++++++++++++-------
>  2 files changed, 84 insertions(+), 26 deletions(-)
>
> diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
> index 8091311..ff95ca5 100644
> --- a/guix/build-system/glib-or-gtk.scm
> +++ b/guix/build-system/glib-or-gtk.scm
> @@ -38,11 +38,10 @@
>  ;;
>  ;; 'glib-or-gtk-wrap' phase:
>  ;;
> -;; a) This phase looks for GSettings schemas by verifying the existence of
> -;; path "datadir/glib-2.0/schemas" in all input packages.  If the path is
> -;; found in any package, then all programs in "out/bin" are wrapped in scripts
> -;; where the environment variable "XDG_DATA_DIRS" is set and points to the
> -;; list of found schemas directories.
> +;; a) This phase looks for GSettings schemas, GIO modules and theming data.
> +;; If any of these is found in any input package, then all programs in
> +;; "out/bin" are wrapped in scripts defining the nedessary environment
> +;; variables.
>  ;;
>  ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all input
>  ;; packages.  If any is found, then the environment variable "GTK_PATH" is
> @@ -95,7 +94,7 @@
>                                `(("source" ,source))
>                                '())
>                          ,@inputs))
> -         (build-inputs `(("glib:bin" ,glib)
> +         (build-inputs `(("glib:bin" ,glib "bin")
>                           ,@(if implicit-inputs?
>                                 (standard-packages)
>                                 '())
> diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm
> index 9351a70..712087e 100644
> --- a/guix/build/glib-or-gtk-build-system.scm
> +++ b/guix/build/glib-or-gtk-build-system.scm
> @@ -41,6 +41,9 @@
>    (fold (lambda (s p) (or (string-ci=? s directory) p))
>          #f directories-list))
>  
> +;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not
> +;; want to mix gtk+-2 and gtk+-3 modules.  See
> +;; https://developer.gnome.org/gtk3/stable/gtk-running.html
>  (define (gtk-module-directories inputs)
>    "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a list
>  with all found directories."
> @@ -64,20 +67,68 @@ with all found directories."
>                    prev)))))
>      (fold gtk-module '() inputs)))
>  
> -(define (schemas-directories inputs)
> -  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.  Return
> -a list with all found directories."
> -  (define (glib-schemas input previous)
> +;; We include $HOME/.guix-profile/share so that if the user installs a
> +;; desktop, a sound or an icon theme, the application should be able to see
> +;; it, without having to add the theme to the application inputs.  See
> +;; http://www.freedesktop.org/wiki/DesktopThemeSpec
> +;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
> +;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
FYI, every apps will install icons into 'hicolor-icon-theme',
for it to work, we need regenerated the 'icon-theme.cache'
by `gtk-update-icon-cache`.
> +;; 
> +;; Currently desktop themes are not well supported and do not honor
> +;; XDG_DATA_DIRS.  One example is evince which only looks for desktop themes
> +;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which
> +;; defaults to $HOME/.local/share).  One way to handle these applications
> +;; appears to be by making $HOME/.themes a symlink to
> +;; $HOME/.guix-profile/share/themes.
> +;;
> +;; Note however that GLib's schemas added in $HOME/.guix-profile/share by the
> +;; installation of a library or application will not necessarily work.  This
> +;; is because GLib only looks for compiled schemas (in a file called
> +;; gschemas.compiled) and currently $HOME/.guix-profile/share does not include
> +;; such a file comprising all XML schemas visible in that directory.
> +(define (data-directories inputs)
> +  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data
> +in INPUTS.  Return a list with all found directories."
> +  (define (data-directory input previous)
>      (let* ((in (match input
>                   ((_ . dir) dir)
>                   (_ "")))
>             (datadir (string-append in "/share")))
> -      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
> +      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
> +                   (subdirectory-exists? datadir "/sounds")
> +                   (subdirectory-exists? datadir "/themes")
> +                   (subdirectory-exists? datadir "/cursors")
> +                   (subdirectory-exists? datadir "/wallpapers")
> +                   (subdirectory-exists? datadir "/icons"))                   
>                 (not (directory-included? datadir previous)))
>            (cons datadir previous)
>            previous)))
>  
> -  (fold glib-schemas '() inputs))
> +  (fold data-directory '("$HOME/.guix-profile/share") inputs))
> +
> +;; All GIO modules are expected to be installed in GLib's $libdir/gio/modules
> +;; directory.  That directory has to include a file called giomodule.cache
> +;; listing all available modules.  GIO can be made aware of modules in other
> +;; directories with the help of the environment variable GIO_EXTRA_MODULES.
> +;; The official GIO documentation states that this environment variable should
> +;; only be used for testing and not in a production environment.  However, it
> +;; appears that there is no other way of specifying multiple modules
> +;; directories (NIXOS also does use this variable). See
> +;; https://developer.gnome.org/gio/stable/running-gio-apps.html
> +(define (gio-module-directories inputs)
> +  "Check for the existence of \"$libdir/gio/modules\" in the INPUTS and
> +returns a list with all found directories."
> +  (define (gio-module-directory input previous)
> +    (let* ((in (match input
> +                 ((_ . dir) dir)
> +                 (_ "")))
> +           (gio-mod-dir (string-append in "/lib/gio/modules")))
> +      (if (and (directory-exists? gio-mod-dir)
> +               (not (directory-included? gio-mod-dir previous)))
> +          (cons gio-mod-dir previous)
> +          previous)))
> +
> +  (fold gio-module-directory '("$HOME/.guix-profile/gio/modules")
> inputs))
We should avoid hardcoding guix-profile or current-system to packages.
IMO, for those kind of things, a better place would be '/etc/profile'.

And, apps will crash when user has incompatible gio modules, See:

    https://github.com/NixOS/nixpkgs/issues/1357
>  
>  (define* (wrap-all-programs #:key inputs outputs
>                              (glib-or-gtk-wrap-excluded-outputs '())
> @@ -96,28 +147,36 @@ add a dependency of that output on GLib and GTK+."
>        (unless (member output glib-or-gtk-wrap-excluded-outputs)
>          (let* ((bindir       (string-append directory "/bin"))
>                 (bin-list     (find-files bindir ".*"))
> -               (schemas      (schemas-directories
> +               (datadirs     (data-directories
>                                (alist-cons output directory inputs)))
>                 (gtk-mod-dirs (gtk-module-directories
>                                (alist-cons output directory inputs)))
> -               (schemas-env-var
> -                (if (not (null? schemas))
> -                    `("XDG_DATA_DIRS" ":" prefix ,schemas)
> +               (gio-mod-dirs (gio-module-directories
> +                              (alist-cons output directory inputs)))
> +               (data-env-var
> +                (if (not (null? datadirs))
> +                    `("XDG_DATA_DIRS" ":" prefix ,datadirs)
>                      #f))
>                 (gtk-mod-env-var
>                  (if (not (null? gtk-mod-dirs))
>                      `("GTK_PATH" ":" prefix ,gtk-mod-dirs)
> +                    #f))
> +               (gio-mod-env-var 
> +                (if (not (null? gio-mod-dirs))
> +                    `("GIO_EXTRA_MODULES" ":" prefix ,gio-mod-dirs)
>                      #f)))
> -          (cond
> -           ((and schemas-env-var gtk-mod-env-var)
> -            (for-each (cut wrap-program <> schemas-env-var gtk-mod-env-var)
> -                      bin-list))
> -           (schemas-env-var
> -            (for-each (cut wrap-program <> schemas-env-var)
> -                      bin-list))
> -           (gtk-mod-env-var
> -            (for-each (cut wrap-program <> gtk-mod-env-var)
> -                      bin-list))))))))
> +          ;; Since datadirs and gio-mod-dirs are the result of fold with an
> +          ;; initial value, data-env-var and gio-mod-env-var can't be #f
> +          (if gtk-mod-env-var 
> +              (for-each (cut wrap-program <>
> +                             data-env-var
> +                             gtk-mod-env-var
> +                             gio-mod-env-var)
> +                        bin-list)
> +              (for-each (cut wrap-program <>
> +                             data-env-var
> +                             gio-mod-env-var)
> +                        bin-list)))))))
>  
>    (for-each handle-output outputs)
>    #t)
> -- 
> 1.8.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2014-12-19 12:56 ` 宋文武
@ 2014-12-21  9:41   ` Federico Beffa
  2014-12-21 10:54     ` Ludovic Courtès
  0 siblings, 1 reply; 17+ messages in thread
From: Federico Beffa @ 2014-12-21  9:41 UTC (permalink / raw
  To: 宋文武; +Cc: Guix-devel

On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
> FYI, every apps will install icons into 'hicolor-icon-theme',
> for it to work, we need regenerated the 'icon-theme.cache'
> by `gtk-update-icon-cache`.

The icon packages that I looked into are generating the cache by
themselves at installation.  In any case, I think we can add a check
similar to one we do for schemas, just in case some icon packages do
not generate the cache.

> We should avoid hardcoding guix-profile or current-system to packages.
> IMO, for those kind of things, a better place would be '/etc/profile'.
>
> And, apps will crash when user has incompatible gio modules, See:
>
>     https://github.com/NixOS/nixpkgs/issues/1357

I agree, keeping the guix-profile out is actually increasing flexibility.

Thanks for the review and the suggestions!
I will update the patch accordingly.

Regards,
Fede

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2014-12-21  9:41   ` Federico Beffa
@ 2014-12-21 10:54     ` Ludovic Courtès
  2015-01-07 17:27       ` Federico Beffa
  0 siblings, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2014-12-21 10:54 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
>> FYI, every apps will install icons into 'hicolor-icon-theme',
>> for it to work, we need regenerated the 'icon-theme.cache'
>> by `gtk-update-icon-cache`.
>
> The icon packages that I looked into are generating the cache by
> themselves at installation.  In any case, I think we can add a check
> similar to one we do for schemas, just in case some icon packages do
> not generate the cache.

Agreed.

Ludo’.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2014-12-21 10:54     ` Ludovic Courtès
@ 2015-01-07 17:27       ` Federico Beffa
  2015-01-08 12:39         ` 宋文武
  0 siblings, 1 reply; 17+ messages in thread
From: Federico Beffa @ 2015-01-07 17:27 UTC (permalink / raw
  To: Ludovic Courtès; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

On Sun, Dec 21, 2014 at 11:54 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>
>> On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
>>> FYI, every apps will install icons into 'hicolor-icon-theme',
>>> for it to work, we need regenerated the 'icon-theme.cache'
>>> by `gtk-update-icon-cache`.
>>
>> The icon packages that I looked into are generating the cache by
>> themselves at installation.  In any case, I think we can add a check
>> similar to one we do for schemas, just in case some icon packages do
>> not generate the cache.
>
> Agreed.

Please find attached an updated patch.

Regards,
Fede

[-- Attachment #2: 0001-guix-build-glib-or-gtk-build-system-Add-support-for-.patch --]
[-- Type: text/x-patch, Size: 13348 bytes --]

From 4191ba9b8c86adaf9477e71a3a9f03cb04fc6528 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Thu, 18 Dec 2014 20:58:18 +0100
Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO
 and XDG theming.

* guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
  'schemas-directories' to 'data-directories' and add support for XDG theming
  data.

* guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
  function.

* guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update names to
  reflect that we are dealing with more types of data and not only with
  schemas.  Add handling of GIO modules.

* guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of GLib
  instead of 'out'.  This was an error since we need the program
  'glib-compile-schemas'.  Update the description.
---
 guix/build-system/glib-or-gtk.scm       |  30 ++++---
 guix/build/glib-or-gtk-build-system.scm | 138 +++++++++++++++++++++++++++-----
 2 files changed, 141 insertions(+), 27 deletions(-)

diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
index 8091311..7a90587 100644
--- a/guix/build-system/glib-or-gtk.scm
+++ b/guix/build-system/glib-or-gtk.scm
@@ -34,15 +34,14 @@
 ;; This build system is an extension of the 'gnu-build-system'.  It
 ;; accomodates the needs of applications making use of glib or gtk+ (with "or"
 ;; to be interpreted in the mathematical sense).  This is achieved by adding
-;; two phases run after the 'install' phase:
+;; three phases run after the 'install' phase:
 ;;
 ;; 'glib-or-gtk-wrap' phase:
 ;;
-;; a) This phase looks for GSettings schemas by verifying the existence of
-;; path "datadir/glib-2.0/schemas" in all input packages.  If the path is
-;; found in any package, then all programs in "out/bin" are wrapped in scripts
-;; where the environment variable "XDG_DATA_DIRS" is set and points to the
-;; list of found schemas directories.
+;; a) This phase looks for GSettings schemas, GIO modules and theming data.
+;; If any of these is found in any input package, then all programs in
+;; "out/bin" are wrapped in scripts defining the nedessary environment
+;; variables.
 ;;
 ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all input
 ;; packages.  If any is found, then the environment variable "GTK_PATH" is
@@ -56,6 +55,11 @@
 ;; exists and does not include a file named "gschemas.compiled", then
 ;; "glib-compile-schemas" is run in that directory.
 ;;
+;; 'glib-or-gtk-icon-cache' phase:
+;;
+;; Looks for the existence of icon themes and, if no cache exists, generate
+;; the "icon-theme.cache" file.
+;;
 ;; Code:
 
 (define %default-modules
@@ -76,15 +80,22 @@
   (let ((module (resolve-interface '(gnu packages glib))))
     (module-ref module 'glib)))
 
+(define (default-gtk+)
+  "Return the default gtk+ package from which we use
+\"gtk-update-icon-cache\"."
+  (let ((module (resolve-interface '(gnu packages gtk))))
+    (module-ref module 'gtk+)))
+
 (define* (lower name
                 #:key source inputs native-inputs outputs system target
-                (glib (default-glib)) (implicit-inputs? #t)
+                (glib (default-glib)) (gtk+ (default-gtk+))
+                (implicit-inputs? #t)
                 (strip-binaries? #t)
                 #:allow-other-keys
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    '(#:source #:target #:glib #:inputs #:native-inputs
+    '(#:source #:target #:glib #:gtk+ #:inputs #:native-inputs
       #:outputs #:implicit-inputs?))
 
   (and (not target)                               ;XXX: no cross-compilation
@@ -95,7 +106,8 @@
                               `(("source" ,source))
                               '())
                         ,@inputs))
-         (build-inputs `(("glib:bin" ,glib)
+         (build-inputs `(("glib:bin" ,glib "bin") ; to compile schemas
+                         ("gtk+" ,gtk+)           ; to generate icon cache
                          ,@(if implicit-inputs?
                                (standard-packages)
                                '())
diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm
index 9351a70..2fe7aa4 100644
--- a/guix/build/glib-or-gtk-build-system.scm
+++ b/guix/build/glib-or-gtk-build-system.scm
@@ -22,6 +22,7 @@
   #:use-module (guix build utils)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 ftw)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -41,6 +42,9 @@
   (fold (lambda (s p) (or (string-ci=? s directory) p))
         #f directories-list))
 
+;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not
+;; want to mix gtk+-2 and gtk+-3 modules.  See
+;; https://developer.gnome.org/gtk3/stable/gtk-running.html
 (define (gtk-module-directories inputs)
   "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a list
 with all found directories."
@@ -64,20 +68,60 @@ with all found directories."
                   prev)))))
     (fold gtk-module '() inputs)))
 
-(define (schemas-directories inputs)
-  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.  Return
-a list with all found directories."
-  (define (glib-schemas input previous)
+;; See
+;; http://www.freedesktop.org/wiki/DesktopThemeSpec
+;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
+;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
+;; 
+;; Currently desktop themes are not well supported and do not honor
+;; XDG_DATA_DIRS.  One example is evince which only looks for desktop themes
+;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which
+;; defaults to $HOME/.local/share).  One way to handle these applications
+;; appears to be by making $HOME/.themes a symlink to
+;; $HOME/.guix-profile/share/themes.
+(define (data-directories inputs)
+  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data
+in INPUTS.  Return a list with all found directories."
+  (define (data-directory input previous)
     (let* ((in (match input
                  ((_ . dir) dir)
                  (_ "")))
            (datadir (string-append in "/share")))
-      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
+      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
+                   (subdirectory-exists? datadir "/sounds")
+                   (subdirectory-exists? datadir "/themes")
+                   (subdirectory-exists? datadir "/cursors")
+                   (subdirectory-exists? datadir "/wallpapers")
+                   (subdirectory-exists? datadir "/icons"))                   
                (not (directory-included? datadir previous)))
           (cons datadir previous)
           previous)))
 
-  (fold glib-schemas '() inputs))
+  (fold data-directory '() inputs))
+
+;; All GIO modules are expected to be installed in GLib's $libdir/gio/modules
+;; directory.  That directory has to include a file called giomodule.cache
+;; listing all available modules.  GIO can be made aware of modules in other
+;; directories with the help of the environment variable GIO_EXTRA_MODULES.
+;; The official GIO documentation states that this environment variable should
+;; only be used for testing and not in a production environment.  However, it
+;; appears that there is no other way of specifying multiple modules
+;; directories (NIXOS also does use this variable). See
+;; https://developer.gnome.org/gio/stable/running-gio-apps.html
+(define (gio-module-directories inputs)
+  "Check for the existence of \"$libdir/gio/modules\" in the INPUTS and
+returns a list with all found directories."
+  (define (gio-module-directory input previous)
+    (let* ((in (match input
+                 ((_ . dir) dir)
+                 (_ "")))
+           (gio-mod-dir (string-append in "/lib/gio/modules")))
+      (if (and (directory-exists? gio-mod-dir)
+               (not (directory-included? gio-mod-dir previous)))
+          (cons gio-mod-dir previous)
+          previous)))
+
+  (fold gio-module-directory '() inputs))
 
 (define* (wrap-all-programs #:key inputs outputs
                             (glib-or-gtk-wrap-excluded-outputs '())
@@ -96,27 +140,57 @@ add a dependency of that output on GLib and GTK+."
       (unless (member output glib-or-gtk-wrap-excluded-outputs)
         (let* ((bindir       (string-append directory "/bin"))
                (bin-list     (find-files bindir ".*"))
-               (schemas      (schemas-directories
+               (datadirs     (data-directories
                               (alist-cons output directory inputs)))
                (gtk-mod-dirs (gtk-module-directories
                               (alist-cons output directory inputs)))
-               (schemas-env-var
-                (if (not (null? schemas))
-                    `("XDG_DATA_DIRS" ":" prefix ,schemas)
+               (gio-mod-dirs (gio-module-directories
+                              (alist-cons output directory inputs)))
+               (data-env-var
+                (if (not (null? datadirs))
+                    `("XDG_DATA_DIRS" ":" prefix ,datadirs)
                     #f))
                (gtk-mod-env-var
                 (if (not (null? gtk-mod-dirs))
                     `("GTK_PATH" ":" prefix ,gtk-mod-dirs)
+                    #f))
+               (gio-mod-env-var 
+                (if (not (null? gio-mod-dirs))
+                    `("GIO_EXTRA_MODULES" ":" prefix ,gio-mod-dirs)
                     #f)))
           (cond
-           ((and schemas-env-var gtk-mod-env-var)
-            (for-each (cut wrap-program <> schemas-env-var gtk-mod-env-var)
+           ((and data-env-var gtk-mod-env-var gio-mod-env-var)
+            (for-each (cut wrap-program <>
+                           data-env-var
+                           gtk-mod-env-var
+                           gio-mod-env-var)
                       bin-list))
-           (schemas-env-var
-            (for-each (cut wrap-program <> schemas-env-var)
+           ((and data-env-var gtk-mod-env-var (not gio-mod-env-var))
+            (for-each (cut wrap-program <>
+                           data-env-var
+                           gtk-mod-env-var)
                       bin-list))
-           (gtk-mod-env-var
-            (for-each (cut wrap-program <> gtk-mod-env-var)
+           ((and data-env-var (not gtk-mod-env-var) gio-mod-env-var)
+            (for-each (cut wrap-program <>
+                           data-env-var
+                           gio-mod-env-var)
+                      bin-list))
+           ((and (not data-env-var) gtk-mod-env-var gio-mod-env-var)
+            (for-each (cut wrap-program <>
+                           gio-mod-env-var
+                           gtk-mod-env-var)
+                      bin-list))
+           ((and data-env-var (not gtk-mod-env-var) (not gio-mod-env-var))
+            (for-each (cut wrap-program <>
+                           data-env-var)
+                      bin-list))
+           ((and (not data-env-var) gtk-mod-env-var (not gio-mod-env-var))
+            (for-each (cut wrap-program <>
+                           gtk-mod-env-var)
+                      bin-list))
+           ((and (not data-env-var) (not gtk-mod-env-var) gio-mod-env-var)
+            (for-each (cut wrap-program <>
+                           gio-mod-env-var)
                       bin-list))))))))
 
   (for-each handle-output outputs)
@@ -136,12 +210,40 @@ if needed."
                  #t))))
          outputs))
 
+(define* (generate-icon-cache #:key outputs #:allow-other-keys)
+  "Implement phase \"glib-or-gtk-icon-cache\": generate icon cache if
+needed."
+  (every (match-lambda
+          ((output . directory)
+           (let ((iconsdir (string-append directory
+                                            "/share/icons")))
+             (with-directory-excursion iconsdir
+               (for-each
+                (lambda (dir)
+                  (unless (file-exists?
+                           (string-append iconsdir "/" dir "/"
+                                          "icon-theme.cache"))
+                    (system* "gtk-update-icon-cache"
+                             "--ignore-theme-index"
+                             (string-append iconsdir "/" dir))))
+                (scandir "."
+                         (lambda (name)
+                           (and
+                            (not (equal? name "."))
+                            (not (equal? name ".."))
+                            (equal? 'directory
+                                    (stat:type (stat name))))))))
+             #t)))
+         outputs))
+
 (define %standard-phases
   (alist-cons-after
    'install 'glib-or-gtk-wrap wrap-all-programs
    (alist-cons-after
-    'install 'glib-or-gtk-compile-schemas compile-glib-schemas
-    gnu:%standard-phases)))
+    'install 'glib-or-gtk-icon-cache generate-icon-cache
+    (alist-cons-after
+     'install 'glib-or-gtk-compile-schemas compile-glib-schemas
+     gnu:%standard-phases))))
 
 (define* (glib-or-gtk-build #:key inputs (phases %standard-phases)
                             #:allow-other-keys #:rest args)
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-07 17:27       ` Federico Beffa
@ 2015-01-08 12:39         ` 宋文武
  2015-01-08 17:43           ` Federico Beffa
  2015-01-08 20:27           ` Ludovic Courtès
  0 siblings, 2 replies; 17+ messages in thread
From: 宋文武 @ 2015-01-08 12:39 UTC (permalink / raw
  To: Federico Beffa, Ludovic Courtès; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> writes:

> On Sun, Dec 21, 2014 at 11:54 AM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Federico Beffa <beffa@ieee.org> skribis:
>>
>>> On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
>>>> FYI, every apps will install icons into 'hicolor-icon-theme',
>>>> for it to work, we need regenerated the 'icon-theme.cache'
>>>> by `gtk-update-icon-cache`.
>>>
>>> The icon packages that I looked into are generating the cache by
>>> themselves at installation.  In any case, I think we can add a check
>>> similar to one we do for schemas, just in case some icon packages do
>>> not generate the cache.
>>
>> Agreed.
>
> Please find attached an updated patch.
>
> Regards,
> Fede
> From 4191ba9b8c86adaf9477e71a3a9f03cb04fc6528 Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Thu, 18 Dec 2014 20:58:18 +0100
> Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO
>  and XDG theming.
>
> * guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
>   'schemas-directories' to 'data-directories' and add support for XDG theming
>   data.
>
> * guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
>   function.
>
> * guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update names to
>   reflect that we are dealing with more types of data and not only with
>   schemas.  Add handling of GIO modules.
>
> * guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of GLib
>   instead of 'out'.  This was an error since we need the program
>   'glib-compile-schemas'.  Update the description.
> ---
>  guix/build-system/glib-or-gtk.scm       |  30 ++++---
>  guix/build/glib-or-gtk-build-system.scm | 138 +++++++++++++++++++++++++++-----
>  2 files changed, 141 insertions(+), 27 deletions(-)
>
> diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
> index 8091311..7a90587 100644
> --- a/guix/build-system/glib-or-gtk.scm
> +++ b/guix/build-system/glib-or-gtk.scm
> @@ -34,15 +34,14 @@
>  ;; This build system is an extension of the 'gnu-build-system'.  It
>  ;; accomodates the needs of applications making use of glib or gtk+ (with "or"
>  ;; to be interpreted in the mathematical sense).  This is achieved by adding
> -;; two phases run after the 'install' phase:
> +;; three phases run after the 'install' phase:
>  ;;
>  ;; 'glib-or-gtk-wrap' phase:
>  ;;
> -;; a) This phase looks for GSettings schemas by verifying the existence of
> -;; path "datadir/glib-2.0/schemas" in all input packages.  If the path is
> -;; found in any package, then all programs in "out/bin" are wrapped in scripts
> -;; where the environment variable "XDG_DATA_DIRS" is set and points to the
> -;; list of found schemas directories.
> +;; a) This phase looks for GSettings schemas, GIO modules and theming data.
> +;; If any of these is found in any input package, then all programs in
> +;; "out/bin" are wrapped in scripts defining the nedessary environment
> +;; variables.
>  ;;
>  ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all input
>  ;; packages.  If any is found, then the environment variable "GTK_PATH" is
> @@ -56,6 +55,11 @@
>  ;; exists and does not include a file named "gschemas.compiled", then
>  ;; "glib-compile-schemas" is run in that directory.
>  ;;
> +;; 'glib-or-gtk-icon-cache' phase:
> +;;
> +;; Looks for the existence of icon themes and, if no cache exists, generate
> +;; the "icon-theme.cache" file.
> +;;
I think this won't do what we want.

The only icon theme we should be care is hicolor-icon-theme,
which just provide a layout and the name, every applications
will install icons under the name, and often with a invalid cache,
see thunar for example. The icon-theme.cache is invalid because it
just contain icons from thunar, but the right cache should contain all
icons of hicolor-icon-theme. Its usage is the same as info.dir for
texinfo. Currently, info.dir is generated for all packages in profile,
by code in (guix profiles). We should do the same for cache of hicolor
theme there.

See also:
https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00027.html

>  ;; Code:
>  
>  (define %default-modules
> @@ -76,15 +80,22 @@
>    (let ((module (resolve-interface '(gnu packages glib))))
>      (module-ref module 'glib)))
>  
> +(define (default-gtk+)
> +  "Return the default gtk+ package from which we use
> +\"gtk-update-icon-cache\"."
> +  (let ((module (resolve-interface '(gnu packages gtk))))
> +    (module-ref module 'gtk+)))
> +
>  (define* (lower name
>                  #:key source inputs native-inputs outputs system target
> -                (glib (default-glib)) (implicit-inputs? #t)
> +                (glib (default-glib)) (gtk+ (default-gtk+))
> +                (implicit-inputs? #t)
>                  (strip-binaries? #t)
>                  #:allow-other-keys
>                  #:rest arguments)
>    "Return a bag for NAME."
>    (define private-keywords
> -    '(#:source #:target #:glib #:inputs #:native-inputs
> +    '(#:source #:target #:glib #:gtk+ #:inputs #:native-inputs
>        #:outputs #:implicit-inputs?))
>  
>    (and (not target)                               ;XXX: no cross-compilation
> @@ -95,7 +106,8 @@
>                                `(("source" ,source))
>                                '())
>                          ,@inputs))
> -         (build-inputs `(("glib:bin" ,glib)
> +         (build-inputs `(("glib:bin" ,glib "bin") ; to compile schemas
> +                         ("gtk+" ,gtk+)           ; to generate icon cache
>                           ,@(if implicit-inputs?
>                                 (standard-packages)
>                                 '())
> diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm
> index 9351a70..2fe7aa4 100644
> --- a/guix/build/glib-or-gtk-build-system.scm
> +++ b/guix/build/glib-or-gtk-build-system.scm
> @@ -22,6 +22,7 @@
>    #:use-module (guix build utils)
>    #:use-module (ice-9 match)
>    #:use-module (ice-9 regex)
> +  #:use-module (ice-9 ftw)
>    #:use-module (srfi srfi-1)
>    #:use-module (srfi srfi-26)
>    #:export (%standard-phases
> @@ -41,6 +42,9 @@
>    (fold (lambda (s p) (or (string-ci=? s directory) p))
>          #f directories-list))
>  
> +;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not
> +;; want to mix gtk+-2 and gtk+-3 modules.  See
> +;; https://developer.gnome.org/gtk3/stable/gtk-running.html
>  (define (gtk-module-directories inputs)
>    "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a list
>  with all found directories."
> @@ -64,20 +68,60 @@ with all found directories."
>                    prev)))))
>      (fold gtk-module '() inputs)))
>  
> -(define (schemas-directories inputs)
> -  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.  Return
> -a list with all found directories."
> -  (define (glib-schemas input previous)
> +;; See
> +;; http://www.freedesktop.org/wiki/DesktopThemeSpec
> +;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
> +;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
> +;; 
> +;; Currently desktop themes are not well supported and do not honor
> +;; XDG_DATA_DIRS.  One example is evince which only looks for desktop themes
> +;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which
> +;; defaults to $HOME/.local/share).  One way to handle these applications
> +;; appears to be by making $HOME/.themes a symlink to
> +;; $HOME/.guix-profile/share/themes.
Set GTK_DATA_PREFIX to $HOME/.guix-profile will work too.
Like in NixOS, we can set it to /run/current-system/profile.
> +(define (data-directories inputs)
> +  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data
> +in INPUTS.  Return a list with all found directories."
> +  (define (data-directory input previous)
>      (let* ((in (match input
>                   ((_ . dir) dir)
>                   (_ "")))
>             (datadir (string-append in "/share")))
> -      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
> +      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
> +                   (subdirectory-exists? datadir "/sounds")
> +                   (subdirectory-exists? datadir "/themes")
> +                   (subdirectory-exists? datadir "/cursors")
> +                   (subdirectory-exists? datadir "/wallpapers")
> +                   (subdirectory-exists? datadir "/icons"))
And I don't think the sounds, themes, cursors, wallpapers and icons are
hard depends of a application, they are for all applications.
Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
$HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
So, install a theme package will work for all applications.

WTDY?
>                 (not (directory-included? datadir previous)))
>            (cons datadir previous)
>            previous)))
>  
> -  (fold glib-schemas '() inputs))
> +  (fold data-directory '() inputs))
> +
> +;; All GIO modules are expected to be installed in GLib's $libdir/gio/modules
> +;; directory.  That directory has to include a file called giomodule.cache
> +;; listing all available modules.  GIO can be made aware of modules in other
> +;; directories with the help of the environment variable GIO_EXTRA_MODULES.
> +;; The official GIO documentation states that this environment variable should
> +;; only be used for testing and not in a production environment.  However, it
> +;; appears that there is no other way of specifying multiple modules
> +;; directories (NIXOS also does use this variable). See
> +;; https://developer.gnome.org/gio/stable/running-gio-apps.html
> +(define (gio-module-directories inputs)
> +  "Check for the existence of \"$libdir/gio/modules\" in the INPUTS and
> +returns a list with all found directories."
> +  (define (gio-module-directory input previous)
> +    (let* ((in (match input
> +                 ((_ . dir) dir)
> +                 (_ "")))
> +           (gio-mod-dir (string-append in "/lib/gio/modules")))
> +      (if (and (directory-exists? gio-mod-dir)
> +               (not (directory-included? gio-mod-dir previous)))
> +          (cons gio-mod-dir previous)
> +          previous)))
> +
> +  (fold gio-module-directory '() inputs))
>  
>  (define* (wrap-all-programs #:key inputs outputs
>                              (glib-or-gtk-wrap-excluded-outputs '())
> @@ -96,27 +140,57 @@ add a dependency of that output on GLib and GTK+."
>        (unless (member output glib-or-gtk-wrap-excluded-outputs)
>          (let* ((bindir       (string-append directory "/bin"))
>                 (bin-list     (find-files bindir ".*"))
> -               (schemas      (schemas-directories
> +               (datadirs     (data-directories
>                                (alist-cons output directory inputs)))
>                 (gtk-mod-dirs (gtk-module-directories
>                                (alist-cons output directory inputs)))
> -               (schemas-env-var
> -                (if (not (null? schemas))
> -                    `("XDG_DATA_DIRS" ":" prefix ,schemas)
> +               (gio-mod-dirs (gio-module-directories
> +                              (alist-cons output directory inputs)))
> +               (data-env-var
> +                (if (not (null? datadirs))
> +                    `("XDG_DATA_DIRS" ":" prefix ,datadirs)
>                      #f))
>                 (gtk-mod-env-var
>                  (if (not (null? gtk-mod-dirs))
>                      `("GTK_PATH" ":" prefix ,gtk-mod-dirs)
> +                    #f))
> +               (gio-mod-env-var 
> +                (if (not (null? gio-mod-dirs))
> +                    `("GIO_EXTRA_MODULES" ":" prefix ,gio-mod-dirs)
>                      #f)))
>            (cond
> -           ((and schemas-env-var gtk-mod-env-var)
> -            (for-each (cut wrap-program <> schemas-env-var gtk-mod-env-var)
> +           ((and data-env-var gtk-mod-env-var gio-mod-env-var)
> +            (for-each (cut wrap-program <>
> +                           data-env-var
> +                           gtk-mod-env-var
> +                           gio-mod-env-var)
>                        bin-list))
> -           (schemas-env-var
> -            (for-each (cut wrap-program <> schemas-env-var)
> +           ((and data-env-var gtk-mod-env-var (not gio-mod-env-var))
> +            (for-each (cut wrap-program <>
> +                           data-env-var
> +                           gtk-mod-env-var)
>                        bin-list))
> -           (gtk-mod-env-var
> -            (for-each (cut wrap-program <> gtk-mod-env-var)
> +           ((and data-env-var (not gtk-mod-env-var) gio-mod-env-var)
> +            (for-each (cut wrap-program <>
> +                           data-env-var
> +                           gio-mod-env-var)
> +                      bin-list))
> +           ((and (not data-env-var) gtk-mod-env-var gio-mod-env-var)
> +            (for-each (cut wrap-program <>
> +                           gio-mod-env-var
> +                           gtk-mod-env-var)
> +                      bin-list))
> +           ((and data-env-var (not gtk-mod-env-var) (not gio-mod-env-var))
> +            (for-each (cut wrap-program <>
> +                           data-env-var)
> +                      bin-list))
> +           ((and (not data-env-var) gtk-mod-env-var (not gio-mod-env-var))
> +            (for-each (cut wrap-program <>
> +                           gtk-mod-env-var)
> +                      bin-list))
> +           ((and (not data-env-var) (not gtk-mod-env-var) gio-mod-env-var)
> +            (for-each (cut wrap-program <>
> +                           gio-mod-env-var)
>                        bin-list))))))))
>  
>    (for-each handle-output outputs)
> @@ -136,12 +210,40 @@ if needed."
>                   #t))))
>           outputs))
>  
> +(define* (generate-icon-cache #:key outputs #:allow-other-keys)
> +  "Implement phase \"glib-or-gtk-icon-cache\": generate icon cache if
> +needed."
> +  (every (match-lambda
> +          ((output . directory)
> +           (let ((iconsdir (string-append directory
> +                                            "/share/icons")))
> +             (with-directory-excursion iconsdir
> +               (for-each
> +                (lambda (dir)
> +                  (unless (file-exists?
> +                           (string-append iconsdir "/" dir "/"
> +                                          "icon-theme.cache"))
> +                    (system* "gtk-update-icon-cache"
> +                             "--ignore-theme-index"
> +                             (string-append iconsdir "/" dir))))
> +                (scandir "."
> +                         (lambda (name)
> +                           (and
> +                            (not (equal? name "."))
> +                            (not (equal? name ".."))
> +                            (equal? 'directory
> +                                    (stat:type (stat name))))))))
> +             #t)))
> +         outputs))
> +
>  (define %standard-phases
>    (alist-cons-after
>     'install 'glib-or-gtk-wrap wrap-all-programs
>     (alist-cons-after
> -    'install 'glib-or-gtk-compile-schemas compile-glib-schemas
> -    gnu:%standard-phases)))
> +    'install 'glib-or-gtk-icon-cache generate-icon-cache
> +    (alist-cons-after
> +     'install 'glib-or-gtk-compile-schemas compile-glib-schemas
> +     gnu:%standard-phases))))
>  
>  (define* (glib-or-gtk-build #:key inputs (phases %standard-phases)
>                              #:allow-other-keys #:rest args)
> -- 
> 1.8.4
Thanks for working on this!

(Currently I have packaged some Xfce packages, but not fully working
due to miss icons, themes, etc.)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 12:39         ` 宋文武
@ 2015-01-08 17:43           ` Federico Beffa
  2015-01-08 20:26             ` Ludovic Courtès
  2015-01-09  1:57             ` 宋文武
  2015-01-08 20:27           ` Ludovic Courtès
  1 sibling, 2 replies; 17+ messages in thread
From: Federico Beffa @ 2015-01-08 17:43 UTC (permalink / raw
  To: 宋文武; +Cc: Guix-devel

On Thu, Jan 8, 2015 at 1:39 PM, 宋文武 <iyzsong@gmail.com> wrote:
> Federico Beffa <beffa@ieee.org> writes:
>
>> On Sun, Dec 21, 2014 at 11:54 AM, Ludovic Courtès <ludo@gnu.org> wrote:
>>> Federico Beffa <beffa@ieee.org> skribis:
>>>
>>>> On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
>>>>> FYI, every apps will install icons into 'hicolor-icon-theme',
>>>>> for it to work, we need regenerated the 'icon-theme.cache'
>>>>> by `gtk-update-icon-cache`.
>>>>
>>>> The icon packages that I looked into are generating the cache by
>>>> themselves at installation.  In any case, I think we can add a check
>>>> similar to one we do for schemas, just in case some icon packages do
>>>> not generate the cache.
>>>
>>> Agreed.
>>
>> Please find attached an updated patch.
>>
>> Regards,
>> Fede
>> From 4191ba9b8c86adaf9477e71a3a9f03cb04fc6528 Mon Sep 17 00:00:00 2001
>> From: Federico Beffa <beffa@fbengineering.ch>
>> Date: Thu, 18 Dec 2014 20:58:18 +0100
>> Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO
>>  and XDG theming.
>>
>> * guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
>>   'schemas-directories' to 'data-directories' and add support for XDG theming
>>   data.
>>
>> * guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
>>   function.
>>
>> * guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update names to
>>   reflect that we are dealing with more types of data and not only with
>>   schemas.  Add handling of GIO modules.
>>
>> * guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of GLib
>>   instead of 'out'.  This was an error since we need the program
>>   'glib-compile-schemas'.  Update the description.
>> ---
>>  guix/build-system/glib-or-gtk.scm       |  30 ++++---
>>  guix/build/glib-or-gtk-build-system.scm | 138 +++++++++++++++++++++++++++-----
>>  2 files changed, 141 insertions(+), 27 deletions(-)
>>
>> diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
>> index 8091311..7a90587 100644
>> --- a/guix/build-system/glib-or-gtk.scm
>> +++ b/guix/build-system/glib-or-gtk.scm
>> @@ -34,15 +34,14 @@
>>  ;; This build system is an extension of the 'gnu-build-system'.  It
>>  ;; accomodates the needs of applications making use of glib or gtk+ (with "or"
>>  ;; to be interpreted in the mathematical sense).  This is achieved by adding
>> -;; two phases run after the 'install' phase:
>> +;; three phases run after the 'install' phase:
>>  ;;
>>  ;; 'glib-or-gtk-wrap' phase:
>>  ;;
>> -;; a) This phase looks for GSettings schemas by verifying the existence of
>> -;; path "datadir/glib-2.0/schemas" in all input packages.  If the path is
>> -;; found in any package, then all programs in "out/bin" are wrapped in scripts
>> -;; where the environment variable "XDG_DATA_DIRS" is set and points to the
>> -;; list of found schemas directories.
>> +;; a) This phase looks for GSettings schemas, GIO modules and theming data.
>> +;; If any of these is found in any input package, then all programs in
>> +;; "out/bin" are wrapped in scripts defining the nedessary environment
>> +;; variables.
>>  ;;
>>  ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all input
>>  ;; packages.  If any is found, then the environment variable "GTK_PATH" is
>> @@ -56,6 +55,11 @@
>>  ;; exists and does not include a file named "gschemas.compiled", then
>>  ;; "glib-compile-schemas" is run in that directory.
>>  ;;
>> +;; 'glib-or-gtk-icon-cache' phase:
>> +;;
>> +;; Looks for the existence of icon themes and, if no cache exists, generate
>> +;; the "icon-theme.cache" file.
>> +;;
> I think this won't do what we want.
>
> The only icon theme we should be care is hicolor-icon-theme,
> which just provide a layout and the name, every applications
> will install icons under the name, and often with a invalid cache,
> see thunar for example. The icon-theme.cache is invalid because it
> just contain icons from thunar, but the right cache should contain all
> icons of hicolor-icon-theme. Its usage is the same as info.dir for
> texinfo. Currently, info.dir is generated for all packages in profile,
> by code in (guix profiles). We should do the same for cache of hicolor
> theme there.
>
> See also:
> https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00027.html
>

I believe that what you are saying does not correspond to the specification at
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html

* In my understanding there can be any number of base directories and
not just hicolor-icon-theme. If the latter is the only one currently
in wide use, it does not means that we should not be considering other
options described in the specification.

* Any theme can be spread into several different base directories.
Citing the specification: "... A theme can be spread across several
base directories by having subdirectories of the same name. This way
users can extend and override system themes. ... In at least one of
the theme directories there must be a file called index.theme that
describes the theme. The first index.theme found while searching the
base directories in order is used. This file describes the general
attributes of the theme. "
The program gtk-update-icon-cache, according to its manual, "writes a
icon-theme.cache containing cached information about the icons in the
directory tree below the given directory."

From the above I understand that, if a piece of software provides
icons which are part of a theme, we can point XGD_DATA_DIRS to the
relevant directory in the store and generate a cache for that part of
the theme. My proposal makes sure that the theme is found and used
without having to explicitly install it in a profile.

The problem that you mention only manifests itself if we want to use
the theme from a profile directory instead of directly from the store.
In the profile there will be a cache clash and your suggestion would
fix it, but this is a different problem.

>>  ;; Code:
>>
>>  (define %default-modules
>> @@ -76,15 +80,22 @@
>>    (let ((module (resolve-interface '(gnu packages glib))))
>>      (module-ref module 'glib)))
>>
>> +(define (default-gtk+)
>> +  "Return the default gtk+ package from which we use
>> +\"gtk-update-icon-cache\"."
>> +  (let ((module (resolve-interface '(gnu packages gtk))))
>> +    (module-ref module 'gtk+)))
>> +
>>  (define* (lower name
>>                  #:key source inputs native-inputs outputs system target
>> -                (glib (default-glib)) (implicit-inputs? #t)
>> +                (glib (default-glib)) (gtk+ (default-gtk+))
>> +                (implicit-inputs? #t)
>>                  (strip-binaries? #t)
>>                  #:allow-other-keys
>>                  #:rest arguments)
>>    "Return a bag for NAME."
>>    (define private-keywords
>> -    '(#:source #:target #:glib #:inputs #:native-inputs
>> +    '(#:source #:target #:glib #:gtk+ #:inputs #:native-inputs
>>        #:outputs #:implicit-inputs?))
>>
>>    (and (not target)                               ;XXX: no cross-compilation
>> @@ -95,7 +106,8 @@
>>                                `(("source" ,source))
>>                                '())
>>                          ,@inputs))
>> -         (build-inputs `(("glib:bin" ,glib)
>> +         (build-inputs `(("glib:bin" ,glib "bin") ; to compile schemas
>> +                         ("gtk+" ,gtk+)           ; to generate icon cache
>>                           ,@(if implicit-inputs?
>>                                 (standard-packages)
>>                                 '())
>> diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm
>> index 9351a70..2fe7aa4 100644
>> --- a/guix/build/glib-or-gtk-build-system.scm
>> +++ b/guix/build/glib-or-gtk-build-system.scm
>> @@ -22,6 +22,7 @@
>>    #:use-module (guix build utils)
>>    #:use-module (ice-9 match)
>>    #:use-module (ice-9 regex)
>> +  #:use-module (ice-9 ftw)
>>    #:use-module (srfi srfi-1)
>>    #:use-module (srfi srfi-26)
>>    #:export (%standard-phases
>> @@ -41,6 +42,9 @@
>>    (fold (lambda (s p) (or (string-ci=? s directory) p))
>>          #f directories-list))
>>
>> +;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not
>> +;; want to mix gtk+-2 and gtk+-3 modules.  See
>> +;; https://developer.gnome.org/gtk3/stable/gtk-running.html
>>  (define (gtk-module-directories inputs)
>>    "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a list
>>  with all found directories."
>> @@ -64,20 +68,60 @@ with all found directories."
>>                    prev)))))
>>      (fold gtk-module '() inputs)))
>>
>> -(define (schemas-directories inputs)
>> -  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.  Return
>> -a list with all found directories."
>> -  (define (glib-schemas input previous)
>> +;; See
>> +;; http://www.freedesktop.org/wiki/DesktopThemeSpec
>> +;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
>> +;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
>> +;;
>> +;; Currently desktop themes are not well supported and do not honor
>> +;; XDG_DATA_DIRS.  One example is evince which only looks for desktop themes
>> +;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which
>> +;; defaults to $HOME/.local/share).  One way to handle these applications
>> +;; appears to be by making $HOME/.themes a symlink to
>> +;; $HOME/.guix-profile/share/themes.
> Set GTK_DATA_PREFIX to $HOME/.guix-profile will work too.
> Like in NixOS, we can set it to /run/current-system/profile.
>> +(define (data-directories inputs)
>> +  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data
>> +in INPUTS.  Return a list with all found directories."
>> +  (define (data-directory input previous)
>>      (let* ((in (match input
>>                   ((_ . dir) dir)
>>                   (_ "")))
>>             (datadir (string-append in "/share")))
>> -      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
>> +      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
>> +                   (subdirectory-exists? datadir "/sounds")
>> +                   (subdirectory-exists? datadir "/themes")
>> +                   (subdirectory-exists? datadir "/cursors")
>> +                   (subdirectory-exists? datadir "/wallpapers")
>> +                   (subdirectory-exists? datadir "/icons"))
> And I don't think the sounds, themes, cursors, wallpapers and icons are
> hard depends of a application, they are for all applications.
> Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
> $HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
> So, install a theme package will work for all applications.
>
> WTDY?

As said above, my proposal will make sure that the relevant theming
data is found and used directly from the store.

I think your comment is relevant for "themes" only packages, but I see
it as a different problem which I'm not addressing here.

Regards,
Fede

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 17:43           ` Federico Beffa
@ 2015-01-08 20:26             ` Ludovic Courtès
  2015-01-08 21:46               ` Federico Beffa
  2015-01-09  1:57             ` 宋文武
  1 sibling, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2015-01-08 20:26 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> On Thu, Jan 8, 2015 at 1:39 PM, 宋文武 <iyzsong@gmail.com> wrote:

[...]

>> And I don't think the sounds, themes, cursors, wallpapers and icons are
>> hard depends of a application, they are for all applications.
>> Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
>> $HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
>> So, install a theme package will work for all applications.
>>
>> WTDY?
>
> As said above, my proposal will make sure that the relevant theming
> data is found and used directly from the store.

To summarize, I think the solution you propose would have the advantage
of working out-of-the-box, even when Guix is used on another distro, and
the disadvantage to be inflexible (the set of themes, icons, etc. used
by an application will be fixed at build time, IIUC.)

What 宋文武 proposes would have the advantage of being more flexible
(users can install the themes they prefer), but would work only on
“Guixotic”, and not out-of-the-box (users will have to remember to
install one sound theme, icon set, etc.)

Does that make sense?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 12:39         ` 宋文武
  2015-01-08 17:43           ` Federico Beffa
@ 2015-01-08 20:27           ` Ludovic Courtès
  2015-01-09  2:00             ` 宋文武
  1 sibling, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2015-01-08 20:27 UTC (permalink / raw
  To: 宋文武; +Cc: Guix-devel, Federico Beffa

宋文武 <iyzsong@gmail.com> skribis:

> See also:
> https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00027.html

Of course this sounds like the best outcome.  We count on you.  :-)

That said, the work that Federico has done may be a good solution, at
least in the interim.

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 20:26             ` Ludovic Courtès
@ 2015-01-08 21:46               ` Federico Beffa
  2015-01-10 21:08                 ` Ludovic Courtès
  0 siblings, 1 reply; 17+ messages in thread
From: Federico Beffa @ 2015-01-08 21:46 UTC (permalink / raw
  To: Ludovic Courtès; +Cc: Guix-devel

On Thu, Jan 8, 2015 at 9:26 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>
>> On Thu, Jan 8, 2015 at 1:39 PM, 宋文武 <iyzsong@gmail.com> wrote:
>
> [...]
>
>>> And I don't think the sounds, themes, cursors, wallpapers and icons are
>>> hard depends of a application, they are for all applications.
>>> Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
>>> $HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
>>> So, install a theme package will work for all applications.
>>>
>>> WTDY?
>>
>> As said above, my proposal will make sure that the relevant theming
>> data is found and used directly from the store.
>
> To summarize, I think the solution you propose would have the advantage
> of working out-of-the-box, even when Guix is used on another distro, and
> the disadvantage to be inflexible (the set of themes, icons, etc. used
> by an application will be fixed at build time, IIUC.)
>
> What 宋文武 proposes would have the advantage of being more flexible
> (users can install the themes they prefer), but would work only on
> “Guixotic”, and not out-of-the-box (users will have to remember to
> install one sound theme, icon set, etc.)
>
> Does that make sense?

I do not see the two methods as alternatives, but as complementary and
co-working: my proposal makes sure that a package works out of the box
by *prefixing* XDG_DATA_DIRS (and not replacing it). So a user is
still able to add themes in his own profile.

Or, do you see any problem? Or, would you prefer to append instead to prefix?

Regards,
Fede

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 17:43           ` Federico Beffa
  2015-01-08 20:26             ` Ludovic Courtès
@ 2015-01-09  1:57             ` 宋文武
  1 sibling, 0 replies; 17+ messages in thread
From: 宋文武 @ 2015-01-09  1:57 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 12036 bytes --]

2015-01-09 1:43 GMT+08:00 Federico Beffa <beffa@ieee.org>:

> On Thu, Jan 8, 2015 at 1:39 PM, 宋文武 <iyzsong@gmail.com> wrote:
> > Federico Beffa <beffa@ieee.org> writes:
> >
> >> On Sun, Dec 21, 2014 at 11:54 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> >>> Federico Beffa <beffa@ieee.org> skribis:
> >>>
> >>>> On Fri, Dec 19, 2014 at 1:56 PM, 宋文武 <iyzsong@gmail.com> wrote:
> >>>>> FYI, every apps will install icons into 'hicolor-icon-theme',
> >>>>> for it to work, we need regenerated the 'icon-theme.cache'
> >>>>> by `gtk-update-icon-cache`.
> >>>>
> >>>> The icon packages that I looked into are generating the cache by
> >>>> themselves at installation.  In any case, I think we can add a check
> >>>> similar to one we do for schemas, just in case some icon packages do
> >>>> not generate the cache.
> >>>
> >>> Agreed.
> >>
> >> Please find attached an updated patch.
> >>
> >> Regards,
> >> Fede
> >> From 4191ba9b8c86adaf9477e71a3a9f03cb04fc6528 Mon Sep 17 00:00:00 2001
> >> From: Federico Beffa <beffa@fbengineering.ch>
> >> Date: Thu, 18 Dec 2014 20:58:18 +0100
> >> Subject: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support
> for GIO
> >>  and XDG theming.
> >>
> >> * guix/build/glib-or-gtk-build-system.scm (data-directories): Rename
> >>   'schemas-directories' to 'data-directories' and add support for XDG
> theming
> >>   data.
> >>
> >> * guix/build/glib-or-gtk-build-system.scm (gio-module-directories): New
> >>   function.
> >>
> >> * guix/build/glib-or-gtk-build-system.scm (wrap-all-programs): Update
> names to
> >>   reflect that we are dealing with more types of data and not only with
> >>   schemas.  Add handling of GIO modules.
> >>
> >> * guix/build-system/glib-or-gtk.scm (lower): Import the 'bin' output of
> GLib
> >>   instead of 'out'.  This was an error since we need the program
> >>   'glib-compile-schemas'.  Update the description.
> >> ---
> >>  guix/build-system/glib-or-gtk.scm       |  30 ++++---
> >>  guix/build/glib-or-gtk-build-system.scm | 138
> +++++++++++++++++++++++++++-----
> >>  2 files changed, 141 insertions(+), 27 deletions(-)
> >>
> >> diff --git a/guix/build-system/glib-or-gtk.scm
> b/guix/build-system/glib-or-gtk.scm
> >> index 8091311..7a90587 100644
> >> --- a/guix/build-system/glib-or-gtk.scm
> >> +++ b/guix/build-system/glib-or-gtk.scm
> >> @@ -34,15 +34,14 @@
> >>  ;; This build system is an extension of the 'gnu-build-system'.  It
> >>  ;; accomodates the needs of applications making use of glib or gtk+
> (with "or"
> >>  ;; to be interpreted in the mathematical sense).  This is achieved by
> adding
> >> -;; two phases run after the 'install' phase:
> >> +;; three phases run after the 'install' phase:
> >>  ;;
> >>  ;; 'glib-or-gtk-wrap' phase:
> >>  ;;
> >> -;; a) This phase looks for GSettings schemas by verifying the
> existence of
> >> -;; path "datadir/glib-2.0/schemas" in all input packages.  If the path
> is
> >> -;; found in any package, then all programs in "out/bin" are wrapped in
> scripts
> >> -;; where the environment variable "XDG_DATA_DIRS" is set and points to
> the
> >> -;; list of found schemas directories.
> >> +;; a) This phase looks for GSettings schemas, GIO modules and theming
> data.
> >> +;; If any of these is found in any input package, then all programs in
> >> +;; "out/bin" are wrapped in scripts defining the nedessary environment
> >> +;; variables.
> >>  ;;
> >>  ;; b) Looks for the existence of "libdir/gtk-3.0" directories in all
> input
> >>  ;; packages.  If any is found, then the environment variable
> "GTK_PATH" is
> >> @@ -56,6 +55,11 @@
> >>  ;; exists and does not include a file named "gschemas.compiled", then
> >>  ;; "glib-compile-schemas" is run in that directory.
> >>  ;;
> >> +;; 'glib-or-gtk-icon-cache' phase:
> >> +;;
> >> +;; Looks for the existence of icon themes and, if no cache exists,
> generate
> >> +;; the "icon-theme.cache" file.
> >> +;;
> > I think this won't do what we want.
> >
> > The only icon theme we should be care is hicolor-icon-theme,
> > which just provide a layout and the name, every applications
> > will install icons under the name, and often with a invalid cache,
> > see thunar for example. The icon-theme.cache is invalid because it
> > just contain icons from thunar, but the right cache should contain all
> > icons of hicolor-icon-theme. Its usage is the same as info.dir for
> > texinfo. Currently, info.dir is generated for all packages in profile,
> > by code in (guix profiles). We should do the same for cache of hicolor
> > theme there.
> >
> > See also:
> > https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00027.html
> >
>
> I believe that what you are saying does not correspond to the
> specification at
>
> http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
>
> * In my understanding there can be any number of base directories and
> not just hicolor-icon-theme. If the latter is the only one currently
> in wide use, it does not means that we should not be considering other
> options described in the specification.
>
> * Any theme can be spread into several different base directories.
> Citing the specification: "... A theme can be spread across several
> base directories by having subdirectories of the same name. This way
> users can extend and override system themes. ... In at least one of
> the theme directories there must be a file called index.theme that
> describes the theme. The first index.theme found while searching the
> base directories in order is used. This file describes the general
> attributes of the theme. "
> The program gtk-update-icon-cache, according to its manual, "writes a
> icon-theme.cache containing cached information about the icons in the
> directory tree below the given directory."

Thanks for explanations! you're right.

>
>
From the above I understand that, if a piece of software provides
> icons which are part of a theme, we can point XGD_DATA_DIRS to the
> relevant directory in the store and generate a cache for that part of
> the theme. My proposal makes sure that the theme is found and used
> without having to explicitly install it in a profile.
>
> The problem that you mention only manifests itself if we want to use
> the theme from a profile directory instead of directly from the store.
> In the profile there will be a cache clash and your suggestion would
> fix it, but this is a different problem.

OK.

> >>  ;; Code:
> >>
> >>  (define %default-modules
> >> @@ -76,15 +80,22 @@
> >>    (let ((module (resolve-interface '(gnu packages glib))))
> >>      (module-ref module 'glib)))
> >>
> >> +(define (default-gtk+)
> >> +  "Return the default gtk+ package from which we use
> >> +\"gtk-update-icon-cache\"."
> >> +  (let ((module (resolve-interface '(gnu packages gtk))))
> >> +    (module-ref module 'gtk+)))
> >> +
> >>  (define* (lower name
> >>                  #:key source inputs native-inputs outputs system target
> >> -                (glib (default-glib)) (implicit-inputs? #t)
> >> +                (glib (default-glib)) (gtk+ (default-gtk+))
> >> +                (implicit-inputs? #t)
> >>                  (strip-binaries? #t)
> >>                  #:allow-other-keys
> >>                  #:rest arguments)
> >>    "Return a bag for NAME."
> >>    (define private-keywords
> >> -    '(#:source #:target #:glib #:inputs #:native-inputs
> >> +    '(#:source #:target #:glib #:gtk+ #:inputs #:native-inputs
> >>        #:outputs #:implicit-inputs?))
> >>
> >>    (and (not target)                               ;XXX: no
> cross-compilation
> >> @@ -95,7 +106,8 @@
> >>                                `(("source" ,source))
> >>                                '())
> >>                          ,@inputs))
> >> -         (build-inputs `(("glib:bin" ,glib)
> >> +         (build-inputs `(("glib:bin" ,glib "bin") ; to compile schemas
> >> +                         ("gtk+" ,gtk+)           ; to generate icon
> cache
> >>                           ,@(if implicit-inputs?
> >>                                 (standard-packages)
> >>                                 '())
> >> diff --git a/guix/build/glib-or-gtk-build-system.scm
> b/guix/build/glib-or-gtk-build-system.scm
> >> index 9351a70..2fe7aa4 100644
> >> --- a/guix/build/glib-or-gtk-build-system.scm
> >> +++ b/guix/build/glib-or-gtk-build-system.scm
> >> @@ -22,6 +22,7 @@
> >>    #:use-module (guix build utils)
> >>    #:use-module (ice-9 match)
> >>    #:use-module (ice-9 regex)
> >> +  #:use-module (ice-9 ftw)
> >>    #:use-module (srfi srfi-1)
> >>    #:use-module (srfi srfi-26)
> >>    #:export (%standard-phases
> >> @@ -41,6 +42,9 @@
> >>    (fold (lambda (s p) (or (string-ci=? s directory) p))
> >>          #f directories-list))
> >>
> >> +;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we
> do not
> >> +;; want to mix gtk+-2 and gtk+-3 modules.  See
> >> +;; https://developer.gnome.org/gtk3/stable/gtk-running.html
> >>  (define (gtk-module-directories inputs)
> >>    "Check for the existence of \"libdir/gtk-v.0\" in INPUTS.  Return a
> list
> >>  with all found directories."
> >> @@ -64,20 +68,60 @@ with all found directories."
> >>                    prev)))))
> >>      (fold gtk-module '() inputs)))
> >>
> >> -(define (schemas-directories inputs)
> >> -  "Check for the existence of \"datadir/glib-2.0/schemas\" in INPUTS.
> Return
> >> -a list with all found directories."
> >> -  (define (glib-schemas input previous)
> >> +;; See
> >> +;; http://www.freedesktop.org/wiki/DesktopThemeSpec
> >> +;; http://freedesktop.org/wiki/Specifications/sound-theme-spec
> >> +;; http://freedesktop.org/wiki/Specifications/icon-theme-spec
> >> +;;
> >> +;; Currently desktop themes are not well supported and do not honor
> >> +;; XDG_DATA_DIRS.  One example is evince which only looks for desktop
> themes
> >> +;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME
> (which
> >> +;; defaults to $HOME/.local/share).  One way to handle these
> applications
> >> +;; appears to be by making $HOME/.themes a symlink to
> >> +;; $HOME/.guix-profile/share/themes.
> > Set GTK_DATA_PREFIX to $HOME/.guix-profile will work too.
> > Like in NixOS, we can set it to /run/current-system/profile.
> >> +(define (data-directories inputs)
> >> +  "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG
> themes data
> >> +in INPUTS.  Return a list with all found directories."
> >> +  (define (data-directory input previous)
> >>      (let* ((in (match input
> >>                   ((_ . dir) dir)
> >>                   (_ "")))
> >>             (datadir (string-append in "/share")))
> >> -      (if (and (subdirectory-exists? datadir "/glib-2.0/schemas")
> >> +      (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas")
> >> +                   (subdirectory-exists? datadir "/sounds")
> >> +                   (subdirectory-exists? datadir "/themes")
> >> +                   (subdirectory-exists? datadir "/cursors")
> >> +                   (subdirectory-exists? datadir "/wallpapers")
> >> +                   (subdirectory-exists? datadir "/icons"))
> > And I don't think the sounds, themes, cursors, wallpapers and icons are
> > hard depends of a application, they are for all applications.
> > Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
> > $HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
> > So, install a theme package will work for all applications.
> >
> > WTDY?
>
> As said above, my proposal will make sure that the relevant theming
> data is found and used directly from the store.
>
> I think your comment is relevant for "themes" only packages, but I see
> it as a different problem which I'm not addressing here.
>
Agree!

> Regards,
> Fede
>

[-- Attachment #2: Type: text/html, Size: 16190 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 20:27           ` Ludovic Courtès
@ 2015-01-09  2:00             ` 宋文武
  0 siblings, 0 replies; 17+ messages in thread
From: 宋文武 @ 2015-01-09  2:00 UTC (permalink / raw
  To: Ludovic Courtès; +Cc: Guix-devel, Federico Beffa

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

2015-01-09 4:27 GMT+08:00 Ludovic Courtès <ludo@gnu.org>:

> 宋文武 <iyzsong@gmail.com> skribis:
>
> > See also:
> > https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00027.html
>
> Of course this sounds like the best outcome.  We count on you.  :-)
>
> That said, the work that Federico has done may be a good solution, at
> least in the interim.
>
> WDYT?
>
> Yes, Federico have done a good job.

> Ludo’.
>

[-- Attachment #2: Type: text/html, Size: 1033 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-08 21:46               ` Federico Beffa
@ 2015-01-10 21:08                 ` Ludovic Courtès
  2015-01-11  8:25                   ` Federico Beffa
  0 siblings, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2015-01-10 21:08 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> On Thu, Jan 8, 2015 at 9:26 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Federico Beffa <beffa@ieee.org> skribis:
>>
>>> On Thu, Jan 8, 2015 at 1:39 PM, 宋文武 <iyzsong@gmail.com> wrote:
>>
>> [...]
>>
>>>> And I don't think the sounds, themes, cursors, wallpapers and icons are
>>>> hard depends of a application, they are for all applications.
>>>> Why not set XDG_DATA_DIRS to /run/current-system/profile/share and
>>>> $HOME/.guix-profile/share in /etc/profile? (at gnu/system.scm)
>>>> So, install a theme package will work for all applications.
>>>>
>>>> WTDY?
>>>
>>> As said above, my proposal will make sure that the relevant theming
>>> data is found and used directly from the store.
>>
>> To summarize, I think the solution you propose would have the advantage
>> of working out-of-the-box, even when Guix is used on another distro, and
>> the disadvantage to be inflexible (the set of themes, icons, etc. used
>> by an application will be fixed at build time, IIUC.)
>>
>> What 宋文武 proposes would have the advantage of being more flexible
>> (users can install the themes they prefer), but would work only on
>> “Guixotic”, and not out-of-the-box (users will have to remember to
>> install one sound theme, icon set, etc.)
>>
>> Does that make sense?
>
> I do not see the two methods as alternatives, but as complementary and
> co-working: my proposal makes sure that a package works out of the box
> by *prefixing* XDG_DATA_DIRS (and not replacing it). So a user is
> still able to add themes in his own profile.
>
> Or, do you see any problem? 

Oh no, you're right.  Sorry for the confusion.

> Or, would you prefer to append instead to prefix?

Yes, rather append, otherwise users would be unable to change it, no?

Do you need anything else for the review?

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-10 21:08                 ` Ludovic Courtès
@ 2015-01-11  8:25                   ` Federico Beffa
  2015-01-11 10:55                     ` Ludovic Courtès
  2015-01-12 21:33                     ` Mark H Weaver
  0 siblings, 2 replies; 17+ messages in thread
From: Federico Beffa @ 2015-01-11  8:25 UTC (permalink / raw
  To: Ludovic Courtès; +Cc: Guix-devel

On Sat, Jan 10, 2015 at 10:08 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Yes, rather append, otherwise users would be unable to change it, no?

My reasoning for choosing to prefix is as follows: we want the
application to find the data version that it was compiled with (GLib
schemas, ...) to avoid clashing with incompatible updates.  However,
we want to be able to extend the search path to add optional data not
available at compile time. If a user really wants to override one of
the compile time data path, he still has the possibility to use
XDG_DATA_HOME.

WDYT?

> Do you need anything else for the review?

If we agree on the above, then I'm just waiting for an "OK to push" :-)

Thanks,
Fede

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-11  8:25                   ` Federico Beffa
@ 2015-01-11 10:55                     ` Ludovic Courtès
  2015-01-12 21:33                     ` Mark H Weaver
  1 sibling, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2015-01-11 10:55 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> On Sat, Jan 10, 2015 at 10:08 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Yes, rather append, otherwise users would be unable to change it, no?
>
> My reasoning for choosing to prefix is as follows: we want the
> application to find the data version that it was compiled with (GLib
> schemas, ...) to avoid clashing with incompatible updates.  However,
> we want to be able to extend the search path to add optional data not
> available at compile time. If a user really wants to override one of
> the compile time data path, he still has the possibility to use
> XDG_DATA_HOME.
>
> WDYT?

Ah yes, that makes sense.  I guess for schemas we really want the
application to use those produced at build time, whereas for things like
icons, it would be OK to use anything (I suppose.)

But XDG_DATA_DIRS is coarse-grain, so prefixing seems safer, indeed.

>> Do you need anything else for the review?
>
> If we agree on the above, then I'm just waiting for an "OK to push" :-)

Then OK to push.  :-)

Thanks for explaining!

Ludo’.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-11  8:25                   ` Federico Beffa
  2015-01-11 10:55                     ` Ludovic Courtès
@ 2015-01-12 21:33                     ` Mark H Weaver
  2015-01-13  8:18                       ` Federico Beffa
  1 sibling, 1 reply; 17+ messages in thread
From: Mark H Weaver @ 2015-01-12 21:33 UTC (permalink / raw
  To: Federico Beffa; +Cc: Guix-devel

Hi Federico,

Your commit 61771a7 seems to have broken the 'transmission' build.  See:

  http://hydra.gnu.org/build/199802/log/tail-reload

Specifically, the problem seems to be that 'generate-icon-cache' (a new
procedure that should have been mentioned in the commit log, but wasn't)
implicitly assumes that <OUT>/share/icons will exist for every output
directory <OUT>.  In the case of 'transmission', this is not the case.

Can you take a look?

     Thanks!
       Mark

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming.
  2015-01-12 21:33                     ` Mark H Weaver
@ 2015-01-13  8:18                       ` Federico Beffa
  0 siblings, 0 replies; 17+ messages in thread
From: Federico Beffa @ 2015-01-13  8:18 UTC (permalink / raw
  To: Mark H Weaver; +Cc: Guix-devel

On Mon, Jan 12, 2015 at 10:33 PM, Mark H Weaver <mhw@netris.org> wrote:
> Hi Federico,
>
> Your commit 61771a7 seems to have broken the 'transmission' build.  See:
>
>   http://hydra.gnu.org/build/199802/log/tail-reload
>
> Specifically, the problem seems to be that 'generate-icon-cache' (a new
> procedure that should have been mentioned in the commit log, but wasn't)
> implicitly assumes that <OUT>/share/icons will exist for every output
> directory <OUT>.  In the case of 'transmission', this is not the case.
>
> Can you take a look?

Commit f5895dab8a99c758b2591de334e7ac3ba9eb66fb fixes this problem.

Sorry for the inconvenience.

Regards,
Fede

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-01-13  8:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 21:10 [PATCH 1/4] guix: build/glib-or-gtk-build-system: Add support for GIO and XDG theming Federico Beffa
2014-12-19 12:56 ` 宋文武
2014-12-21  9:41   ` Federico Beffa
2014-12-21 10:54     ` Ludovic Courtès
2015-01-07 17:27       ` Federico Beffa
2015-01-08 12:39         ` 宋文武
2015-01-08 17:43           ` Federico Beffa
2015-01-08 20:26             ` Ludovic Courtès
2015-01-08 21:46               ` Federico Beffa
2015-01-10 21:08                 ` Ludovic Courtès
2015-01-11  8:25                   ` Federico Beffa
2015-01-11 10:55                     ` Ludovic Courtès
2015-01-12 21:33                     ` Mark H Weaver
2015-01-13  8:18                       ` Federico Beffa
2015-01-09  1:57             ` 宋文武
2015-01-08 20:27           ` Ludovic Courtès
2015-01-09  2:00             ` 宋文武

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.