guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.


From: Andrew Tropin
Subject: [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
Date: Thu, 22 Sep 2022 09:14:10 +0300

On 2022-09-22 10:20, Taiju HIGASHI wrote:

> * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's
> fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
> index 6062eaed6a..b57cccbaae 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 <andrew@trop.in>
>  ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -21,6 +22,9 @@ (define-module (gnu home services fontutils)
>    #:use-module (gnu home services)
>    #:use-module (gnu packages fontutils)
>    #:use-module (guix gexp)
> +  #:use-module (srfi srfi-1)
> +  #:use-module (sxml simple)
> +  #:use-module (ice-9 match)
>  
>    #:export (home-fontconfig-service-type))
>  
> @@ -33,15 +37,28 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>  
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (parse-extra-user-config extra-user-config)
> +  (map (match-lambda
> +         ((? pair? sxml) sxml)
> +         ((? string? xml) (xml->sxml xml))
> +         (_ (error "extra-user-config must be xml string or sxml.")))
> +       extra-user-config))
> +
> +(define (add-fontconfig-config-file extra-user-config)
>    `(("fontconfig/fonts.conf"
>       ,(mixed-text-file
>         "fonts.conf"
>         "<?xml version='1.0'?>
>  <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> -<fontconfig>
> -  <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +"
> +       (call-with-output-string
> +         (lambda (port)
> +           (sxml->xml
> +            `(fontconfig
> +              (dir "~/.guix-home/profile/share/fonts")
> +              ,@(parse-extra-user-config extra-user-config))
> +            port)
> +           (newline port)))))))
>  
>  (define (regenerate-font-cache-gexp _)
>    `(("profile/share/fonts"
> @@ -49,6 +66,8 @@ (define (regenerate-font-cache-gexp _)
>  
>  (define home-fontconfig-service-type
>    (service-type (name 'home-fontconfig)
> +                (compose concatenate)
> +                (extend append)
>                  (extensions
>                   (list (service-extension
>                          home-xdg-configuration-files-service-type
> @@ -59,7 +78,7 @@ (define home-fontconfig-service-type
>                         (service-extension
>                          home-profile-service-type
>                          (const (list fontconfig)))))
> -                (default-value #f)
> +                (default-value '())
>                  (description
>                   "Provides configuration file for fontconfig and make
>  fc-* utilities aware of font packages installed in Guix Home's profile.")))

I like the current approach, but I have two concerns:

1. Serialization happens on client side, not daemon side (during the
build), thus it doesn't support gexp and file-likes, so it would be hard
to append part of already existing file to the config or do similiar thing.

2. We had a discussion with Ludovic about rde home services vs guix home
services styles.  And this one looks like rde style, not guix.

rde takes arbitrary s-exps and g-exps with optional structure checks and
serializes them to target format.

guix uses nested records with rigid nesting structure.

rde services style examples:
https://git.sr.ht/~abcdw/rde/tree/8ec99884fad18a80a08a7c1d6a7cf46a006327c4/rde/home/services/wm.scm#L145
https://git.sr.ht/~abcdw/rde/tree/8ec99884fad18a80a08a7c1d6a7cf46a006327c4/rde/home/services/xdisorg.scm#L55

guix services style examples:
https://guix.gnu.org/manual/devel/en/guix.html#Web-Services

Related discussions:
https://issues.guix.gnu.org/53466
https://issues.guix.gnu.org/52698
https://yhetil.org/guix-devel/87h79qx5db.fsf@trop.in/

To sum up, personally I like and prefer the configuration style from
this patch, but to keep it consistent with guix system services we need
to use guix style.

-- 
Best regards,
Andrew Tropin

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]