From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 02:40:51 2022 Received: (at 57963) by debbugs.gnu.org; 10 Oct 2022 06:40:51 +0000 Received: from localhost ([127.0.0.1]:45545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohmT5-0003nA-1J for submit@debbugs.gnu.org; Mon, 10 Oct 2022 02:40:51 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:34443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohmT1-0003mu-7B for 57963@debbugs.gnu.org; Mon, 10 Oct 2022 02:40:49 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id F0FE340004; Mon, 10 Oct 2022 06:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1665384041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eCpzUZ5YJPyFCWLfXiJHe3QfZwMrQnmxG4S0zJmXwhE=; b=j2NyPn+ld2Bljg4BIxI3MJyl78hoQvyTFRoCJVYrLxn7a/UYYCTjrPOsSRrC14AcgrFD7c PyACGlBI/NQ2ij+O71LGdliWPNIVPUb5ktMLQxbAxFJMgPxolK9i+ZLt3JmpCh9H2k+tN5 CPSm2b1Oq34YZ0a5g45tyiVlZgKJxp3qMpiQszxFbZ2EaRKMtLJkDgtidGl4ki9ctgnDoK 2dLUlo8opGKLzmn7xDJc5D8ouLNJP9uVJhEh9c0m5CJ6JUVNR/Vrw/2cprHo+JDun23Lu1 q/ZqyFofpYOW7LueBLiaQ5u5Efa5EwDMnjsny48ENQYID7crTSH9ojrMdmWS0g== From: Andrew Tropin To: Taiju HIGASHI , 57963@debbugs.gnu.org Subject: Re: [PATCH v5 2/2] home: services: Support user's fontconfig configuration. In-Reply-To: <20221002131535.9972-2-higashi@taiju.info> References: <20221002131535.9972-1-higashi@taiju.info> <20221002131535.9972-2-higashi@taiju.info> Date: Mon, 10 Oct 2022 10:40:30 +0400 Message-ID: <87zge4chb5.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 2022-10-02 22:15, Taiju HIGASHI wrote: > * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's > fontconfig configuration. > (home-fontconfig-configuration): New configuration for it. > (string-list, maybe-string, [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.183.194 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.194 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: 57963 Cc: ludo@gnu.org, Taiju HIGASHI , liliana.prikler@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-10-02 22:15, Taiju HIGASHI wrote: > * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support u= ser's > fontconfig configuration. > (home-fontconfig-configuration): New configuration for it. > (string-list, maybe-string, maybe-extra-config-list): New types for it. > (string-list?, extra-config-list?): New predicate procedures for it. > (serialize-string-list, serialize-string, serialize-extra-config-list): N= ew > serialize procedures for it. > (guix-home-font-dir): New variable. > --- > gnu/home/services/fontutils.scm | 89 ++++++++++++++++++++++++++++++--- > 1 file changed, 83 insertions(+), 6 deletions(-) > > diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutil= s.scm > index 6062eaed6a..4b3caf3985 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 =C2=A9 2021 Andrew Tropin > ;;; Copyright =C2=A9 2021 Xinglu Chen > +;;; Copyright =C2=A9 2022 Taiju HIGASHI > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -20,9 +21,17 @@ > (define-module (gnu home services fontutils) > #:use-module (gnu home services) > #:use-module (gnu packages fontutils) > + #:use-module (gnu services configuration) > + #:use-module (guix diagnostics) > #:use-module (guix gexp) > + #:use-module (guix i18n) > + #:use-module (guix records) > + #:use-module (srfi srfi-1) > + #:use-module (sxml simple) > + #:use-module (ice-9 match) >=20=20 > - #:export (home-fontconfig-service-type)) > + #:export (home-fontconfig-service-type > + home-fontconfig-configuration)) >=20=20 > ;;; Commentary: > ;;; > @@ -33,15 +42,83 @@ (define-module (gnu home services fontutils) > ;;; > ;;; Code: >=20=20 > -(define (add-fontconfig-config-file he-symlink-path) > +(define (sxml->xml-string sxml) > + "Serialize the sxml tree @var{tree} as XML. The output will be string." > + (call-with-output-string > + (lambda (port) > + (sxml->xml sxml port)))) > + > +(define guix-home-font-dir "~/.guix-home/profile/share/fonts") > + > +(define (string-list? value) > + (and (pair? value) (every string? value))) Better to use list? here and in the other places, at least for the consistency, but also for semantic meaning. > + > +(define (serialize-string-list field-name value) > + (sxml->xml-string > + (map > + (lambda (path) `(dir ,path)) > + (if (member guix-home-font-dir value) > + value > + (append (list guix-home-font-dir) value))))) > + > +(define (serialize-string field-name value) > + (define (serialize type value) > + (sxml->xml-string > + `(alias > + (family ,type) > + (prefer > + (family ,value))))) > + (match (list field-name value) > + (('default-font-serif-family family) > + (serialize 'serif family)) > + (('default-font-sans-serif-family family) > + (serialize 'sans-serif family)) > + (('default-font-monospace-family family) > + (serialize 'monospace family)))) > + > +(define-maybe string) > + > +(define extra-config-list? list?) > + > +(define-maybe extra-config-list) > + > +(define (serialize-extra-config-list field-name value) > + (sxml->xml-string > + (map (match-lambda > + ((? pair? sxml) sxml) Other branches would never be visited because it will fail earlier by define-configuration predicate check for extra-config-list? (which is basically list?). Also, making multi-type fields is debatable, but isn't great IMO. If serialization would support G-exps, we could write=20 (list #~"RAW_XML_HERE") or even something like this: (list #~(READ-THE-WHOLE-FILE #$(local-file "our-old.xml"))) > + ((? string? xml) (xml->sxml xml)) > + (else > + (raise (formatted-message > + (G_ "'extra-config' type must be xml string or sxml l= ist, was given: ~a") > + value)))) > + value))) > + > +(define-configuration home-fontconfig-configuration > + (font-directories > + (string-list (list guix-home-font-dir)) It's not a generic string-list, but a specific font-directories-list with extra logic inside. Also, because guix-home-font-dir always added to the list, the default value should '() and field should be called additional-font-directories instead. Otherwise it will be confusing, why guix-home-font-dir is not removed from the final configuration, when this field is set to a different value. I skimmed previous messages, but sorry, if I missed any already mentioned points. > + "The directory list that provides fonts.") > + (default-font-serif-family > + maybe-string > + "The preffered default fonts of serif.") > + (default-font-sans-serif-family > + maybe-string > + "The preffered default fonts of sans-serif.") > + (default-font-monospace-family > + maybe-string > + "The preffered default fonts of monospace.") > + (extra-config > + maybe-extra-config-list > + "Extra configuration values to append to the fonts.conf.")) > + > +(define (add-fontconfig-config-file user-config) > `(("fontconfig/fonts.conf" > ,(mixed-text-file > "fonts.conf" > " > > - > - ~/.guix-home/profile/share/fonts > -")))) > +" > + (serialize-configuration user-config home-fontconfig-configuratio= n-fields) Just a thought for the future and a point for configuration module improvements: It would be cool if serialize-configuration and all other serialize- functions returned a G-exps, this way we could write something like that: (home-fontconfig-configuration (font-directories (list (file-append font-iosevka "/share/fonts")))) > + "\n")))) >=20=20 > (define (regenerate-font-cache-gexp _) > `(("profile/share/fonts" > @@ -59,7 +136,7 @@ (define home-fontconfig-service-type > (service-extension > home-profile-service-type > (const (list fontconfig))))) > - (default-value #f) > + (default-value (home-fontconfig-configuration)) > (description > "Provides configuration file for fontconfig and make > fc-* utilities aware of font packages installed in Guix Home's profile."= ))) =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNDvl4ACgkQIgjSCVjB 3rCueA/+PBM5g/Qe3+91C8u4h+s/0Ot6D9VJhBDQRLEgNYPkFKHKQ4dqsR0WQVHC QHpNmBlHp8cuh34q7UJ2YHMj+5MNzZK/iwekUu7eG0ioWTqTZe6dfVoq5ImPawgd 4f8CmcOFLRlmGD29EOjka9qkb7K8vHlBrOL3GBWiutLO7jmWgdlt3AcX6ehggqD7 8Jb5+aSwAcGl580RBMr/0SyTUqsvesyGjoRQn6T1AWZQI/2QRtYP6TAGlZ8TDbbr tYTU7Mgcvw9WkxjfpwK4JU6kDvp9e1I9HzfjlPfCgALOeYmpCjUWIAOSaouyZxXX JT5FmNXO+tY3Fra0SaD7CpyEF9JhtEnAgyPNECM35Ym/dP9mV/zaL4miZdJTC+Ef 2ItbOCHNU5LFWKXCOLLorKl+4D1o4Ux9csFrH9u/kHfxuZhJk8WKFW0IraMViXRN u4TF432subComkGGyBkoe5egCahVmD6CwqpQI0YMhje5vppN6bdjp5oY94oBoLuL MoibLZffrYmc4mTigrgzF7fA1+kg80Vm0SyOB3uVPgqokzXVJrp1vgRNVj2K0/NA 4Sq3hMPEknfLUgBktZI60C1OqFo6Eur1VAcq6DdOrJknpO2pd934gKveoFt39xcJ sXz9YgeU0kEU68FEdDo7pS732O6WCz/Q5HNkuAXyp9e1YtPz6yY= =ngCV -----END PGP SIGNATURE----- --=-=-=--