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

From: Ludovic Courtès <[email-masked]>
Date: Thu, 22 Sep 2022 10:53:47 +0200

Hi Andrew,

Andrew Tropin <[email-masked]> skribis:

> 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.

That’s generally true, but it’s not black and white and there’s room for
discussion.  :-)

In this case, Taiju’s proposal is to let users write snippets like this:

--8<---------------cut here---------------start------------->8---
    (define font-family-map
      '((sans-serif . "Noto Sans CJK JP")
        (serif . "Noto Serif CJK JP")))

    (home-environment
     (packages (list font-google-noto))
     (services
      (list
       (simple-service 'my-fontconfig-service
                       home-fontconfig-service-type
                       (list
                        (call-with-output-string
                          (lambda (port)
                            (sxml->xml
                             (map (lambda (pair)
                                    `(alias
                                      (family ,(car pair))
                                      (prefer
                                       (family ,(cdr pair)))))
                                  font-family-map)
                             port))))))))
--8<---------------cut here---------------end--------------->8---

(With v2 they’d provide SXML instead of XML-in-a-string, so it’s
slightly less verbose but quite similar.)

In this particular case, I would find it easier to use if one could
provide a set of <font-alias> records, let’s say along these lines:

  (simple-service 'my-fontconfig-service
                  home-fontconfig-service-type
                  (list (font-alias 'sans-serif "Noto Sans CJK JP") …))

That way, users wouldn’t need to know the details of the XML syntax for
fontconfig.

The downside is that it restricts what can be done: it lets you add font
aliases, but nothing more.

Do you have other use cases in mind, Taiju?

Thanks,
Ludo’.