From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 +IQIESOPOWOrLwAAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 15:16:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cD7SECOPOWPyTAAAauVa8A (envelope-from ) for ; Sun, 02 Oct 2022 15:16:19 +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 D97C5FF98 for ; Sun, 2 Oct 2022 15:16:18 +0200 (CEST) Received: from localhost ([::1]:37498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeypO-0000O4-3l for larch@yhetil.org; Sun, 02 Oct 2022 09:16:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeyp9-0000L8-1D for guix-patches@gnu.org; Sun, 02 Oct 2022 09:16:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeyp8-000396-Mp for guix-patches@gnu.org; Sun, 02 Oct 2022 09:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oeyp8-0008D2-H9 for guix-patches@gnu.org; Sun, 02 Oct 2022 09:16: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: Sun, 02 Oct 2022 13:16: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: 57963@debbugs.gnu.org Cc: ludo@gnu.org, Taiju HIGASHI , liliana.prikler@gmail.com, andrew@trop.in Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166471656131535 (code B ref 57963); Sun, 02 Oct 2022 13:16:02 +0000 Received: (at 57963) by debbugs.gnu.org; 2 Oct 2022 13:16:01 +0000 Received: from localhost ([127.0.0.1]:46502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeyp7-0008CQ-Br for submit@debbugs.gnu.org; Sun, 02 Oct 2022 09:16:01 -0400 Received: from mail-pl1-f173.google.com ([209.85.214.173]:45862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeyp4-0008C0-Cp for 57963@debbugs.gnu.org; Sun, 02 Oct 2022 09:15:59 -0400 Received: by mail-pl1-f173.google.com with SMTP id u24so635383plq.12 for <57963@debbugs.gnu.org>; Sun, 02 Oct 2022 06:15:58 -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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=IoHeb2pHkDjy0aw5l7LvutHwtBqqe7doznlxEpcU0Dw=; b=GgTjn5ljfLkxE/XCswtQXOsWZUu7oqHYytOz09s+NznnIeTWrcKwkmI1zI7hYIynBZ 0uOjEEU6JV5ohWhX3rVhkwep5aI3ZEvIJPG711Mlu32YbROeqjNUqQYdQAGvHlqPjmtW /HbhNihigVHO9jgjnWYfMNX5eyRDza1/id7v6UQc6Er46xAf/w5stINz5hCKfSzSIqDI 61A4YcR6HQ8DrFBBqsvUanlt3ryBUT2GfNyRpxHMj3tlH9dzoG1bhEePgsm7Ra1Gb6Be Tbb2rX2e3ugSIBPAdaI/rOw2Xz6nrqdj+/TclxnvBGsfBM89kP8/ti1zFxDP3Z5EPRMf lVxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=IoHeb2pHkDjy0aw5l7LvutHwtBqqe7doznlxEpcU0Dw=; b=SMbopuSY8mxjny0Us2geS9V1p7lM4BF4LeA/Hf5wq98y/9Xlmb8FK0PAzEAxr/S4p+ m2iI6ul/2q91Rie0PYATdvtsworrQNHt9m5IXTK26GDrldb/rnNuKG/Vy57z3WD+jt17 cE/U842236EOiAgePkEs2MChLfGYKqK5tT4p5fd7mXGpKn3r0W0zbsyt2w3rF1FkBFEB 9+CMgDiJ/yGw1zpbrZ98qocd9Nx6GUFaNs9LFcXB8Hce9uz/07u3u1QGc8Cz0aB6xPk0 YkPNeAlPEWlvBHdXk/k0am/vP/EHQAHCV3kaOXjuZXvCnbbBW2EunxFQCJaMW4G/y7Dc cmCQ== X-Gm-Message-State: ACrzQf1j4PVPjCpFYGPFJQc/bJQ6IO4tMmKi0p9Jb9BzY7UsJJ6k9fXW vB1KiYoYjs2fXZyf91e7V6Wr20Z8YmRZ4z2y X-Google-Smtp-Source: AMsMyM49DuD3ay4rsWw7WklKTrn1bEPKnVmt+iwOwBJ0EKDCW9jkwSJOoZ1lHzKRUajAidCfdBPXhQ== X-Received: by 2002:a17:903:1c4:b0:17f:5b7b:657 with SMTP id e4-20020a17090301c400b0017f5b7b0657mr651090plh.125.1664716552499; Sun, 02 Oct 2022 06:15:52 -0700 (PDT) Received: from Taix.flets-west.jp ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id i2-20020a17090332c200b00176c89243fcsm5342906plr.179.2022.10.02.06.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 06:15:52 -0700 (PDT) From: Taiju HIGASHI Date: Sun, 2 Oct 2022 22:15:35 +0900 Message-Id: <20221002131535.9972-2-higashi@taiju.info> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221002131535.9972-1-higashi@taiju.info> References: <20221002131535.9972-1-higashi@taiju.info> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=1664716579; 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=IoHeb2pHkDjy0aw5l7LvutHwtBqqe7doznlxEpcU0Dw=; b=hfMgbq7rY2V2jVeWuN3uM/Rt5+A8uAiAU0Jg8N79aWaFnOm/3n0/Lo83vYuWIoaqXzj3Yr eLr3lHLplrnK24wPETs7EOF8N45eh5Tq6sw2XLL3SdnuCERkXK0yn34SI4/xjHyvkNRhf6 9/9hcjItZG2C4I4PyErt14FYCEH1OTWqraT9QZpbpzmL36BGAVi6+cQxMenDUpd8ZTfHy8 bAQnnEdoud+5kNVbdFDRQAHn3smaATmOu5V8ngrQDGsrYiXmyy/qwDB0WTE78+s45fx4Ih RNq/0CwguK2yej+yrwCYX4M1RWACC4RREbE1p21Vu9UyM43ObbpL5n2h9oj3JA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664716579; a=rsa-sha256; cv=none; b=OGjtb3DMxdwF94Zvlecf90Ki2T3sffTYgHLkqbYDn9FgPXh+OCqYgBe3eP0+HtPIZKiIGo l+0lwUjcp0pyAnWoOE8H/5TxthLBTOSbbWbbkSOgrQN+7H9t2IMcjLJ/glweEPhRwGOiQa zXzoaXh9dTmGBXShJoWQY+MBW++9YgmPMXmMDBn5DplJbTysMEkRgiU/XxXpO4VH3spt1q mtOY6msI5hfKrtN7zvGTJhmAxLzcucAf8iOn7UVo8753b2Vruoe08+7IgI+Ihv1Ap79Zts noHHP0aZmLMl/6sc2ZRJ//Lgr4fsVDEHNK1IUIO6RjPy6mDhj1fVoClbv5Kw5Q== 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=GgTjn5lj; 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: 3.86 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=GgTjn5lj; 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: D97C5FF98 X-Spam-Score: 3.86 X-Migadu-Scanner: scn0.migadu.com X-TUID: dOwfzY0S+naw * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's fontconfig configuration. (home-fontconfig-configuration): New configuration for it. (string-list, maybe-string, maybe-extra-config-list): New types for it. (string-list?, extra-config-list?): New predicate procedures for it. (serialize-string-list, serialize-string, serialize-extra-config-list): New serialize procedures for it. (guix-home-font-dir): New variable. --- gnu/home/services/fontutils.scm | 89 ++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm index 6062eaed6a..4b3caf3985 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 © 2021 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2022 Taiju HIGASHI ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,9 +21,17 @@ (define-module (gnu home services fontutils) #:use-module (gnu home services) #:use-module (gnu packages fontutils) + #:use-module (gnu services configuration) + #:use-module (guix diagnostics) #:use-module (guix gexp) + #:use-module (guix i18n) + #: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)) ;;; Commentary: ;;; @@ -33,15 +42,83 @@ (define-module (gnu home services fontutils) ;;; ;;; Code: -(define (add-fontconfig-config-file he-symlink-path) +(define (sxml->xml-string sxml) + "Serialize the sxml tree @var{tree} as XML. The output will be string." + (call-with-output-string + (lambda (port) + (sxml->xml sxml port)))) + +(define guix-home-font-dir "~/.guix-home/profile/share/fonts") + +(define (string-list? value) + (and (pair? value) (every string? value))) + +(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) + ((? 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)) + "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) + "\n")))) (define (regenerate-font-cache-gexp _) `(("profile/share/fonts" @@ -59,7 +136,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."))) -- 2.37.3