From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 SDYXJH6nRmPECQAAbAwnHQ (envelope-from ) for ; Wed, 12 Oct 2022 13:39:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id WM0uJH6nRmOyPQAA9RJhRA (envelope-from ) for ; Wed, 12 Oct 2022 13:39:42 +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 43879616C for ; Wed, 12 Oct 2022 13:39:42 +0200 (CEST) Received: from localhost ([::1]:51060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oia5N-0002Qs-6H for larch@yhetil.org; Wed, 12 Oct 2022 07:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oia4m-0002Pb-KY for guix-patches@gnu.org; Wed, 12 Oct 2022 07:39:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oia4k-0000fc-Ip for guix-patches@gnu.org; Wed, 12 Oct 2022 07:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oia4k-0002od-Ao for guix-patches@gnu.org; Wed, 12 Oct 2022 07:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration. Resent-From: Taiju HIGASHI Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 12 Oct 2022 11:39: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: Andrew Tropin Cc: ludo@gnu.org, 57963@debbugs.gnu.org, liliana.prikler@gmail.com Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166557470410781 (code B ref 57963); Wed, 12 Oct 2022 11:39:02 +0000 Received: (at 57963) by debbugs.gnu.org; 12 Oct 2022 11:38:24 +0000 Received: from localhost ([127.0.0.1]:55942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oia47-0002no-IB for submit@debbugs.gnu.org; Wed, 12 Oct 2022 07:38:23 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:39853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oia45-0002na-4b for 57963@debbugs.gnu.org; Wed, 12 Oct 2022 07:38:21 -0400 Received: by mail-pg1-f182.google.com with SMTP id b5so15312105pgb.6 for <57963@debbugs.gnu.org>; Wed, 12 Oct 2022 04:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taiju-info.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qCThdVYoiHOdElzmiHBfKyKfVtAT1DHfWAopE7gbyFs=; b=tp3WsiMPXP2Tp2EZp2aGDKLTFku02oDcVJnruQ+NHQTzoRroXxY3PxPGX79YwOjsPL kV1AObvT/FXLPSzMw+xr2rPzY8L6SrZJ+qfajCbxPmCSaAM91PJfzrtIUqTgmYacOS6Q 05XtrK/qB8MYlI8Ix40YGb0FfB1AM4knqtW19pH/GXT+1XAxJJ8TaeDVuRI6dYGMAhzi eD8UIlLMEDPQ8PMMEIqvypbLzQfpZrisv8BfnDnHhsNTnCw/48MbMd/mfdObqFjhXMlg DluNha9Go99pubQ+7xyU/7uxd3em6R1w7DiFm7TgEl7b1hS75r+NssBHH+Sl4OyKo3L4 w7Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qCThdVYoiHOdElzmiHBfKyKfVtAT1DHfWAopE7gbyFs=; b=dQseQpQNufGSN+LPt3lUuRNkA5DhZ88rgXGExYOcSxLr09xNf1UCyvapwZrk1HsPzn 6wLExwfRlM6/iD7nMirlKaNVpUMr7Tl2JLI5/ZYhxF9Nh4MfNmccNNx8f6UmJSrfKfZo 7axpIfoNPhQpFeHCi7M9FtXETRlKWs0dbkTd0lq83tgyrrge6xM6AD7wh/5xG5NEAVdI U4TmSY8LiLZOKdYG+7+vxsNOSZTTlRN3QhUEEqpueOl7Uy1TQZryJH72ljP5z4Mh8ikw Z2Ak+F7mGtRf5eiWcvj6U/toMRB/yo9Xq6Ndk+Rd+UKBY7aEwyoG0T+aKO2MfG01bmUe AYew== X-Gm-Message-State: ACrzQf12u5yjC8k6wyluI/0jQyZSzeVb7j2/pjxta2fDVr3y3YkK/pj0 mGCv0RdMUfZdHpsCszEqNv3+sw== X-Google-Smtp-Source: AMsMyM5z4kal28Gkf/2y4kH74ZseZjJja7Qz+g7kHNYXRfTQ442sY7VoJOkVwmeb3mfbdY5POkKHVw== X-Received: by 2002:a05:6a00:854:b0:563:a22f:50d4 with SMTP id q20-20020a056a00085400b00563a22f50d4mr10187018pfk.31.1665574695228; Wed, 12 Oct 2022 04:38:15 -0700 (PDT) Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id h14-20020a170902f54e00b00179f370dbfasm10569293plf.26.2022.10.12.04.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 04:38:14 -0700 (PDT) From: Taiju HIGASHI 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> Date: Wed, 12 Oct 2022 20:38:11 +0900 In-Reply-To: <87wn95mtih.fsf@trop.in> (Andrew Tropin's message of "Wed, 12 Oct 2022 10:43:34 +0400") Message-ID: <87k055i864.fsf@taiju.info> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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=1665574782; 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=qCThdVYoiHOdElzmiHBfKyKfVtAT1DHfWAopE7gbyFs=; b=pxjLAx3mj3mN6SN7jwrrLiGRixGsmW7/To4HERlw0QLFq++yltJ1Si68l1/np7IJhbjUVH +SFNtQRaihVKxyiI3iRLAM7venQyhv3PhHZ8IoiV3xX9KKWbrJL9Fl5J9EeTaSA0YPOgro iBufHjpfjr/ylE6oK6gn1nOZ44MtvdULZtuES86WpU4/aXqH99z06wg6rY2zit0EIAiZ3L 3Gr9oV6Q0diwqlgrCNhli51ePXBmlnk1tEfWI6bXC7qnkG/HfOqrcysDejDNde9JzFQnt5 78eFPAs5LcTLs+7EsURnbE4rUfeI6ONR1zsFUkRm4SF3b3g4RCzMONxy1DlGVw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665574782; a=rsa-sha256; cv=none; b=nVqofmZ63USZ4WEy0CWc5iGiN6VUilkEvFmgSWw33Quxrhnob1LZLMO7KNVT0wtJl1ypTY AtlbLHix1jV73PgcY15O/mhgkvXoBMd23DC/44SuAi87oSxotsAc9mFD6saamiRc3a55W0 4EqzauKIpAGgJrIc8Fc9/ebWHJDOpICqu41T2AdnONYiY5ibP7fhq5T6EuvHpeOxRLflk2 AclWWMZdPHTNp4kYh6gVBZB9+4B0zCWhSlaIAtD5vJ9rk/nClglW0lBYihDZgJLa7uqBEH /419FE58X/VAPOvngtO0SC0lZz0OAXDctQC7S8THE72AP36Hb5R0VqU+8cz2Mw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=tp3WsiMP; 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: 2.60 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=tp3WsiMP; 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: 43879616C X-Spam-Score: 2.60 X-Migadu-Scanner: scn1.migadu.com X-TUID: UZw66Hi96xA4 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? >> 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 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-configuration-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