From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks. Date: Sat, 09 May 2015 16:10:54 +0200 Message-ID: <87wq0hg7td.fsf@gnu.org> References: <1431147336-4274-1-git-send-email-iyzsong@gmail.com> <877fsixrmg.fsf@gmail.com> 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]:59999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yr5T8-0002ot-LY for guix-devel@gnu.org; Sat, 09 May 2015 10:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yr5T4-00054J-0q for guix-devel@gnu.org; Sat, 09 May 2015 10:11:06 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yr5T3-00054A-TS for guix-devel@gnu.org; Sat, 09 May 2015 10:11:01 -0400 In-Reply-To: <877fsixrmg.fsf@gmail.com> (=?utf-8?B?IuWui+aWh+atpiIncw==?= message of "Sat, 09 May 2015 13:11:03 +0800") 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: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org =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 entri= es 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/" #$name= ))) >> + (destdir (icon-dir #$output)) >> + (icons (filter >> + file-exists? >> + (map icon-dir '#$(manifest-inputs manifest)= ))) >> + (update-icon-cache (string-append >> + #+gtk+ "/bin/gtk-update-icon-cache= "))) >> + ;; 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-them= e") >> + 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 GTK= +. > 2. whether we have a gtk+ package in profile That=E2=80=99s no usually the case. For instance, I have Evince and GIMP i= n 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, case,= one needs to call =E2=80=98references=E2=80=99 to check whether the store item,= which is already built, depends on GTK+. When none of the manifest=E2=80=99s packages depends on GTK+, then the hook= can just return #f, like ghc-package-cache-file does. Does that make sense? >> (define %default-profile-hooks >> ;; This is the list of derivation-returning procedures that are calle= d 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 he= lpful approach that you propose. We can improve later. Thoughts? Thanks, Ludo=E2=80=99.