From patchwork Thu Sep 22 20:28:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 15941 Received: (qmail 114743 invoked by uid 89); 22 Sep 2016 20:34:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=@file, 72368, Union, so X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: lists.gnu.org Received: from lists.gnu.org (HELO lists.gnu.org) (208.118.235.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Sep 2016 20:34:12 +0000 Received: from localhost ([::1]:33101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnAh8-0003Og-Fc for patchwork@sourceware.org; Thu, 22 Sep 2016 16:34:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnAbt-0006yQ-SJ for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnAbs-0008GT-FT for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:45 -0400 Received: from sender163-mail.zoho.com ([74.201.84.163]:21337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnAbs-0008G3-7D for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:44 -0400 Received: from localhost (xd933e765.dyn.telefonica.de [217.51.231.101]) by mx.zohomail.com with SMTPS id 1474576120256701.0269964956567; Thu, 22 Sep 2016 13:28:40 -0700 (PDT) From: Ricardo Wurmus To: guix-devel@gnu.org Subject: [PATCH 2/2] profiles: Build GTK+ input module cache. Date: Thu, 22 Sep 2016 22:28:27 +0200 Message-Id: <20160922202827.22039-2-rekado@elephly.net> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160922202827.22039-1-rekado@elephly.net> References: <20160922202827.22039-1-rekado@elephly.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 74.201.84.163 X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list 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+patchwork=sourceware.org@gnu.org Sender: "Guix-devel" * guix/profiles.scm (gtk-im-modules): New procedure. (%default-profile-hooks): Add it. --- guix/profiles.scm | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/guix/profiles.scm b/guix/profiles.scm index 78deeb7..1a522ae 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -723,6 +723,68 @@ creates the GTK+ 'icon-theme.cache' file for each theme." #:substitutable? #f) (return #f)))) +(define (gtk-im-modules manifest) + "Return a derivation that builds the cache files for input method modules +for both major versions of GTK+." + + (mlet %store-monad ((gtk+ (manifest-lookup-package manifest "gtk+" "3")) + (gtk+-2 (manifest-lookup-package manifest "gtk+" "2"))) + + (define (build gtk gtk-version) + (let ((major (string-take gtk-version 1))) + (with-imported-modules '((guix build utils) + (guix build union) + (guix build profiles) + (guix search-paths) + (guix records)) + #~(begin + (use-modules (guix build utils) + (guix build union) + (guix build profiles) + (ice-9 popen) + (srfi srfi-26)) + + (let* ((prefix (string-append "/lib/gtk-" #$major ".0/" + #$gtk-version)) + (query (string-append #$gtk "/bin/gtk-query-immodules-" + #$major ".0")) + (destdir (string-append #$output prefix)) + (moddirs (cons (string-append #$gtk prefix "/immodules") + (filter file-exists? + (map (cut string-append <> prefix "/immodules") + '#$(manifest-inputs manifest)))))) + + ;; Union all the gtk immodules directories. + (mkdir-p (string-append #$output "/lib/gtk-" #$major ".0")) + (union-build destdir moddirs #:log-port (%make-void-port "w")) + + ;; Generate a new 'immodules.cache' file. + (let ((pipe (apply open-pipe* + OPEN_READ query + (map readlink (find-files destdir "\\.so$")))) + (outfile (string-append #$output prefix + "/immodules-gtk" #$major ".cache"))) + (dynamic-wind + (const #t) + (lambda () + (call-with-output-file outfile + (lambda (out) + (while (not (eof-object? (peek-char pipe))) + (write-char (read-char pipe) out)))) + #t) + (lambda () + (close-pipe pipe))))))))) + + ;; Don't run the hook when there's nothing to do. + (let ((gexp #~(begin + #$(if gtk+ (build gtk+ "3.0.0") #t) + #$(if gtk+-2 (build gtk+-2 "2.10.0") #t)))) + (if (or gtk+ gtk+-2) + (gexp->derivation "gtk-im-modules" gexp + #:local-build? #t + #: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 @@ -844,6 +906,7 @@ files for the truetype fonts of the @var{manifest} entries." ghc-package-cache-file ca-certificate-bundle gtk-icon-themes + gtk-im-modules xdg-desktop-database xdg-mime-database))