From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 0MsZJ9jnNGMw7QAAbAwnHQ (envelope-from ) for ; Thu, 29 Sep 2022 02:33:28 +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 oNQEJ9jnNGOAvgAAauVa8A (envelope-from ) for ; Thu, 29 Sep 2022 02:33:28 +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 650312AC57 for ; Thu, 29 Sep 2022 02:33:28 +0200 (CEST) Received: from localhost ([::1]:38486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odhUV-0007wK-IU for larch@yhetil.org; Wed, 28 Sep 2022 20:33:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odhT8-0006Tk-CR for guix-patches@gnu.org; Wed, 28 Sep 2022 20:32:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odhT8-0002Xs-3z for guix-patches@gnu.org; Wed, 28 Sep 2022 20:32:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odhT7-0001dt-UE for guix-patches@gnu.org; Wed, 28 Sep 2022 20:32:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig. Resent-From: Taiju HIGASHI Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Sep 2022 00:32: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: Liliana Marie Prikler Cc: ludo@gnu.org, 57963@debbugs.gnu.org, andrew@trop.in Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.16644114826266 (code B ref 57963); Thu, 29 Sep 2022 00:32:01 +0000 Received: (at 57963) by debbugs.gnu.org; 29 Sep 2022 00:31:22 +0000 Received: from localhost ([127.0.0.1]:35272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odhST-0001cz-Ax for submit@debbugs.gnu.org; Wed, 28 Sep 2022 20:31:21 -0400 Received: from mail-pl1-f180.google.com ([209.85.214.180]:45917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odhSR-0001cg-5w for 57963@debbugs.gnu.org; Wed, 28 Sep 2022 20:31:19 -0400 Received: by mail-pl1-f180.google.com with SMTP id w20so13057092ply.12 for <57963@debbugs.gnu.org>; Wed, 28 Sep 2022 17:31:19 -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=1qiSRL14IGgDIO3d7G+gdNNoZBFryycjEeoedNrmwS0=; b=pDpwtZk/wNimSwWYyelybYxEGDVeopf5EdruotqI8jl9+Y6N7l0mswRywo22es8MQa A2AuqvF7J2SCx880NyiW5NrZubnm6GI1R86Vwk728lmn0nOYfAdjCAuDK2Pwhsc5auGG HBJLPXNkJhRmXiorbu6oNRU7GQdlU5mpQy5+n2D1HMqXITgO7M4KIwuFbFmhYB3ssh4i 8H9jQUmXOQ6BHjhgX186ffHc+v6piWn8AOU1id5gJt5BEtBuQ5e1JFFDVc6e5I0UpM/a 9CNodpyitQvMwSEvbigX1t2X6YiBgDuUu2A43/VuR91H+IMIvTBub9I1R4w9izgOVS/4 q4Sw== 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=1qiSRL14IGgDIO3d7G+gdNNoZBFryycjEeoedNrmwS0=; b=VuClz1dq61Rr9oLgRvuP4m1o6k7ENSjoPh3hDEIw779kJwTJxF4Zt79K4oaiz15m1S u1HRK4hN3pBARQGcG1hTWtrClCj5ZzVbrYJb/3sGbQsUqIDZfEGnDm36UE/PlM6jJWg+ 32DWzRcAybUMtNI1k9ft9rnuPP0GYq91fdQYFms78MHw1fXWPlIGu+iU+YsVs/0k7BXN Fr/STghBSPbTHPI40xEU9kJbPP0DktfvykWxaXrYGtga4svyH6caeovKfj+7jN3tfCL/ 6vDwSIE/5LUYOhW0S9/Xw3DjdJEB7EtVzhx8bVoBlRotI6V6Ult7L9+9YEZYSUdetfbN X7cg== X-Gm-Message-State: ACrzQf2ITAfxDjvxVLd+AA0A7u1yefptQErGBug6BvlBu04+w5BBOrZK UWuOARWb+cM8S/usSiThKrqS+7nvBecxF42R X-Google-Smtp-Source: AMsMyM7uAtEPEPkQBNOZYw7iVlbR4cJbSm7Yz0dgTIEcxBPOMvEdmZ1Htd7DlO3p2G4uaHF/gwC7fQ== X-Received: by 2002:a17:903:442:b0:17a:ac:1b75 with SMTP id iw2-20020a170903044200b0017a00ac1b75mr632173plb.5.1664411473025; Wed, 28 Sep 2022 17:31:13 -0700 (PDT) Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id y16-20020aa78f30000000b00540a3252191sm4698288pfr.28.2022.09.28.17.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:31:12 -0700 (PDT) From: Taiju HIGASHI References: <20220927095525.26431-1-higashi@taiju.info> <2add7a8c83272c5bcb9aac38e63161a48f321cda.camel@gmail.com> Date: Thu, 29 Sep 2022 09:31:09 +0900 In-Reply-To: <2add7a8c83272c5bcb9aac38e63161a48f321cda.camel@gmail.com> (Liliana Marie Prikler's message of "Wed, 28 Sep 2022 21:11:30 +0200") Message-ID: <87tu4rowc2.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: 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=1664411608; 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=1qiSRL14IGgDIO3d7G+gdNNoZBFryycjEeoedNrmwS0=; b=RQcdlkOywsPyxGU/BmK2OLzD04igTydt7MJ2FZiic536bxApRR6n/6mjoMN3SDxLSfsWLj 7YCLzcWGAVayJ1w25qsfiW8r8tJ0rk7qyfC/T5jJTEGmexwvRk5efkqdq052A6pK9/Rz8P MtBLYsOCIKr/8My6rv+kmMIp6toLk9v7fZACc0G/8Z1BPOqiR1IojRQaabHz+L+ZoX3qLJ w3hc2UjAtYaTfNuuKeqjlbT0sCYKjJAMpe5YFDUQPvYNF/n49uYOR4ikq3MWNnOatt3Ro5 ZKrVClrxlK6x22ADXKqqwkgEdnFoZddtPm/6Tyjf8JRkjKZ7RGT8J+9TOvEGcQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664411608; a=rsa-sha256; cv=none; b=k+22wX+i/O/XwPgTn3+4S1o8aJdXY6so5WGb5WA9sArwpRWC3tHRJSkH0w4vXJEOB+EeXj gQxJVYdlDTyZDg/bGO5D3aReJWKzvF6ntjFFyydIy9iCPvdk5WvlI4E0Uu+7bvogelJrjZ eNikw7q4gAlRoBkb3O6Vo4NBtZh63LXjZ/ua70P/EYWyvH7h+6pvj2yw4sHUFK/lrNtNsw WiSq7d2mwRCy4gQyYQ45yRRoqGIOCFQrleN/d7hq1nZCZQFTC/pFKWRD8xTvqFE/cze6Lp EJIjYs6mSlUB1HNXe7lBOPzeFlAMOZMl+QVoyU3GZsGXidS56IDRqoolsVWCjQ== 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="pDpwtZk/"; 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.15 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b="pDpwtZk/"; 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: 650312AC57 X-Spam-Score: 4.15 X-Migadu-Scanner: scn1.migadu.com X-TUID: qIifU1j+/tL2 Liliana Marie Prikler writes: > Am Dienstag, dem 27.09.2022 um 18:55 +0900 schrieb Taiju HIGASHI: >> * gnu/home/services/fontutils.scm (add-fontconfig-config-file): >> Support user's >> fontconfig. >> --- >> =A0gnu/home/services/fontutils.scm | 103 >> ++++++++++++++++++++++++++++++-- >> =A01 file changed, 97 insertions(+), 6 deletions(-) >> >> diff --git a/gnu/home/services/fontutils.scm >> b/gnu/home/services/fontutils.scm >> index 6062eaed6a..b02f43a4fc 100644 >> --- a/gnu/home/services/fontutils.scm >> +++ b/gnu/home/services/fontutils.scm >> @@ -1,6 +1,7 @@ >> =A0;;; GNU Guix --- Functional package management for GNU >> =A0;;; Copyright =A9 2021 Andrew Tropin >> =A0;;; Copyright =A9 2021 Xinglu Chen >> +;;; Copyright =A9 2022 Taiju HIGASHI >> =A0;;; >> =A0;;; This file is part of GNU Guix. >> =A0;;; >> @@ -20,9 +21,16 @@ >> =A0(define-module (gnu home services fontutils) >> =A0=A0 #:use-module (gnu home services) >> =A0=A0 #:use-module (gnu packages fontutils) >> +=A0 #:use-module (gnu services configuration) >> =A0=A0 #:use-module (guix gexp) >> +=A0 #:use-module (guix records) >> +=A0 #:use-module (srfi srfi-1) >> +=A0 #:use-module (sxml simple) >> +=A0 #:use-module (ice-9 match) >> >> -=A0 #:export (home-fontconfig-service-type)) >> +=A0 #:export (home-fontconfig-service-type >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 home-fontconfig-configuration >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 default-font)) >> >> =A0;;; Commentary: >> =A0;;; >> @@ -33,15 +41,96 @@ (define-module (gnu home services fontutils) >> =A0;;; >> =A0;;; Code: >> >> -(define (add-fontconfig-config-file he-symlink-path) >> +(define-record-type* default-font >> +=A0 make-default-font >> +=A0 default-font? >> +=A0 (serif default-font-serif (default "")) >> +=A0 (sans-serif defalut-font-sans-serif (default "")) >> +=A0 (monospace default-font-monospace (default ""))) > Is the empty string a meaningful value in these places? Sure, It is not meaningful. I would remove the default value. >> +(define (sxml->xmlstring sxml) >> +=A0 (if (null? sxml) >> +=A0=A0=A0=A0=A0 "" >> +=A0=A0=A0=A0=A0 (call-with-output-string >> +=A0=A0=A0=A0=A0=A0=A0 (lambda (port) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (sxml->xml sxml port) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (newline port))))) >> + >> +(define font-directories? list?) >> + >> +(define (serialize-font-directories field-name value) >> +=A0 (sxml->xmlstring >> +=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0 '((dir "~/.guix-home/profile/share/fonts")) >> +=A0=A0=A0=A0=A0=A0 (map >> +=A0=A0=A0=A0=A0=A0=A0 (lambda (path) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 `(dir ,path)) >> +=A0=A0=A0=A0=A0=A0=A0 value)))) >> + >> +(define extra-config-list? list?) >> + >> +(define (serialize-extra-config-list field-name value) >> +=A0 (sxml->xmlstring >> +=A0=A0 (map (match-lambda >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 ((? pair? sxml) sxml) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 ((? string? xml) (xml->sxml xml)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (_ (error "extra-config value must be xml s= tring or sxml >> list."))) >> +=A0=A0=A0=A0=A0=A0=A0 value))) >> + >> +(define (serialize-default-font field-name value) >> +=A0 (match value >> +=A0=A0=A0 (($ serif sans-serif monospace) >> +=A0=A0=A0=A0 (sxml->xmlstring >> +=A0=A0=A0=A0=A0 (fold (lambda (pair sxml) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if (string-null? (cdr pair)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sxml >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (append sxml >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 `((alias >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (family ,(car pair)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (prefer >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 (family ,(cdr pair)))))))) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 '() >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 `((serif . ,serif) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (sans-serif . ,sans-serif) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (monospace . ,monospace))))))) > You can greatly simplify these by serializing the fields to SXML and > only taking the final SXML and serializing it to a string. I see. We can define sanitizer for fields, right? >> +(define-configuration home-fontconfig-configuration >> +=A0 (font-directories >> +=A0=A0 (font-directories '()) >> +=A0=A0 "The directory list that provides fonts.") >> +=A0 (preferred-default-font >> +=A0=A0 (default-font (default-font)) >> +=A0=A0 "The preffered default fonts for serif, sans-serif, and >> monospace.") >> +=A0 (extra-config >> +=A0=A0 (extra-config-list '()) >> +=A0=A0 "Extra configuration values to append to the fonts.conf.")) >> + >> +(define (home-fontconfig-extend original-config extend-configs) >> +=A0 (home-fontconfig-configuration >> +=A0=A0 (inherit original-config) >> +=A0=A0 (font-directories >> +=A0=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0=A0 (home-fontconfig-configuration-font-directories o= riginal- >> config) >> +=A0=A0=A0=A0=A0=A0=A0 (append-map home-fontconfig-configuration-font-di= rectories >> extend-configs))) >> +=A0=A0 (preferred-default-font >> +=A0=A0=A0 (home-fontconfig-configuration-preferred-default-font >> +=A0=A0=A0=A0 (if (null? extend-configs) >> +=A0=A0=A0=A0=A0=A0=A0=A0 original-config >> +=A0=A0=A0=A0=A0=A0=A0=A0 (last extend-configs)))) >> +=A0=A0 (extra-config >> +=A0=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0=A0 (home-fontconfig-configuration-extra-config origi= nal-config) >> +=A0=A0=A0=A0=A0=A0=A0 (append-map home-fontconfig-configuration-extra-c= onfig >> extend-configs))))) >> + >> +(define (add-fontconfig-config-file user-config) >> =A0=A0 `(("fontconfig/fonts.conf" >> =A0=A0=A0=A0=A0 ,(mixed-text-file >> =A0=A0=A0=A0=A0=A0=A0 "fonts.conf" >> =A0=A0=A0=A0=A0=A0=A0 " >> =A0 >> - >> -=A0 ~/.guix-home/profile/share/fonts >> -")))) >> +\n" >> +=A0=A0=A0=A0=A0=A0 (serialize-configuration user-config home-fontconfig- >> configuration-fields) >> +=A0=A0=A0=A0=A0=A0 "\n")))) > Is it expected that our configuration will be pretty? If so, you might > want to use a tree fold (there sadly doesn't seem to be a built-in XML > pretty printer, which is a shame imho.) > > If not, those extra newlines do little. OK, I would remove extra newlines. >> =A0(define (regenerate-font-cache-gexp _) >> =A0=A0 `(("profile/share/fonts" >> @@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _) >> >> =A0(define home-fontconfig-service-type >> =A0=A0 (service-type (name 'home-fontconfig) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (compose identity) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (extend home-fontconfig-e= xtend) >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (extensions >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (list (service-exten= sion >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= home-xdg-configuration-files-service-type >> @@ -59,7 +150,7 @@ (define home-fontconfig-service-type >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (s= ervice-extension >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= home-profile-service-type >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= (const (list fontconfig))))) >> -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (default-value #f) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (default-value (home-font= config-configuration)) >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (description >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "Provides configurat= ion file for fontconfig and >> make >> =A0fc-* utilities aware of font packages installed in Guix Home's >> profile."))) > > Cheers > Cheers, -- Taiju