From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 vGCiBR/pRGOfagAAbAwnHQ (envelope-from ) for ; Tue, 11 Oct 2022 05:55:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GIKiBB/pRGOpEAAA9RJhRA (envelope-from ) for ; Tue, 11 Oct 2022 05:55:11 +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 A25DD28310 for ; Tue, 11 Oct 2022 05:55:10 +0200 (CEST) Received: from localhost ([::1]:56740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi6MH-00024d-MT for larch@yhetil.org; Mon, 10 Oct 2022 23:55:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi6MA-00024V-Ez for guix-patches@gnu.org; Mon, 10 Oct 2022 23:55:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oi6MA-0000if-6H for guix-patches@gnu.org; Mon, 10 Oct 2022 23:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oi6M9-0002EI-PM for guix-patches@gnu.org; Mon, 10 Oct 2022 23:55:01 -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: Tue, 11 Oct 2022 03:55: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: 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.16654604718531 (code B ref 57963); Tue, 11 Oct 2022 03:55:01 +0000 Received: (at 57963) by debbugs.gnu.org; 11 Oct 2022 03:54:31 +0000 Received: from localhost ([127.0.0.1]:50479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi6Le-0002DW-Qe for submit@debbugs.gnu.org; Mon, 10 Oct 2022 23:54:31 -0400 Received: from mail-pj1-f54.google.com ([209.85.216.54]:52187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi6Ld-0002DJ-E0 for 57963@debbugs.gnu.org; Mon, 10 Oct 2022 23:54:29 -0400 Received: by mail-pj1-f54.google.com with SMTP id b15so11424221pje.1 for <57963@debbugs.gnu.org>; Mon, 10 Oct 2022 20:54:29 -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=Q/YEJIrUxmquULnG66dWQoiznxeIFPGI0zxsfwYXUoY=; b=iFvCZQjPlEK7mk1tWSiFW0h4H/ljP9iywge9ua7YCD7OxyKP4mBV+GYdaEGa6HnIMd Nx/7QLa3levHA+NZkvxTb+KeFZXcKjkQxUXzPo8OHbo/eJ9Hdd+H6Pb5UfXSjLaeyvS6 kDvLc6u09GuxJ8P0Kub+nWCR3PQ6W26zT8Si5U8+Bi+b9XnfDZ4oK3xaCNZbV1tv2BO6 5jmjWgJZPLFx01BGqOGfaXEfmDiuuSdbzMWWqK59TwIOupxTWSkqHtN3klzSOTMPLORn vcur8xzOPICBWV+bKfwqBdceuziu/rNxe66grI/lDTN5th+UFwT/+7U+eqy0Ltjeidva hSLw== 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=Q/YEJIrUxmquULnG66dWQoiznxeIFPGI0zxsfwYXUoY=; b=irGMntzVyRAq1840ua/hBnNtrv9WctEbsb4jdMUxMJwVVYCH8siB1YtEzcO2XnKInL w3o9PRxm7rkPt+IvChf8dOruCx1vTlPf/5ttuJQiEjzP8BvEew2QKuym8o79d2yLUL04 izm7JZHXjqitisK6OMYB+G/0fR0xID+LykVZhKo1YGaD/lBjF4BMjvNYLqqRUnlTPe+V DdhBCvBeg+yk6X0u6ZE5Z+B59Z25juVEoJsdy6+GHbgY5DiNT6q4HIc2jYOr//aOtEVk G5c2T56gyhTJIZ41aPgeMJ1ScpXFKf8+UF2otGF/TR/wGXLU40VFMgVaNqhGixl9rNAL VxWw== X-Gm-Message-State: ACrzQf0RzhU7JLB5egDUr6Ff3M2aZPKpcgD/WAInVV7w2wEr0zVHULak Z7swMj09RRaM4Dunex7/P0MglA== X-Google-Smtp-Source: AMsMyM4cINMN016fvlTWf4mlxlFVvmNIHqgOFWlGWn+/SUUHJ32/1bT/eAbba4hEmXG7HluHOZcRPg== X-Received: by 2002:a17:90a:d191:b0:20d:2649:43b1 with SMTP id fu17-20020a17090ad19100b0020d264943b1mr14481197pjb.154.1665460463447; Mon, 10 Oct 2022 20:54:23 -0700 (PDT) Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id y126-20020a623284000000b00562f9ea47a5sm5433341pfy.190.2022.10.10.20.54.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 20:54:22 -0700 (PDT) From: Taiju HIGASHI References: <20221002131535.9972-1-higashi@taiju.info> <20221002131535.9972-2-higashi@taiju.info> <87zge4chb5.fsf@trop.in> Date: Tue, 11 Oct 2022 12:54:19 +0900 In-Reply-To: <87zge4chb5.fsf@trop.in> (Andrew Tropin's message of "Mon, 10 Oct 2022 10:40:30 +0400") Message-ID: <87edvfkob8.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=1665460510; 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=Q/YEJIrUxmquULnG66dWQoiznxeIFPGI0zxsfwYXUoY=; b=P92kM+5BxrmnDzZgPTZz6Cwd23tcVgpyu5um5oSnMqaF/5cNTi/3j5DIT0DZoHvXmcw9Hj UoNLEaxB8fQgA7Pd4unkIZ75WOd62WkRHX+jI8/5QZ9+Tms+omMaL2cOLraEkw1GIGtbJk Bb5Ctnlm980pRWo7pggo6xigT1o0hBXkp3TjXxmva6piw5/ozsMZBPECrPzSWdJKCO1o0S Ha7mW7MZFNR2se/oEr6ew6q96mKqBAR8qTTk68J21fwSBB6Nc4lm6qIQqkfD7WEKqdsYTN QN55EKR33cNz3hokxKAmnY83wl+ZZ7NBgNCTiCepkkLXEcBXq8qrrDSkjUKMKA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665460510; a=rsa-sha256; cv=none; b=hinosmZukDjyCCXPJLaRnB+WQFJg2hJgUk7oclf1MwwwffRKyaS+QydyohDTUNXjW7P+hL 0Tsz9zL7rTHbSb1QH+QnoT89JcjSKcTJhthpNxl+ERTWwQXRf6NcfDJ6zSv4pi2VbJmT9o MQpgVz/3qx7TZdf79vprdGstjeb/ru7RVXr9WgamGFlOxV/kB8Q4jMJdFPe9wgddCixrTu 8bBy82GrTUDpr36OOYl9dY+L12fWCYTTw8QrmGIGyyqk6AHDTjbafq7IwXP5GiASqqb079 3UaeleWN9iPpJ2VB/UQmNbO6unuem/D56NzMlP6yoerQkSitcL92Y5dQkKkHsw== 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=iFvCZQjP; 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.61 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=iFvCZQjP; 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: A25DD28310 X-Spam-Score: 2.61 X-Migadu-Scanner: scn1.migadu.com X-TUID: dOkqU4jiCEMj 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?). 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? >> + ((? 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. >> + "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