From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-patches-bounces+larch=yhetil.org@gnu.org>
Received: from mp12.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 kHxXHoDSNWNUjgAAbAwnHQ
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Thu, 29 Sep 2022 19:14:40 +0200
Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp12.migadu.com with LMTPS
	id cFQnHoDSNWOGVwAAauVa8A
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Thu, 29 Sep 2022 19:14:40 +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 1EDA42D62F
	for <larch@yhetil.org>; Thu, 29 Sep 2022 19:14:40 +0200 (CEST)
Received: from localhost ([::1]:46898 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	id 1odx7P-0007M7-6D
	for larch@yhetil.org; Thu, 29 Sep 2022 13:14:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42822)
 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 1oduxG-0005cW-7v
 for guix-patches@gnu.org; Thu, 29 Sep 2022 10:56:03 -0400
Received: from debbugs.gnu.org ([209.51.188.43]:40175)
 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 1oduxG-0001GC-0E
 for guix-patches@gnu.org; Thu, 29 Sep 2022 10:56:02 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oduxF-0007nd-SV
 for guix-patches@gnu.org; Thu, 29 Sep 2022 10:56:01 -0400
X-Loop: help-debbugs@gnu.org
Subject: [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
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: Thu, 29 Sep 2022 14:56:01 +0000
Resent-Message-ID: <handler.57963.B57963.166446333029938@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: ludo@gnu.org, liliana.prikler@gmail.com, andrew@trop.in
Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166446333029938
 (code B ref 57963); Thu, 29 Sep 2022 14:56:01 +0000
Received: (at 57963) by debbugs.gnu.org; 29 Sep 2022 14:55:30 +0000
Received: from localhost ([127.0.0.1]:39253 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1oduwj-0007mo-Qe
 for submit@debbugs.gnu.org; Thu, 29 Sep 2022 10:55:30 -0400
Received: from mail-pg1-f172.google.com ([209.85.215.172]:37855)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <higashi@taiju.info>) id 1oduwf-0007mT-RI
 for 57963@debbugs.gnu.org; Thu, 29 Sep 2022 10:55:29 -0400
Received: by mail-pg1-f172.google.com with SMTP id bh13so1674771pgb.4
 for <57963@debbugs.gnu.org>; Thu, 29 Sep 2022 07:55:25 -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:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date; bh=et/svd1EUd6T/YAczapjYPudZ5nYFHVn2Ghlsn2aZvU=;
 b=wXjMCAb7CYZTP2e+x+5WOQV+ynDS8VyZKo3fEbSzpPYbecef2+/V2lA91+1XIjFRje
 9zttItZ8NbsCaatzvIFg3uXpucqMcuHJ3+VHaeGtG8yPJIhsUcpXnr6/JtPv9G+VUWhm
 1Yg8kpRudeC0wSbRFYNdnJfbU7lzxhVniS+CnM9GiaCjoLW6HiSoZix4uN2Ve8iSfiSr
 R5RJaJ5ywmGl3qALuZsToZLpwsGcctc97PL9anbFoUhvFzjptO5uvkjdPuoyzTGMWyn+
 qykXbx8hJi3geGzikoC0ZqpLht6YuOlpCq69fpjhjbUqLOLxIeYeXrQnOj833DXzLYw8
 VJoQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date;
 bh=et/svd1EUd6T/YAczapjYPudZ5nYFHVn2Ghlsn2aZvU=;
 b=Mh0URMfX9jp4DcMcxxe+53kgcQH0NR6wJhL2avqBtu6/9MY2mT/tl1stacQh3030sV
 dVHToB2zMvU/fMHEPwFFZVDTvjXSRTkSzpYhHaoFn9EIcml3l1CyTFjyuFK0oeQuVvzn
 Pk6pberSngpHYCl5NtfvF8jI7IDixq7uvQ19C1TMlzmJqW465LwnTgHQ4avqYj67HzEa
 Iq9j1qmhLAoL05zOXUiQyP3kLIbXc3nxpubhbHcosMgbYQ35ajCwvJ6+QJOSdjVfCFLe
 u1V3Ad8NgI3Sy5yzpPIaWR2twouXofnoPBrTqfcSdJdh+V/I8CA9veFH9meePbxnpKWA
 /gKQ==
X-Gm-Message-State: ACrzQf3bUbomhvR4vh6hLQGltZ48mzaTiyd7N/Yl62eJUforvJ6tUBQB
 JMt/LjkyXOk1OTDRa1PJ9oj7Xg==
X-Google-Smtp-Source: AMsMyM5PS35gPPo9Q+6tsEILH2kmhgSAyE5qtq1OmqxLlCQdVHADB4hKtDQh+5mJybLk89lXxF/9Hg==
X-Received: by 2002:a05:6a00:1c98:b0:540:d461:f9d8 with SMTP id
 y24-20020a056a001c9800b00540d461f9d8mr4028322pfw.29.1664463319966; 
 Thu, 29 Sep 2022 07:55:19 -0700 (PDT)
Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925])
 by smtp.gmail.com with ESMTPSA id
 h8-20020a170902680800b0017a018221e2sm3881078plk.70.2022.09.29.07.55.18
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 29 Sep 2022 07:55:19 -0700 (PDT)
From: Taiju HIGASHI <higashi@taiju.info>
References: <20220929143633.28844-1-higashi@taiju.info>
 <20220929143633.28844-2-higashi@taiju.info>
