From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GHg9Iyy2RmO6jwAAbAwnHQ (envelope-from ) for ; Wed, 12 Oct 2022 14:42:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id SIFVIiy2RmOKcQEAG6o9tA (envelope-from ) for ; Wed, 12 Oct 2022 14:42:20 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 477E0857F for ; Wed, 12 Oct 2022 14:42:20 +0200 (CEST) Received: from localhost ([::1]:54650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oib3z-0008Hs-E9 for larch@yhetil.org; Wed, 12 Oct 2022 08:42:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oib3l-0008HT-3y for guix-patches@gnu.org; Wed, 12 Oct 2022 08:42:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oib3i-0002sG-5w for guix-patches@gnu.org; Wed, 12 Oct 2022 08:42:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oib3h-0005Rz-UW for guix-patches@gnu.org; Wed, 12 Oct 2022 08:42:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 12 Oct 2022 12:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57963 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Taiju HIGASHI Cc: ludo@gnu.org, 57963@debbugs.gnu.org, liliana.prikler@gmail.com Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166557849420917 (code B ref 57963); Wed, 12 Oct 2022 12:42:01 +0000 Received: (at 57963) by debbugs.gnu.org; 12 Oct 2022 12:41:34 +0000 Received: from localhost ([127.0.0.1]:56036 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oib3F-0005RI-Mq for submit@debbugs.gnu.org; Wed, 12 Oct 2022 08:41:34 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:55869) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oib3E-0005R6-Ag for 57963@debbugs.gnu.org; Wed, 12 Oct 2022 08:41:33 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 9C6531BF212; Wed, 12 Oct 2022 12:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1665578486; 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=Uz+g2UdVDr1SBtKhiv9n4T4IZ44+oKz1cUmbTPheT3s=; b=RnZBbBJjXp+DlEbP8o6sDRoZINJwcEQ+UyVkYVBlS7N7KAzxME1ev+MDbsuIUFlPDHaKM4 h8GbeXQaop/gc/fit60MMIQjoURVTOPeUgtvOxe9Bn2vsJjqZ3X0PoOK9WlwTsAb8Dspdz Mlns250y+cd2QzG99ElQxbr/63x/mv42ZbxMDRrrZokc5AcOgeQ2SN7XQyqYuoY/Wujcag hrZodXcZSWslTRFGXDa/ILT0yIalo/rkvAya441xjI4VXbRZyAkh0r9oj1+zlwaBy3ZdLX cdNe56dH7Ca+tXs3Ctccl8MyGUrkpDmBwFJyiY3pEw7pS6fD4I+/ROiDY4c47Q== From: Andrew Tropin In-Reply-To: <87k055i864.fsf@taiju.info> References: <20221002131535.9972-1-higashi@taiju.info> <20221002131535.9972-2-higashi@taiju.info> <87zge4chb5.fsf@trop.in> <87edvfkob8.fsf@taiju.info> <87wn95mtih.fsf@trop.in> <87k055i864.fsf@taiju.info> Date: Wed, 12 Oct 2022 16:41:16 +0400 Message-ID: <87a661mcyb.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665578540; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=Uz+g2UdVDr1SBtKhiv9n4T4IZ44+oKz1cUmbTPheT3s=; b=svhD6PzWTd/xKina36a2DfyKIqs7xXPBJQ4dZeO0+y8CeOcFBzKQvVkCjj8lUAkCXRWvJ9 1s4qFRZC4ccxSVsci2cMiGEaDDf5UUpMqZ0UNpyKcYDge9o0xemSKWV2dhojId5M62hXQ8 dRT2aDzEo1qGuu9jOm6KL5ojC0qRNjtfEYb9pTxgPSsVTQFpy2ROpAD6LdCjFb3Y9zAxW7 lnp8OWP6b7syifQsE3PIjAKM/wTtdazWkKhX0gVTtuD3D5MmQJjz2Ua3BqmkCzhoL72uEb NdkBlsD6Kixk5D2UdtCqdE13re/P0lzJquoR0faxOGS1k1qc3iQsuyTYGn4VQg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665578540; a=rsa-sha256; cv=none; b=TBC+01O1ULx3D+Ue8wGbVupL/5Nuit4YFKYb+/IOPwVOUj1BPb0r7jcjEsjeLN+5iMVXmz IwcdjPlVTY/dPh2Xoi1FMrxFzswkvUOqhgGAOpiau5b0JdgsPp2lhoBCpJX42xPklLUSOF jtCiLe8aq3+rEEEp0icTxzpGrQpLZ7HwJNItmxIkfb3nMTtIhEU/Co5o/qwvhqXJNf8/fM 2ib0/pb97Mr2LIegXnb+WUiiGJZDpHOW+neD940DbjTnnP2DOWSOptP09Zh5shZHjbd/GC 6Bp2pWV5X3XKpXu1n9v/igcc37WGRSME2OOhijE2v4xfp9LUoPLOL+iG+aeVOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=RnZBbBJj; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.20 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=RnZBbBJj; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 477E0857F X-Spam-Score: 0.20 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6Iel1HPVlZd+ --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2022-10-12 20:38, Taiju HIGASHI wrote: > Andrew Tropin writes: > >> On 2022-10-11 12:54, Taiju HIGASHI wrote: >> >>> Hi Andrew, >>> >>> Thank you for your review! >>> >>>>> +(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. >>> >>> OK. I'll rewrite it to below. >>> >>> --8<---------------cut here---------------start------------->8--- >>> (define (string-list? value) >>> (and (list? value) (every string? value))) >>> --8<---------------cut here---------------end--------------->8--- >>> >>>>> + >>>>> +(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?). >> >> Oh, I missed the map over the list elements and slightly missread the >> code. I thought (according to my incorrect perception of >> implementation) extra-config have to be either sxml or string, that's is >> why I said that it will fail earlier because plan string value won't >> satisfy list predicate attached to extra-config field, but in a fact >> extra-config is always a list, but can be a list of sxml's and strings >> mixed together. >> >> Thus, some of my comments are invalid. Sorry for the confusion. I'll >> rephrase and elaborate in the later message. > > I was worried that I was the only one who did not understand the code I > wrote, but I've relieved to hear that it was a misunderstanding :) > > Is it OK to have multiple data types (XML string and SXML list) in a > list? > I think it's not a great practice, I'll describe an alternative approach in the other message. >>> We can specify invalid value such as (list "foo" '(foo bar) 123). >>> >>>> Also, making multi-type fields is debatable, but isn't great IMO. >>> >>> I see. If we had to choose one or the other, I would prefer the >>> string-type field. >>> >>>> If serialization would support G-exps, we could write >>>> >>>> (list #~"RAW_XML_HERE") >>>> >>>> or even something like this: >>>> >>>> (list #~(READ-THE-WHOLE-FILE #$(local-file "our-old.xml"))) >>> >>> Does it mean that the specification does not allow it now? Or does it >>> mean that it is not possible with my implementation? >>> >> >> It's not possible with the current implementation. > > I'll try to modify it so that it can support G-exps. > >>>>> + ((? string? xml) (xml->sxml xml)) + (else + (raise >>>>> (formatted-message + (G_ "'extra-config' type must be xml string or >>>>> sxml list, 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. >>> >>> Sure, It is more appropriate that the field type is to >>> font-directories-list field name is to additional-font-directories. >>> >> >> As Liliana mentioned in the other message, it's better not to set >> anything implicitly. It's better to keep the name, but change the >> implementation and remove implicitly and unconditionally added >> directory. > > OK. I'll modify the default value to an empty list and include > ~/.guix-home/profile/share/fonts in the sample code in the > documentation. > The default value is good, but the code, which always adds ~/.guix-home/profile/share/fonts to fontdirs is not. =2D-8<---------------cut here---------------start------------->8--- + (if (member guix-home-font-dir value) + value + (append (list guix-home-font-dir) value)) =2D-8<---------------cut here---------------end--------------->8--- >>>>> + "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-configur= ation-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")))) >>> >>> Nice. >>> >>> Thanks, >>> -- >>> Taiju > > Thanks, > -- > Taiju =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGtewACgkQIgjSCVjB 3rBjhw/+PHqGEzKvXRkm8osF/xuxxOIclJUU2bi0N85/+9/KquL0QOlCf2QcxIS1 DHBrLEe6LCEgpqeQSVrsAxsMRs8wWDglPinafFtl3fbqqHdzVcOTs/xj5iZiYcew thDUoUtXneAlfrKj7QONyd6aBaluhcG1fgRYKq9OXLQxwPD188vDjfIlQ6rflthk A+umhNcrqX3QM34/shK8OzDwb7p+T33z/xy/dlzDlbwXGkpiFRE2/je1i5I8kP8q oyXD33oBDuql4Z688btUqeWVfGFo17LUILFc237TDSaq70OsD3itjGbsRpykR/cw F2OQNfjOYPx21T8p4rhlNUy6H7guy4s+vaqC1Fc+3lB0QMMinL5yTncC58BnDIiy yKzBYDs+MssqK98cNHA2QurKtj+d0afhB8Eiqq7iDZ3iKQP7Ea8wkGGglGbev0hQ U872q92rLjKsQxQrFHKQPpGLgGPJx183Bw+P4ARXgev3yj30+68R+HejOkOR9bAF U2jKOO24oIMeALK8ASTzMDXLtxdAjyt2K5hwsc2QnoOarsUqHcVOkxjqyjGgPR9M MV0VOg/DHQR3rn/Lcb1XOWjTwqm6GZnVLzZrVg/vuB611cGdHq/h+e+eiqiYa9xo VUX9D9bjsrlWC+f/WQMMiodvdzLlLWmeyGP2t1CP4t4tsAakcw0= =iXYB -----END PGP SIGNATURE----- --=-=-=--