From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 6O7sIn1mRmMJPAAAbAwnHQ (envelope-from ) for ; Wed, 12 Oct 2022 09:02:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aN4UIn1mRmM1GQAAG6o9tA (envelope-from ) for ; Wed, 12 Oct 2022 09:02:21 +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 2511519451 for ; Wed, 12 Oct 2022 09:02:21 +0200 (CEST) Received: from localhost ([::1]:47048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiVky-00049f-4y for larch@yhetil.org; Wed, 12 Oct 2022 03:02:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiVTI-0003Mk-62 for guix-patches@gnu.org; Wed, 12 Oct 2022 02:44:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiVTH-0004Qj-SP for guix-patches@gnu.org; Wed, 12 Oct 2022 02:44:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oiVTG-0005O6-NQ for guix-patches@gnu.org; Wed, 12 Oct 2022 02:44:02 -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 06:44:02 +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.166555704120693 (code B ref 57963); Wed, 12 Oct 2022 06:44:02 +0000 Received: (at 57963) by debbugs.gnu.org; 12 Oct 2022 06:44:01 +0000 Received: from localhost ([127.0.0.1]:55460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiVTF-0005NW-4j for submit@debbugs.gnu.org; Wed, 12 Oct 2022 02:44:01 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:32903) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiVTD-0005NG-6A for 57963@debbugs.gnu.org; Wed, 12 Oct 2022 02:43:59 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 233EC2000C; Wed, 12 Oct 2022 06:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1665557033; 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=cmaMxgd81WZYpB160gtAQ1zRhl47DwmtxsuskHgCpwY=; b=agA7ZkVMe7jZf2jGTez/4DJjtNpRYhMA3QTioShQ3g+68ce0fHtC6yYkPddWHE+kfa5VaH wfBxr1jG/NBnlxjiYkL/PzghZ7prPCvS601dJZ6yIcMrszWQKY460xkFZ8S6wM7soL9ToY +it8OZN3AmSdUOkUxl5mBnP36C8HctXmOuMlzROV8yw0dxx4lIdDZ53v7iPVeKZuzeUFdt HtCP5N93uHsJQxSqIuBJNLhhF0eJ0VaN+Bc01g+2iAAXb1I2Dd0FsfNBhl+BJTjILHjBpG ppBfm9moExEgVC5Zp82Z/FNLG3ZQCQcUYTeUdgeDSryX8BOM2OyZjFo+azfhAg== From: Andrew Tropin In-Reply-To: <87edvfkob8.fsf@taiju.info> References: <20221002131535.9972-1-higashi@taiju.info> <20221002131535.9972-2-higashi@taiju.info> <87zge4chb5.fsf@trop.in> <87edvfkob8.fsf@taiju.info> Date: Wed, 12 Oct 2022 10:43:34 +0400 Message-ID: <87wn95mtih.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=1665558141; 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=cmaMxgd81WZYpB160gtAQ1zRhl47DwmtxsuskHgCpwY=; b=mxuQhqoUpG2HIEqIsbKdr5cZHnNJlmQNwHHl9E44ByboTnCakaDuKv+H9L8p9S14NXWi2m YW+NEzKqDbNtcd416K4uqf1iiTlG8ICi8T8A/tG3WQoy256d39/A2PufrrV9dYiMAVF2vn Mgc9YIFCVyFIfXI73zHyTYCv/7ygZj7jL+8wguElgp65xieF9mb1b7Iu/eO9Ij1qNokVJV zybt/7W4c/DYfRoFjFo21LPLJwDnZ7Y9yXdsufKSMHytymPB9dS67O1mgzEib+EY78IF1s dkcEtMwJ/H1VLeB1unhKDkdX07oPBe7+EvioWa2WQidQN20KwIninC2fVy9PqA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665558141; a=rsa-sha256; cv=none; b=sCKwoK0Rld+SMvQIH84k9XHGon+88HI+bve1ogRPqwgFaYPoGCOD7wN3xbIlhFicpp/mfu YzZSPPOOPHD3s+TjViK/Wq8eOrcKIT3Nqbz/dDtcUSN6/41two3fp4qzvIJk7KntgANOea Mp5N0ToDdtSfHOuuBKpYQpEiK2FqDpZB8LJDAu8Rgv+j8CdtJYFoEXwR60Q7C2ApsgqBMf rkrSMvbfRatpX8KRmlxedtj97gg3gn6wqlswkRNbwOayKZ3GDsehQJs6Hb5AChKDvgU4nn PuFDTVOocsGvUPM5cyMPHoYxO8xF4YT4/17tLz7pAWaGAOXpw2zx3UEq9Kg6rg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=agA7ZkVM; 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.60 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=agA7ZkVM; 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: 2511519451 X-Spam-Score: 0.60 X-Migadu-Scanner: scn0.migadu.com X-TUID: y2HDerk6FSVv --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. > > 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. >>> + ((? 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. >>> + "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-configurat= ion-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 =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGYhYACgkQIgjSCVjB 3rAPzw/+L/OhOp1INFRdX4m/Qp+1BbEo5hyEKHOkDk4USdpe9Olky2izvkTU8ujH aeZU2m/+TsbtleJaIENasmzpIVds8TrUdItwaECOxjhmyG+PbvBZyhXiBvmzKp3p AdxvbYSU3AVlVGKETs5suyNCail9JuX9JkaTAJFWJPm6Xc9FqZwXUtvdGC9FW/5p px+hLw0upj2h0ZmSuDU7q2LMQFk7Iehiwf4VkTNxedacx6a6FkYF9upk+j1k5o+U 2XntQxcEiCH4bHfrSte8WfBKuCQid2cHj2mYedGZ1NiSaTr59CNUb3ZL+/ABRxYc oFiw2IIq7LbOpmJym33PITsVm1OMChLZQfaMldBMXxrndrxl7vHw333DDhxMjWyz dZunfZsRuwqnmSG8oVmljPd243Cc0SVvDY6IDiGPIbFiwoYO5mYUAth1+mES8CS5 YJKgzgjXsTI97nSlZ4zPagnhD1wrOZzzbHqkhaPPzVV+lQue8yWiIxZDhPZ7WMDb MnV4tVoVt5U1+Nz9pGmEmjFq+AX4IoHDZilvdLA5Vtgd3xklduyqca6LRRPrNLKn DdtX9DDPcVxNaVeReJ0D7vpH8ZF47PZH7gUPpOsGv9V1746SsMGas5kp2PNTB3ST KOfwDGBp8+qeHFH+gemFP/ht8GI1KAgNpQ07631r+4w1w5aFvdI= =mzvN -----END PGP SIGNATURE----- --=-=-=--