Date: Thu, 29 Sep 2022 23:55:16 +0900
In-Reply-To: <20220929143633.28844-2-higashi@taiju.info> (Taiju HIGASHI's
 message of "Thu, 29 Sep 2022 23:36:33 +0900")
Message-ID: <87y1u2mdrf.fsf@taiju.info>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
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+larch=yhetil.org@gnu.org
Sender: "Guix-patches" <guix-patches-bounces+larch=yhetil.org@gnu.org>
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=1664471680;
	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:
	 content-transfer-encoding:content-transfer-encoding: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=et/svd1EUd6T/YAczapjYPudZ5nYFHVn2Ghlsn2aZvU=;
	b=XF2dk4giiWff1RnLEz1Ch5HbRrzw+pxu8dmSt7lm8PoILbfYur1EetlvjIeQFUl9w+PVIN
	YIcHj4RUZk2e2DghsV6AYXvSO9QhEWaj3wEVfaSdFEcdEPpq7eOZU2DKpRY7u2D47bT0Mv
	jJjxAk57TuV5yQCwhlVyDIYEcPd8H3s3AAkrE0XkfC15yiUFHZ77ZAlIo/+9tR/trkDDp9
	PiFXWUEALt3VneGO3wH20lSZONqW7ZxvrNXoa33Wa+Tbp6fGMwdmtzRKp3s1UXaBE2boYD
	EsiyD1E0sMlwZqQCnUkRlgyLdl8rCAvj3cPvRG70kA8MxBA+aGOaPn7MwGER5Q==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664471680; a=rsa-sha256; cv=none;
	b=MBJKmco0K8kUO1yd0bAjKo4pHuD6NoUGN9tzBqBcaH/B52UsKHWZc1Urjsp4Y6FO7m3jaL
	NpU7czyJCOgmRNRr5wwbEupAgrNn45My7kNhaUBDD+eKOFhjV0zabcX5yA9SJIhVPPry3C
	YOW6Kjc0Eb4lT7XdFzdoipGGyw6W1bCU+HbK8QNYBht1vBgB+JTDWdYIosKwP8ejJrF3J8
	WNiSwNcUshBVvjEk5hUEebJKVPqPoYjabAPCbxwLO1xWVBl+l/tSwLNkxIpeOLvJMcGHiI
	RwVXLmTdnpPJV6PKEcX2eEPTAW1fozUBFb9JOse+LYfHpQV0vUG2OwlM5KtWZA==
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=wXjMCAb7;
	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: 4.16
Authentication-Results: aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=wXjMCAb7;
	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: 1EDA42D62F
X-Spam-Score: 4.16
X-Migadu-Scanner: scn1.migadu.com
X-TUID: r8+9bqpc5K6I

The new way to extend the service is as follows.

