* [PATCH 1/2] profiles: Add xdg-desktop-database hook. @ 2016-01-31 12:03 宋文武 2016-01-31 12:03 ` [PATCH 2/2] profiles: Add xdg-mime-database hook 宋文武 2016-02-02 13:09 ` [PATCH 1/2] profiles: Add xdg-desktop-database hook Ludovic Courtès 0 siblings, 2 replies; 8+ messages in thread From: 宋文武 @ 2016-01-31 12:03 UTC (permalink / raw) To: guix-devel; +Cc: 宋文武 * guix/profiles (xdg-desktop-database): New function. (%default-profile-hooks): Add it. --- guix/profiles.scm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index ce86ff8..38e2730 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -684,13 +684,45 @@ creates the GTK+ 'icon-theme.cache' file for each theme." #:substitutable? #f) (return #f)))) +(define (xdg-desktop-database manifest) + "Return a derivation that builds the @file{mimeinfo.cache} database from +desktop files." + (define desktop-file-utils + (module-ref (resolve-interface '(gnu packages gnome)) + 'desktop-file-utils)) + + (define build + #~(begin + (use-modules (srfi srfi-26) + (guix build utils) + (guix build union)) + (let* ((destdir (string-append #$output "/share/applications")) + (appdirs (filter file-exists? + (map (cut string-append <> + "/share/applications") + '#$(manifest-inputs manifest)))) + (update-desktop-database (string-append + #+desktop-file-utils + "/bin/update-desktop-database"))) + (mkdir-p (string-append #$output "/share")) + (union-build destdir appdirs + #:log-port (%make-void-port "w")) + (zero? (system* update-desktop-database destdir))))) + + (gexp->derivation "xdg-desktop-database" build + #:modules '((guix build utils) + (guix build union)) + #:local-build? #t + #:substitutable? #f)) + (define %default-profile-hooks ;; This is the list of derivation-returning procedures that are called by ;; default when making a non-empty profile. (list info-dir-file ghc-package-cache-file ca-certificate-bundle - gtk-icon-themes)) + gtk-icon-themes + xdg-desktop-database)) (define* (profile-derivation manifest #:key -- 2.5.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] profiles: Add xdg-mime-database hook. 2016-01-31 12:03 [PATCH 1/2] profiles: Add xdg-desktop-database hook 宋文武 @ 2016-01-31 12:03 ` 宋文武 2016-01-31 12:32 ` 宋文武 2016-02-02 13:10 ` Ludovic Courtès 2016-02-02 13:09 ` [PATCH 1/2] profiles: Add xdg-desktop-database hook Ludovic Courtès 1 sibling, 2 replies; 8+ messages in thread From: 宋文武 @ 2016-01-31 12:03 UTC (permalink / raw) To: guix-devel; +Cc: 宋文武 * guix/profiles (xdg-mime-database): New function. (%default-profile-hooks): Add it. --- guix/profiles.scm | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index 38e2730..84bcbd2 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -715,6 +715,39 @@ desktop files." #:local-build? #t #:substitutable? #f)) +(define (xdg-mime-database manifest) + "Return a derivation that builds the @file{mime.cache} database from manifest +entries." + (define shared-mime-info + (module-ref (resolve-interface '(gnu packages gnome)) + 'shared-mime-info)) + + (define build + #~(begin + (use-modules (srfi srfi-26) + (guix build utils) + (guix build union)) + (let* ((datadir (string-append #$output "/share")) + (destdir (string-append datadir "/mime")) + (mimedirs (filter file-exists? + (map (cut string-append <> + "/share/mime") + '#$(manifest-inputs manifest)))) + (update-mime-database (string-append + #+shared-mime-info + "/bin/update-mime-database"))) + (mkdir-p datadir) + (union-build destdir mimedirs + #:log-port (%make-void-port "w")) + (setenv "XDG_DATA_HOME" datadir) + (zero? (system* update-mime-database destdir))))) + + (gexp->derivation "xdg-mime-database" build + #:modules '((guix build utils) + (guix build union)) + #:local-build? #t + #:substitutable? #f)) + (define %default-profile-hooks ;; This is the list of derivation-returning procedures that are called by ;; default when making a non-empty profile. @@ -722,7 +755,8 @@ desktop files." ghc-package-cache-file ca-certificate-bundle gtk-icon-themes - xdg-desktop-database)) + xdg-desktop-database + xdg-mime-database)) (define* (profile-derivation manifest #:key -- 2.5.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] profiles: Add xdg-mime-database hook. 2016-01-31 12:03 ` [PATCH 2/2] profiles: Add xdg-mime-database hook 宋文武 @ 2016-01-31 12:32 ` 宋文武 2016-02-02 13:11 ` Ludovic Courtès 2016-02-02 13:10 ` Ludovic Courtès 1 sibling, 1 reply; 8+ messages in thread From: 宋文武 @ 2016-01-31 12:32 UTC (permalink / raw) To: guix-devel The xdg-desktop-database hook rebuilds the 'mimeinfo.cache' database from desktop files of applications, which then is used to decide the "Default Application" (in thunar, nautilus, etc.) for a MIME type. The xdg-mime-database hook rebuilds the 'mime.cache' database, it's the shared mime-info database used to decide the MIME type for files. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] profiles: Add xdg-mime-database hook. 2016-01-31 12:32 ` 宋文武 @ 2016-02-02 13:11 ` Ludovic Courtès 0 siblings, 0 replies; 8+ messages in thread From: Ludovic Courtès @ 2016-02-02 13:11 UTC (permalink / raw) To: 宋文武; +Cc: guix-devel iyzsong@member.fsf.org (宋文武) skribis: > The xdg-desktop-database hook rebuilds the 'mimeinfo.cache' database > from desktop files of applications, which then is used to decide the > "Default Application" (in thunar, nautilus, etc.) for a MIME type. > > The xdg-mime-database hook rebuilds the 'mime.cache' database, > it's the shared mime-info database used to decide the MIME type for > files. OK, thanks for explaining. Could you put it as comments in the source? Ludo’. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] profiles: Add xdg-mime-database hook. 2016-01-31 12:03 ` [PATCH 2/2] profiles: Add xdg-mime-database hook 宋文武 2016-01-31 12:32 ` 宋文武 @ 2016-02-02 13:10 ` Ludovic Courtès 1 sibling, 0 replies; 8+ messages in thread From: Ludovic Courtès @ 2016-02-02 13:10 UTC (permalink / raw) To: 宋文武; +Cc: guix-devel 宋文武 <iyzsong@gmail.com> skribis: > * guix/profiles (xdg-mime-database): New function. > (%default-profile-hooks): Add it. [...] > + (update-mime-database (string-append > + #+shared-mime-info > + "/bin/update-mime-database"))) Same thing here: ‘shared-mime-info’ depends on GLib and intltool. Ludo’. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] profiles: Add xdg-desktop-database hook. 2016-01-31 12:03 [PATCH 1/2] profiles: Add xdg-desktop-database hook 宋文武 2016-01-31 12:03 ` [PATCH 2/2] profiles: Add xdg-mime-database hook 宋文武 @ 2016-02-02 13:09 ` Ludovic Courtès 2016-02-04 7:54 ` 宋文武 1 sibling, 1 reply; 8+ messages in thread From: Ludovic Courtès @ 2016-02-02 13:09 UTC (permalink / raw) To: 宋文武; +Cc: guix-devel 宋文武 <iyzsong@gmail.com> skribis: > * guix/profiles (xdg-desktop-database): New function. > (%default-profile-hooks): Add it. Nice! > + (update-desktop-database (string-append > + #+desktop-file-utils > + "/bin/update-desktop-database"))) This is a small dependency, but it still depends on GLib; my understanding is that building any profile would end up pulling in GLib because of this hook. Should we have some heuristic as for the GTK+ and GHC hooks to avoid pulling it in? For instance, we could check whether GLib is already an indirect dependency of at least one of the packages. WDYT? Thank you! Ludo’. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] profiles: Add xdg-desktop-database hook. 2016-02-02 13:09 ` [PATCH 1/2] profiles: Add xdg-desktop-database hook Ludovic Courtès @ 2016-02-04 7:54 ` 宋文武 2016-02-07 20:13 ` Ludovic Courtès 0 siblings, 1 reply; 8+ messages in thread From: 宋文武 @ 2016-02-04 7:54 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 1431 bytes --] ludo@gnu.org (Ludovic Courtès) writes: > 宋文武 <iyzsong@gmail.com> skribis: > >> * guix/profiles (xdg-desktop-database): New function. >> (%default-profile-hooks): Add it. > > Nice! > >> + (update-desktop-database (string-append >> + #+desktop-file-utils >> + "/bin/update-desktop-database"))) > > This is a small dependency, but it still depends on GLib; my > understanding is that building any profile would end up pulling in GLib > because of this hook. Yes. > > Should we have some heuristic as for the GTK+ and GHC hooks to avoid > pulling it in? > > For instance, we could check whether GLib is already an indirect > dependency of at least one of the packages. WDYT? Sure, but I think check on GLib is not sufficient and necessary, when the hook run, it will use latest desktop-file-utils which may use a different version of glib. Unless I use the desktop-file-utils package installed from profile, but not like the gtk-icon-themes hook, where gtk+ is the runtime dependency, desktop-file-utils is only used to validate the desktop file during build phase, I can't get it from manifest using the same (and IMO, heavy and ugly) method. So, I end up using a simple 'manifest-lookup', which require the desktop-file-utils and shared-mime-info to be installed explicitly. Updated patches: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-profiles-Add-xdg-desktop-database-hook.patch --] [-- Type: text/x-patch, Size: 2812 bytes --] From 9fe7aa4f368def46ddab54bd1347d6cf2ef5832f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com> Date: Thu, 4 Feb 2016 15:33:07 +0800 Subject: [PATCH 1/2] profiles: Add xdg-desktop-database hook. * guix/profiles.scm (xdg-desktop-database): New function. (%default-profile-hooks): Add it. --- guix/profiles.scm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index ce86ff8..a9375e6 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -684,13 +684,49 @@ creates the GTK+ 'icon-theme.cache' file for each theme." #:substitutable? #f) (return #f)))) +(define (xdg-desktop-database manifest) + "Return a derivation that builds the @file{mimeinfo.cache} database from +desktop files. It's used to query what applications can handle a given +MIME type." + (define desktop-file-utils + (module-ref (resolve-interface '(gnu packages gnome)) + 'desktop-file-utils)) + + (define build + #~(begin + (use-modules (srfi srfi-26) + (guix build utils) + (guix build union)) + (let* ((destdir (string-append #$output "/share/applications")) + (appdirs (filter file-exists? + (map (cut string-append <> + "/share/applications") + '#$(manifest-inputs manifest)))) + (update-desktop-database (string-append + #+desktop-file-utils + "/bin/update-desktop-database"))) + (mkdir-p (string-append #$output "/share")) + (union-build destdir appdirs + #:log-port (%make-void-port "w")) + (zero? (system* update-desktop-database destdir))))) + + ;; Don't run the hook when 'desktop-file-utils' is not installed. + (if (manifest-lookup manifest (manifest-pattern (name "desktop-file-utils"))) + (gexp->derivation "xdg-desktop-database" build + #:modules '((guix build utils) + (guix build union)) + #:local-build? #t + #:substitutable? #f) + (with-monad %store-monad (return #f)))) + (define %default-profile-hooks ;; This is the list of derivation-returning procedures that are called by ;; default when making a non-empty profile. (list info-dir-file ghc-package-cache-file ca-certificate-bundle - gtk-icon-themes)) + gtk-icon-themes + xdg-desktop-database)) (define* (profile-derivation manifest #:key -- 2.5.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-profiles-Add-xdg-mime-database-hook.patch --] [-- Type: text/x-patch, Size: 2832 bytes --] From 5e39f976de2ee6854b530a011e036b6ec2018810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com> Date: Thu, 4 Feb 2016 15:35:03 +0800 Subject: [PATCH 2/2] profiles: Add xdg-mime-database hook. * guix/profiles.scm (xdg-mime-database): New function. (%default-profile-hooks): Add it. --- guix/profiles.scm | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index a9375e6..8f9d617 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -719,6 +719,42 @@ MIME type." #:substitutable? #f) (with-monad %store-monad (return #f)))) +(define (xdg-mime-database manifest) + "Return a derivation that builds the @file{mime.cache} database from manifest +entries. It's used to query the MIME type of a given file." + (define shared-mime-info + (module-ref (resolve-interface '(gnu packages gnome)) + 'shared-mime-info)) + + (define build + #~(begin + (use-modules (srfi srfi-26) + (guix build utils) + (guix build union)) + (let* ((datadir (string-append #$output "/share")) + (destdir (string-append datadir "/mime")) + (mimedirs (filter file-exists? + (map (cut string-append <> + "/share/mime") + '#$(manifest-inputs manifest)))) + (update-mime-database (string-append + #+shared-mime-info + "/bin/update-mime-database"))) + (mkdir-p datadir) + (union-build destdir mimedirs + #:log-port (%make-void-port "w")) + (setenv "XDG_DATA_HOME" datadir) + (zero? (system* update-mime-database destdir))))) + + ;; Don't run the hook when 'shared-mime-info' is not installed. + (if (manifest-lookup manifest (manifest-pattern (name "shared-mime-info"))) + (gexp->derivation "xdg-mime-database" build + #:modules '((guix build utils) + (guix build union)) + #:local-build? #t + #:substitutable? #f) + (with-monad %store-monad (return #f)))) + (define %default-profile-hooks ;; This is the list of derivation-returning procedures that are called by ;; default when making a non-empty profile. @@ -726,7 +762,8 @@ MIME type." ghc-package-cache-file ca-certificate-bundle gtk-icon-themes - xdg-desktop-database)) + xdg-desktop-database + xdg-mime-database)) (define* (profile-derivation manifest #:key -- 2.5.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] profiles: Add xdg-desktop-database hook. 2016-02-04 7:54 ` 宋文武 @ 2016-02-07 20:13 ` Ludovic Courtès 0 siblings, 0 replies; 8+ messages in thread From: Ludovic Courtès @ 2016-02-07 20:13 UTC (permalink / raw) To: 宋文武; +Cc: guix-devel iyzsong@member.fsf.org (宋文武) skribis: > ludo@gnu.org (Ludovic Courtès) writes: [...] >> This is a small dependency, but it still depends on GLib; my >> understanding is that building any profile would end up pulling in GLib >> because of this hook. > Yes. >> >> Should we have some heuristic as for the GTK+ and GHC hooks to avoid >> pulling it in? >> >> For instance, we could check whether GLib is already an indirect >> dependency of at least one of the packages. WDYT? > Sure, but I think check on GLib is not sufficient and necessary, > when the hook run, it will use latest desktop-file-utils which may > use a different version of glib. Yes, but that’s not really a problem IMO. The situation I would want to avoid is this: you have machine with profiles containing only, say, console programs and development tools—nothing GLib or GTK+ related; and then, suddently, you end up pulling GLib even though you don’t care at all about it. If a GLib-using package is already in the profile, it’s an indication that the user is fine with pulling in GLib. Another option would be to use the ‘properties’ field to indicate which packages depend on accurate desktop or MIME info; we would need annotate all of them but rather ancestors such as GLib or Qt. WDYT? > So, I end up using a simple 'manifest-lookup', which require the > desktop-file-utils and shared-mime-info to be installed explicitly. It has the advantage of being a simpler and clearer heuristic. However, most people won’t have them in their profile, and thus they’ll end up with broken or missing MIME and desktop info, right? Tricky! Ludo’. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-02-07 20:13 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-31 12:03 [PATCH 1/2] profiles: Add xdg-desktop-database hook 宋文武 2016-01-31 12:03 ` [PATCH 2/2] profiles: Add xdg-mime-database hook 宋文武 2016-01-31 12:32 ` 宋文武 2016-02-02 13:11 ` Ludovic Courtès 2016-02-02 13:10 ` Ludovic Courtès 2016-02-02 13:09 ` [PATCH 1/2] profiles: Add xdg-desktop-database hook Ludovic Courtès 2016-02-04 7:54 ` 宋文武 2016-02-07 20:13 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).