From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?5a6L5paH5q2m?= Subject: Re: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks. Date: Sun, 10 May 2015 12:55:27 +0800 Message-ID: <87twvlghfk.fsf@gmail.com> References: <1431147336-4274-1-git-send-email-iyzsong@gmail.com> <877fsixrmg.fsf@gmail.com> <87wq0hg7td.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrJGS-0003CY-N4 for guix-devel@gnu.org; Sun, 10 May 2015 00:54:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YrJGR-0008RQ-KC for guix-devel@gnu.org; Sun, 10 May 2015 00:54:56 -0400 In-Reply-To: <87wq0hg7td.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org Ludovic Court=C3=A8s writes: > =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: > >> This is WIP. >>> * guix/profiles.scm (gtk-icon-theme-hook): New function. >>> (%default-profile-hooks): Add `(gtk-icon-theme-hook "hicolor")' and >>> `(gtk-icon-theme-hook "HighContrast")'. > > Looks nice! > >>> +(define (gtk-icon-theme-hook name) >>> + "Return a profile hook that unions all NAME icons from manifest entr= ies and >>> +rebuilds the 'icon-theme.cache' file for the NAME icon theme." >>> + (define gtk+ >>> + (module-ref (resolve-interface '(gnu packages gtk)) 'gtk+)) >>> + >>> + (lambda (manifest) >>> + (define build >>> + #~(begin >>> + (use-modules (guix build utils) >>> + (guix build union)) >>> + (let* ((icon-dir (lambda (base) >>> + (string-append base "/share/icons/" #$nam= e))) >>> + (destdir (icon-dir #$output)) >>> + (icons (filter >>> + file-exists? >>> + (map icon-dir '#$(manifest-inputs manifest= )))) >>> + (update-icon-cache (string-append >>> + #+gtk+ "/bin/gtk-update-icon-cach= e"))) >>> + ;; mkdir -p $out/share/icons >>> + (mkdir-p destdir) >>> + (rmdir destdir) >>> + ;; Unions all the icons and update the 'icon-theme.cache'. >>> + (union-build destdir icons) >>> + (system* update-icon-cache "-t" destdir)))) >>> + >>> + (gexp->derivation (string-append (string-downcase name) "-icon-the= me") >>> + build >>> + #:modules '((guix build utils) >>> + (guix build union)) >>> + #:local-build? #t))) >> When to exclude this derivation? >> >> 1. the best would be whether icon dir exists or not >> but is this posibble to implement? and how? > > Currently this is not possible. The builder could depend on all the > manifest entries and scan them for share/icons directory, but at this > point it=E2=80=99s already too later because the build has to depend on G= TK+. Does it mean we can't scan them (manifest-inputs) out of the builder, because they may haven't be realized? > >> 2. whether we have a gtk+ package in profile > > That=E2=80=99s no usually the case. For instance, I have Evince and GIMP= in my > profile, but not GTK+. > > What could be done is to check whether GTK+ appears and an direct or > indirect dependency of the packages being installed. > > Currently manifest entries can contain either a package object or a > store path. In the former case, one has to use package->bag and then > look for GTK+ in the bag=E2=80=99s transitive inputs. In the latter, cas= e, one > needs to call =E2=80=98references=E2=80=99 to check whether the store ite= m, which is > already built, depends on GTK+. > > When none of the manifest=E2=80=99s packages depends on GTK+, then the ho= ok can > just return #f, like ghc-package-cache-file does. > > Does that make sense? OK, I'll try this way. And, which GTK+ we should use to do the icon update? How about choose the one referenced by manifest entries (either gtk+-2 or gtk+-3) instead of the latest gtk+-3 deployed? So, we can avoid downloading the new GTK+. (IMO, this is useful for GHC too) > >>> (define %default-profile-hooks >>> ;; This is the list of derivation-returning procedures that are call= ed by >>> ;; default when making a non-empty profile. >>> (list info-dir-file >>> ghc-package-cache-file >>> - ca-certificate-bundle)) >>> + ca-certificate-bundle >>> + (gtk-icon-theme-hook "hicolor") >>> + (gtk-icon-theme-hook "HighContrast"))) >> Does these 2 enough? I think in practical, it does. >> Or (better) as Federico Beffa said in: >> >> http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00108.html >> >> We should rebuilds all the icon themes? >> If so, I think the code will be more complex... > > Let=E2=80=99s have an incremental approach and start with the simple yet = helpful > approach that you propose. We can improve later. > > Thoughts? Sure, thanks your review! > > Thanks, > Ludo=E2=80=99.