--8<---------------cut here---------------start------------->8---
(home-environment
 (packages (list font-google-noto))
 (services
  (append
      (list
       (service home-bash-service-type))
      (modify-services %home-base-services
        (home-fontconfig-service-type
         config =3D> (home-fontconfig-configuration
                    (font-directories
                     (list "~/fonts"))
                    (preferred-default-font
                     (default-font
                       (serif "Noto Serif CJK JP")
                       (sans-serif "Noto Sans CJK JP")))
                    (extra-config
                     `((match (@ (target font))
                         (edit (@ (mode assign)
                                  (name antialias))
                               (bool true)))))))))))
--8<---------------cut here---------------end--------------->8---


Taiju HIGASHI <higashi@taiju.info> writes:

> * gnu/home/services/fontutils.scm: Support user's fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++---
>  1 file changed, 80 insertions(+), 6 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutil=
s.scm
> index 6062eaed6a..32127740f6 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 =A9 2021 Andrew Tropin <andrew@trop.in>
>  ;;; Copyright =A9 2021 Xinglu Chen <public@yoctocell.xyz>
> +;;; Copyright =A9 2022 Taiju HIGASHI <higashi@taiju.info>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -20,9 +21,16 @@
>  (define-module (gnu home services fontutils)
>    #:use-module (gnu home services)
>    #:use-module (gnu packages fontutils)
> +  #:use-module (gnu services configuration)
>    #:use-module (guix gexp)
> +  #:use-module (guix records)
> +  #:use-module (srfi srfi-1)
> +  #:use-module (sxml simple)
> +  #:use-module (ice-9 match)
>
> -  #:export (home-fontconfig-service-type))
> +  #:export (home-fontconfig-service-type
> +            home-fontconfig-configuration
> +            default-font))
>
>  ;;; Commentary:
>  ;;;
> @@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (default-font-sanitizer type)
> +  (lambda (value)
> +    (if (null? value)
> +        value
> +        `(alias
> +          (family ,type)
> +          (prefer
> +           (family ,value))))))
> +
> +(define-record-type* <default-font> default-font
> +  make-default-font
> +  default-font?
> +  (serif default-font-serif
> +         (default '())
> +         (sanitize (default-font-sanitizer 'serif)))
> +  (sans-serif defalut-font-sans-serif
> +              (default '())
> +              (sanitize (default-font-sanitizer 'sans-serif)))
> +  (monospace default-font-monospace
> +             (default '())
> +             (sanitize (default-font-sanitizer 'monospace))))
> +
> +(define (sxml->xmlstring sxml)
> +  (if (null? sxml)
> +      ""
> +      (call-with-output-string
> +        (lambda (port)
> +          (sxml->xml sxml port)))))
> +
> +(define font-directories? list?)
> +
> +(define (serialize-font-directories field-name value)
> +  (sxml->xmlstring
> +   (append
> +       '((dir "~/.guix-home/profile/share/fonts"))
> +       (map
> +        (lambda (path)
> +          `(dir ,path))
> +        value))))
> +
> +(define extra-config-list? list?)
> +
> +(define (serialize-extra-config-list field-name value)
> +  (sxml->xmlstring
> +   (map (match-lambda
> +          ((? pair? sxml) sxml)
> +          ((? string? xml) (xml->sxml xml))
> +          (_ (error "extra-config value must be xml string or sxml list.=
")))
> +        value)))
> +
> +(define (serialize-default-font field-name value)
> +  (match value
> +    (($ <default-font> serif sans-serif monospace)
> +     (sxml->xmlstring (list serif sans-serif monospace)))))
> +
> +(define-configuration home-fontconfig-configuration
> +  (font-directories
> +   (font-directories '())
> +   "The directory list that provides fonts.")
> +  (preferred-default-font
> +   (default-font (default-font))
> +   "The preffered default fonts for serif, sans-serif, and monospace.")
> +  (extra-config
> +   (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"
>         "<?xml version=3D'1.0'?>
>  <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> -<fontconfig>
> -  <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +<fontconfig>"
> +       (serialize-configuration user-config home-fontconfig-configuratio=
n-fields)
> +       "</fontconfig>\n"))))
>
>  (define (regenerate-font-cache-gexp _)
>    `(("profile/share/fonts"
> @@ -59,7 +133,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."=
)))

Thanks,
--=20
Taiju