Message ID | 20220921002921.23631-2-higashi@taiju.info |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0DD7027BBEA; Wed, 21 Sep 2022 01:41:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B803827BBE9 for <patchwork@mira.cbaines.net>; Wed, 21 Sep 2022 01:41:16 +0100 (BST) Received: from localhost ([::1]:59830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) id 1oannf-0006Xi-T3 for patchwork@mira.cbaines.net; Tue, 20 Sep 2022 20:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oancq-0001wt-IY for guix-patches@gnu.org; Tue, 20 Sep 2022 20:30:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oancp-0002Tr-2s for guix-patches@gnu.org; Tue, 20 Sep 2022 20:30:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oanco-0007by-LH for guix-patches@gnu.org; Tue, 20 Sep 2022 20:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig. References: <20220921002721.23511-1-higashi@taiju.info> In-Reply-To: <20220921002721.23511-1-higashi@taiju.info> Resent-From: Taiju HIGASHI <higashi@taiju.info> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Sep 2022 00:30:02 +0000 Resent-Message-ID: <handler.57963.B57963.166372018529214@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57963 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57963@debbugs.gnu.org Cc: Taiju HIGASHI <higashi@taiju.info> Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166372018529214 (code B ref 57963); Wed, 21 Sep 2022 00:30:02 +0000 Received: (at 57963) by debbugs.gnu.org; 21 Sep 2022 00:29:45 +0000 Received: from localhost ([127.0.0.1]:60072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1oancW-0007b7-Lv for submit@debbugs.gnu.org; Tue, 20 Sep 2022 20:29:44 -0400 Received: from mail-pg1-f175.google.com ([209.85.215.175]:44886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <higashi@taiju.info>) id 1oancU-0007aq-Cy for 57963@debbugs.gnu.org; Tue, 20 Sep 2022 20:29:42 -0400 Received: by mail-pg1-f175.google.com with SMTP id c7so4316546pgt.11 for <57963@debbugs.gnu.org>; Tue, 20 Sep 2022 17:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taiju-info.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=wz0FAF8lUUJIDLZjh0sc33ihU8m/ext0PdmPTJHBuwE=; b=3M0dmK6dPkFWVKQlS47Ge0JcsugiXonm14ZqayPq4zyF5MFlu9pYJwBr58BrRGzg6N GK8+br4KDKCzoUCE76bYxKqmX7S/KeOeUy81oiC2/ph878lMOYrcRvkZ9/jRU8/+u5Kp urE1cAph/8+ersCkOocYWMT9c37wB2mDcosYlfDFPr/7h/RHkNUPAULGCzBtjyZ7gRWP sV1saTu7lBnV4YhIt4v1t7KcaMR9CEliApzSripf/AH4C3i1wzSv/ovwyXSpDyB1KywB kknnWXEvgESZZu+yK6Cjo9qwDpBiBSy4+S25d4C2xbq23110IL1TZhXP5PMKq4Moy/Mf 8vQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=wz0FAF8lUUJIDLZjh0sc33ihU8m/ext0PdmPTJHBuwE=; b=Yq0v3oQCLFTN5N8uDAW47J34Tx734RHW28xmfHbOkn+tp88Sv+aDNzh7J/MMJcIkDY jY4PWJ5vzoJBBVlMW/4LBqoWGOAnCOgDH3VP8BTGWzF2yCJVwNsYymgJODztF6WoiHcL J4dysU0YdAgvRxTWuqk5f97UqUtvZ3Bz2UWylZv8vp0AUz0i4LdfgLmKgnk7XUk3t6+V +VFgvKTilBbIvpxC6is+VntW2/g0h3apLKP8/SAx75pL+7eH4wC9I5aHOIJiETQ6S/AO W3lSVTYD2pkpKenE02tVMlyfdrhtPPPywrUZChfl+ebP6uEe3DuTapPXr2xqE6+q25ct b/LQ== X-Gm-Message-State: ACrzQf09ZpVFl1qGH2YX4tMMnxr244zqJZF2aNTjB4b7nfAnp15BZqR9 647RlBGrhfZnipkTwTdwytX1g+5rpLKw5MiY X-Google-Smtp-Source: AMsMyM7E1fUz8fovv13QxvPsavuL2aNLYzxNVifSvz2YitLTm9A+LI4ID5jvw2hvW1QVeRX8/LQxxw== X-Received: by 2002:a63:2bcc:0:b0:439:36bb:c036 with SMTP id r195-20020a632bcc000000b0043936bbc036mr22304743pgr.447.1663720176217; Tue, 20 Sep 2022 17:29:36 -0700 (PDT) Received: from Taix.flets-west.jp ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id u1-20020a626001000000b0053b9e5d365bsm494914pfb.216.2022.09.20.17.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 17:29:35 -0700 (PDT) From: Taiju HIGASHI <higashi@taiju.info> Date: Wed, 21 Sep 2022 09:29:21 +0900 Message-Id: <20220921002921.23631-2-higashi@taiju.info> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
Support user's fontconfig.
|
|
Commit Message
Taiju HIGASHI
Sept. 21, 2022, 12:29 a.m. UTC
* gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's fontconfig. --- gnu/home/services/fontutils.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
Comments
Am Mittwoch, dem 21.09.2022 um 09:29 +0900 schrieb Taiju HIGASHI: > * gnu/home/services/fontutils.scm (add-fontconfig-config-file): > Support user's fontconfig. > --- > gnu/home/services/fontutils.scm | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/gnu/home/services/fontutils.scm > b/gnu/home/services/fontutils.scm > index 6062eaed6a..3ea8b1db74 100644 > --- a/gnu/home/services/fontutils.scm > +++ b/gnu/home/services/fontutils.scm > @@ -1,6 +1,7 @@ > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> > ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> > +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info> > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -21,6 +22,7 @@ (define-module (gnu home services fontutils) > #:use-module (gnu home services) > #:use-module (gnu packages fontutils) > #:use-module (guix gexp) > + #:use-module (srfi srfi-1) > > #:export (home-fontconfig-service-type)) > > @@ -33,15 +35,18 @@ (define-module (gnu home services fontutils) > ;;; > ;;; Code: > > -(define (add-fontconfig-config-file he-symlink-path) > +(define (add-fontconfig-config-file font-config) > `(("fontconfig/fonts.conf" > ,(mixed-text-file > "fonts.conf" > "<?xml version='1.0'?> > <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> > <fontconfig> > - <dir>~/.guix-home/profile/share/fonts</dir> > -</fontconfig>")))) > + <dir>~/.guix-home/profile/share/fonts</dir>\n" > + (if (null? font-config) > + "" > + (string-join font-config "\n" 'suffix)) > + "</fontconfig>\n")))) I think it'd be wiser to pretty-print SXML here. The structure could look something like `(fontconfig (dir "~/.guix-home/profile/share/fonts") ,@(extra-user-config ...)) Also, for the particular use case of handling multiple profiles gracefully (rather than the current status quo) I think fontconfig- service-type should be able to construct (dir "#$profile/share/fonts") style entries on its own. However, given that multiple profiles aren't supported yet, this is future work. Cheers
Hi Liliana, Thank you for your review. >> -(define (add-fontconfig-config-file he-symlink-path) >> +(define (add-fontconfig-config-file font-config) >> `(("fontconfig/fonts.conf" >> ,(mixed-text-file >> "fonts.conf" >> "<?xml version='1.0'?> >> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> >> <fontconfig> >> - <dir>~/.guix-home/profile/share/fonts</dir> >> -</fontconfig>")))) >> + <dir>~/.guix-home/profile/share/fonts</dir>\n" >> + (if (null? font-config) >> + "" >> + (string-join font-config "\n" 'suffix)) >> + "</fontconfig>\n")))) > I think it'd be wiser to pretty-print SXML here. > The structure could look something like > `(fontconfig > (dir "~/.guix-home/profile/share/fonts") > ,@(extra-user-config ...)) That's definitely better! Does this assume that SXML will also accept additional user settings? > Also, for the particular use case of handling multiple profiles > gracefully (rather than the current status quo) I think fontconfig- > service-type should be able to construct (dir "#$profile/share/fonts") > style entries on its own. However, given that multiple profiles aren't > supported yet, this is future work. Noted. I believe that even with the current patch, it is possible to add arbitrary directories, so it will be better than what we have now. Cheers
Am Mittwoch, dem 21.09.2022 um 18:59 +0900 schrieb Taiju HIGASHI: > Hi Liliana, > > Thank you for your review. > > > > -(define (add-fontconfig-config-file he-symlink-path) > > > +(define (add-fontconfig-config-file font-config) > > > `(("fontconfig/fonts.conf" > > > ,(mixed-text-file > > > "fonts.conf" > > > "<?xml version='1.0'?> > > > <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> > > > <fontconfig> > > > - <dir>~/.guix-home/profile/share/fonts</dir> > > > -</fontconfig>")))) > > > + <dir>~/.guix-home/profile/share/fonts</dir>\n" > > > + (if (null? font-config) > > > + "" > > > + (string-join font-config "\n" 'suffix)) > > > + "</fontconfig>\n")))) > > I think it'd be wiser to pretty-print SXML here. > > The structure could look something like > > `(fontconfig > > (dir "~/.guix-home/profile/share/fonts") > > ,@(extra-user-config ...)) > > That's definitely better! > Does this assume that SXML will also accept additional user settings? It assumes that whatever (extra-user-config ...) does, it returns a list of SXML nodes, e.g. ((dir "~/.fonts")). Writing correct SXML should be comparatively simpler to writing correct XML. > > Also, for the particular use case of handling multiple profiles > > gracefully (rather than the current status quo) I think fontconfig- > > service-type should be able to construct (dir > > "#$profile/share/fonts") style entries on its own. However, given > > that multiple profiles aren't supported yet, this is future work. > > Noted. I believe that even with the current patch, it is possible to > add arbitrary directories, so it will be better than what we have > now. That's fine, just know that this use case might at some point become obsolete thanks to a better implementation :)
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes: > Am Mittwoch, dem 21.09.2022 um 18:59 +0900 schrieb Taiju HIGASHI: >> Hi Liliana, >> >> Thank you for your review. >> >> > > -(define (add-fontconfig-config-file he-symlink-path) >> > > +(define (add-fontconfig-config-file font-config) >> > > `(("fontconfig/fonts.conf" >> > > ,(mixed-text-file >> > > "fonts.conf" >> > > "<?xml version='1.0'?> >> > > <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> >> > > <fontconfig> >> > > - <dir>~/.guix-home/profile/share/fonts</dir> >> > > -</fontconfig>")))) >> > > + <dir>~/.guix-home/profile/share/fonts</dir>\n" >> > > + (if (null? font-config) >> > > + "" >> > > + (string-join font-config "\n" 'suffix)) >> > > + "</fontconfig>\n")))) >> > I think it'd be wiser to pretty-print SXML here. >> > The structure could look something like >> > `(fontconfig >> > (dir "~/.guix-home/profile/share/fonts") >> > ,@(extra-user-config ...)) >> >> That's definitely better! >> Does this assume that SXML will also accept additional user settings? > It assumes that whatever (extra-user-config ...) does, it returns a > list of SXML nodes, e.g. ((dir "~/.fonts")). Writing correct SXML > should be comparatively simpler to writing correct XML. I just sent you the v2 patch. It uses SXML to handle the user's extra configs. I also made it so that the user can pass SXML directly. I also wrote a test but did not include it in the patch because I thought it would be a technical debt. I'm attaching that as a reference. ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (test-home-services-fontutils) #:use-module (gnu services) #:use-module (gnu home services) #:use-module (gnu home services fontutils) #:use-module (guix tests) #:use-module (sxml simple) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64)) ;; or (@@ (gnu home services fontutils) add-fontconfig-config-file) (define add-fontconfig-config-file (let* ((extensions (service-type-extensions home-fontconfig-service-type)) (extension (find (lambda (ext) (eq? (service-extension-target ext) home-xdg-configuration-files-service-type)) extensions)) (compute (service-extension-compute extension))) compute)) (define (assert-fontconfig-value value expected) (mock ((guix gexp) mixed-text-file (lambda* (name #:key guile #:rest text) (let ((text (string-join text ""))) (unless (string= text expected) (error "assert failed. actual: %s" text))))) (add-fontconfig-config-file value) #t)) (test-begin "home-services-fontutils") (test-assert "fontconfig (default value)" (assert-fontconfig-value '() "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir></fontconfig> ")) (test-assert "fontconfig (a text)" (assert-fontconfig-value '("<foo>foo</foo>") "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo></fontconfig> ")) (test-assert "fontconfig (multiple texts)" (assert-fontconfig-value '("<foo>foo</foo>" "<bar><baz>baz</baz></bar>") "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo><bar><baz>baz</baz></bar></fontconfig> ")) (test-assert "fontconfig (a sxml)" (assert-fontconfig-value '((foo foo)) "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo></fontconfig> ")) (test-assert "fontconfig (multiple sxml)" (assert-fontconfig-value '((foo foo) (bar (baz baz))) "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo><bar><baz>baz</baz></bar></fontconfig> ")) (test-error "fontconfig (invalid value)" (add-fontconfig-config-file '(123))) (test-end "home-services-fontutils") >> > Also, for the particular use case of handling multiple profiles >> > gracefully (rather than the current status quo) I think fontconfig- >> > service-type should be able to construct (dir >> > "#$profile/share/fonts") style entries on its own. However, given >> > that multiple profiles aren't supported yet, this is future work. >> >> Noted. I believe that even with the current patch, it is possible to >> add arbitrary directories, so it will be better than what we have >> now. > That's fine, just know that this use case might at some point become > obsolete thanks to a better implementation :) No problem. I would like to solve the current problem first. A better implementation is always welcome :) Cheers
Am Donnerstag, dem 22.09.2022 um 10:27 +0900 schrieb Taiju HIGASHI: > I also wrote a test but did not include it in the patch because I > thought it would be a technical debt. > I'm attaching that as a reference. Added tests are always welcome.
diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm index 6062eaed6a..3ea8b1db74 100644 --- a/gnu/home/services/fontutils.scm +++ b/gnu/home/services/fontutils.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info> ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,7 @@ (define-module (gnu home services fontutils) #:use-module (gnu home services) #:use-module (gnu packages fontutils) #:use-module (guix gexp) + #:use-module (srfi srfi-1) #:export (home-fontconfig-service-type)) @@ -33,15 +35,18 @@ (define-module (gnu home services fontutils) ;;; ;;; Code: -(define (add-fontconfig-config-file he-symlink-path) +(define (add-fontconfig-config-file font-config) `(("fontconfig/fonts.conf" ,(mixed-text-file "fonts.conf" "<?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> - <dir>~/.guix-home/profile/share/fonts</dir> -</fontconfig>")))) + <dir>~/.guix-home/profile/share/fonts</dir>\n" + (if (null? font-config) + "" + (string-join font-config "\n" 'suffix)) + "</fontconfig>\n")))) (define (regenerate-font-cache-gexp _) `(("profile/share/fonts" @@ -49,6 +54,8 @@ (define (regenerate-font-cache-gexp _) (define home-fontconfig-service-type (service-type (name 'home-fontconfig) + (compose concatenate) + (extend append) (extensions (list (service-extension home-xdg-configuration-files-service-type @@ -59,7 +66,7 @@ (define home-fontconfig-service-type (service-extension home-profile-service-type (const (list fontconfig))))) - (default-value #f) + (default-value '()) (description "Provides configuration file for fontconfig and make fc-* utilities aware of font packages installed in Guix Home's profile.")))