[PATCH 0/1] Support user's fontconfig.

  • Open
  • quality assurance status badge
Details
8 participants
  • Andrew Tropin
  • Declan Tsien
  • Taiju HIGASHI
  • Liliana Marie Prikler
  • Liliana Marie Prikler
  • Ludovic Courtès
  • Maxim Cournoyer
  • (
Owner
unassigned
Submitted by
Taiju HIGASHI
Severity
normal
T
T
Taiju HIGASHI wrote on 21 Sep 2022 02:27
(address . guix-patches@gnu.org)(name . Taiju HIGASHI)(address . higashi@taiju.info)
20220921002721.23511-1-higashi@taiju.info
Hi,

I want to add custom fontconfig, so I've implemented the ability of custom
font configuration to fontutils.

It allows us to set up our fontconfig as follows.

(home-environment
(packages (list font-google-noto))
(services
(list
(simple-service 'my-fontconfig-service
home-fontconfig-service-type
(list
"<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans CJK JP</family>
</prefer>
</alias>"
"<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Serif CJK JP</family>
</prefer>
</alias>")))))

Of course, we can also use SXML!

(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))))))))

Taiju HIGASHI (1):
home: fontutils: Support user's fontconfig.

gnu/home/services/fontutils.scm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

--
2.37.3
T
T
Taiju HIGASHI wrote on 21 Sep 2022 02:29
[PATCH 1/1] home: fontutils: Support user's fontconfig.
(address . 57963@debbugs.gnu.org)(name . Taiju HIGASHI)(address . higashi@taiju.info)
20220921002921.23631-2-higashi@taiju.info
* gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's
fontconfig.
---
gnu/home/services/fontutils.scm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

Toggle diff (62 lines)
diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
index 6062eaed6a..3ea8b1db74 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,7 @@ (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)
#:export (home-fontconfig-service-type))
@@ -33,15 +35,18 @@ (define-module (gnu home services fontutils)
;;;
;;; Code:
-(define (add-fontconfig-config-file he-symlink-path)
+(define (add-fontconfig-config-file font-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>"))))
+ <dir>~/.guix-home/profile/share/fonts</dir>\n"
+ (if (null? font-config)
+ ""
+ (string-join font-config "\n" 'suffix))
+ "</fontconfig>\n"))))
(define (regenerate-font-cache-gexp _)
`(("profile/share/fonts"
@@ -49,6 +54,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 +66,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.")))
--
2.37.3
L
L
Liliana Marie Prikler wrote on 21 Sep 2022 10:54
eb87ef1cd1311448fc57ed045deb8de1311c6322.camel@ist.tugraz.at
Am Mittwoch, dem 21.09.2022 um 09:29 +0900 schrieb Taiju HIGASHI:
Toggle quote (46 lines)
> * gnu/home/services/fontutils.scm (add-fontconfig-config-file):
> Support user's fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm
> b/gnu/home/services/fontutils.scm
> index 6062eaed6a..3ea8b1db74 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,7 @@ (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)
>  
>    #:export (home-fontconfig-service-type))
>  
> @@ -33,15 +35,18 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>  
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (add-fontconfig-config-file font-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>"))))
> +  <dir>~/.guix-home/profile/share/fonts</dir>\n"
> +       (if (null? font-config)
> +           ""
> +           (string-join font-config "\n" 'suffix))
> +       "</fontconfig>\n"))))
I think it'd be wiser to pretty-print SXML here.
The structure could look something like
`(fontconfig 
(dir "~/.guix-home/profile/share/fonts")
,@(extra-user-config ...))

Also, for the particular use case of handling multiple profiles
gracefully (rather than the current status quo) I think fontconfig-
service-type should be able to construct (dir "#$profile/share/fonts")
style entries on its own. However, given that multiple profiles aren't
supported yet, this is future work.

Cheers
T
T
Taiju HIGASHI wrote on 21 Sep 2022 11:59
(name . Liliana Marie Prikler)(address . liliana.prikler@ist.tugraz.at)(address . 57963@debbugs.gnu.org)
871qs5xd30.fsf@taiju.info
Hi Liliana,

Thank you for your review.

Toggle quote (21 lines)
>> -(define (add-fontconfig-config-file he-symlink-path)
>> +(define (add-fontconfig-config-file font-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>"))))
>> +  <dir>~/.guix-home/profile/share/fonts</dir>\n"
>> +       (if (null? font-config)
>> +           ""
>> +           (string-join font-config "\n" 'suffix))
>> +       "</fontconfig>\n"))))
> I think it'd be wiser to pretty-print SXML here.
> The structure could look something like
> `(fontconfig
> (dir "~/.guix-home/profile/share/fonts")
> ,@(extra-user-config ...))

That's definitely better!
Does this assume that SXML will also accept additional user settings?

Toggle quote (6 lines)
> Also, for the particular use case of handling multiple profiles
> gracefully (rather than the current status quo) I think fontconfig-
> service-type should be able to construct (dir "#$profile/share/fonts")
> style entries on its own. However, given that multiple profiles aren't
> supported yet, this is future work.

Noted. I believe that even with the current patch, it is possible to add
arbitrary directories, so it will be better than what we have now.

Cheers
--
taiju
L
L
Liliana Marie Prikler wrote on 21 Sep 2022 13:40
(name . Taiju HIGASHI)(address . higashi@taiju.info)(address . 57963@debbugs.gnu.org)
65da0cdb245fe2bcd99589d4fb1a9eb785a1b527.camel@ist.tugraz.at
Am Mittwoch, dem 21.09.2022 um 18:59 +0900 schrieb Taiju HIGASHI:
Toggle quote (27 lines)
> Hi Liliana,
>
> Thank you for your review.
>
> > > -(define (add-fontconfig-config-file he-symlink-path)
> > > +(define (add-fontconfig-config-file font-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>"))))
> > > +  <dir>~/.guix-home/profile/share/fonts</dir>\n"
> > > +       (if (null? font-config)
> > > +           ""
> > > +           (string-join font-config "\n" 'suffix))
> > > +       "</fontconfig>\n"))))
> > I think it'd be wiser to pretty-print SXML here.
> > The structure could look something like
> > `(fontconfig
> >    (dir "~/.guix-home/profile/share/fonts")
> >    ,@(extra-user-config ...))
>
> That's definitely better!
> Does this assume that SXML will also accept additional user settings?
It assumes that whatever (extra-user-config ...) does, it returns a
list of SXML nodes, e.g. ((dir "~/.fonts")). Writing correct SXML
should be comparatively simpler to writing correct XML.

Toggle quote (9 lines)
> > Also, for the particular use case of handling multiple profiles
> > gracefully (rather than the current status quo) I think fontconfig-
> > service-type should be able to construct (dir
> > "#$profile/share/fonts") style entries on its own.  However, given
> > that multiple profiles aren't supported yet, this is future work.
>
> Noted. I believe that even with the current patch, it is possible to
> add arbitrary directories, so it will be better than what we have
> now.
That's fine, just know that this use case might at some point become
obsolete thanks to a better implementation :)
T
T
Taiju HIGASHI wrote on 22 Sep 2022 03:20
[PATCH v2] home: fontutils: Support user's fontconfig.
(address . 57963@debbugs.gnu.org)(name . Taiju HIGASHI)(address . higashi@taiju.info)
20220922012033.30835-1-higashi@taiju.info
* 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(-)

Toggle diff (75 lines)
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.")))
--
2.37.3
T
T
Taiju HIGASHI wrote on 22 Sep 2022 03:27
Re: [PATCH 1/1] home: fontutils: Support user's fontconfig.
(name . Liliana Marie Prikler)(address . liliana.prikler@ist.tugraz.at)(address . 57963@debbugs.gnu.org)
87leqcw63n.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:

Toggle quote (32 lines)
> Am Mittwoch, dem 21.09.2022 um 18:59 +0900 schrieb Taiju HIGASHI:
>> Hi Liliana,
>>
>> Thank you for your review.
>>
>> > > -(define (add-fontconfig-config-file he-symlink-path)
>> > > +(define (add-fontconfig-config-file font-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>"))))
>> > > +  <dir>~/.guix-home/profile/share/fonts</dir>\n"
>> > > +       (if (null? font-config)
>> > > +           ""
>> > > +           (string-join font-config "\n" 'suffix))
>> > > +       "</fontconfig>\n"))))
>> > I think it'd be wiser to pretty-print SXML here.
>> > The structure could look something like
>> > `(fontconfig
>> >    (dir "~/.guix-home/profile/share/fonts")
>> >    ,@(extra-user-config ...))
>>
>> That's definitely better!
>> Does this assume that SXML will also accept additional user settings?
> It assumes that whatever (extra-user-config ...) does, it returns a
> list of SXML nodes, e.g. ((dir "~/.fonts")). Writing correct SXML
> should be comparatively simpler to writing correct XML.

I just sent you the v2 patch. It uses SXML to handle the user's extra
configs.
I also made it so that the user can pass SXML directly.

I also wrote a test but did not include it in the patch because I
thought it would be a technical debt.
I'm attaching that as a reference.
;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (test-home-services-fontutils) #:use-module (gnu services) #:use-module (gnu home services) #:use-module (gnu home services fontutils) #:use-module (guix tests) #:use-module (sxml simple) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64)) ;; or (@@ (gnu home services fontutils) add-fontconfig-config-file) (define add-fontconfig-config-file (let* ((extensions (service-type-extensions home-fontconfig-service-type)) (extension (find (lambda (ext) (eq? (service-extension-target ext) home-xdg-configuration-files-service-type)) extensions)) (compute (service-extension-compute extension))) compute)) (define (assert-fontconfig-value value expected) (mock ((guix gexp) mixed-text-file (lambda* (name #:key guile #:rest text) (let ((text (string-join text ""))) (unless (string= text expected) (error "assert failed. actual: %s" text))))) (add-fontconfig-config-file value) #t)) (test-begin "home-services-fontutils") (test-assert "fontconfig (default value)" (assert-fontconfig-value '() "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir></fontconfig> ")) (test-assert "fontconfig (a text)" (assert-fontconfig-value '("<foo>foo</foo>") "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo></fontconfig> ")) (test-assert "fontconfig (multiple texts)" (assert-fontconfig-value '("<foo>foo</foo>" "<bar><baz>baz</baz></bar>") "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo><bar><baz>baz</baz></bar></fontconfig> ")) (test-assert "fontconfig (a sxml)" (assert-fontconfig-value '((foo foo)) "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo></fontconfig> ")) (test-assert "fontconfig (multiple sxml)" (assert-fontconfig-value '((foo foo) (bar (baz baz))) "\ <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig><dir>~/.guix-home/profile/share/fonts</dir><foo>foo</foo><bar><baz>baz</baz></bar></fontconfig> ")) (test-error "fontconfig (invalid value)" (add-fontconfig-config-file '(123))) (test-end "home-services-fontutils")
Toggle quote (12 lines)
>> > Also, for the particular use case of handling multiple profiles
>> > gracefully (rather than the current status quo) I think fontconfig-
>> > service-type should be able to construct (dir
>> > "#$profile/share/fonts") style entries on its own.  However, given
>> > that multiple profiles aren't supported yet, this is future work.
>>
>> Noted. I believe that even with the current patch, it is possible to
>> add arbitrary directories, so it will be better than what we have
>> now.
> That's fine, just know that this use case might at some point become
> obsolete thanks to a better implementation :)

No problem. I would like to solve the current problem first. A better
implementation is always welcome :)

Cheers
--
taiju
A
A
Andrew Tropin wrote on 22 Sep 2022 08:14
Re: [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
87pmfoq6kt.fsf@trop.in
On 2022-09-22 10:20, Taiju HIGASHI wrote:

Toggle quote (80 lines)
> * 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:

guix services style examples:

Related discussions:

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
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmMr/TIACgkQIgjSCVjB
3rCDDxAAkwi5UxtFBWaGU+WrzUdSxp5ClXpCM1kfHD8XSI2dMEQJbz7YGXQ7f7MD
hwv7489dQcDkqjwFYr6hTTMyicqemrnhi9OIg2rInp8UO83DwLCkZaJP0KVc8/mH
NpB0IaOn1hNqMjHnsgja79PLGXw+wBVrWOxTSVci3QfMv7DzO5E3abrqEzB6LuYR
xOWprV8r3/WttKLoRQ5LD113WbrDdITUrAa2Cs0yZi+bRdAEqw7jz99riqJukpnb
F2zOj5RZUkWq75cTpHCkg7DnB6iASLbMvKvJXnqYr9Yeja1w4XOmzw4Rf3DVdu15
UdiaUGwyWzuaQh61vxlVFCnJ2RQwaFL0/ClXfNH3L7ORmTbvJJT2FXhly3Nxaebn
koxWOSC2NK+PwV0WfaIoEeefT6l/FGZfhuRavSb6nKlQhgUxAnzwSjCVHGV1a94S
kNsagP23PeVtpN+vtTWdoSCKLW1xzGN8ozbrCTDfOdUiw0m1nNLrHnVgc077gjFZ
zVaQC5cmSXkpvJy7cydEEQC7erIf5BIdfbf94DP2mKmiGb1TmV5g/DY+3GEK//WS
wJiV+AdhaboAOufX9Xd/WI6ruEydHQANIUf7Yl9la05loJLTsCZ7kSsjLHfMJOCD
8QuXnZKn6weoL6YPvpgL8HCbV1WaOOvQ6h0Q5gX6JvFTiUb5Cn8=
=uFxI
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 22 Sep 2022 10:53
87sfkjiyck.fsf@gnu.org
Hi Andrew,

Andrew Tropin <andrew@trop.in> skribis:

Toggle quote (8 lines)
> 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:

Toggle snippet (23 lines)
(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))))))))

(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’.
T
T
Taiju HIGASHI wrote on 22 Sep 2022 11:50
875yhfwxe9.fsf@taiju.info
Hi Andrew and Ludovic,

Thanks for your input and background on the code style.

I'm not very knowledgeable about G-Expressions, so I don't understand
much of what you replied. (I will study it!).

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (57 lines)
> Hi Andrew,
>
> Andrew Tropin <andrew@trop.in> 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:
>
> (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))))))))
>
> (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?

My motivation for writing this patch is that I wanted to continue to use
the settings in the following file after switching to Guix Home.


Honestly, I don't know why it is so complicated, but I refered it from
the following ArchWiki content.


Therefore, just being able to set font aliasing is unfortunately not
enough to satisfy my use case.

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 23 Sep 2022 09:20
Re: [PATCH 1/1] home: fontutils: Support user's fontconfig.
(name . Taiju HIGASHI)(address . higashi@taiju.info)(address . 57963@debbugs.gnu.org)
8337bfeb95dffbbe171f706c1fbc36d12658d0f6.camel@ist.tugraz.at
Am Donnerstag, dem 22.09.2022 um 10:27 +0900 schrieb Taiju HIGASHI:
Toggle quote (3 lines)
> I also wrote a test but did not include it in the patch because I
> thought it would be a technical debt.
> I'm attaching that as a reference.
Added tests are always welcome.
L
L
Ludovic Courtès wrote on 24 Sep 2022 17:52
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
871qs093dq.fsf_-_@gnu.org
Hi,

Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (3 lines)
> I'm not very knowledgeable about G-Expressions, so I don't understand
> much of what you replied. (I will study it!).

I didn’t mention gexps. :-)

Toggle quote (14 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
> My motivation for writing this patch is that I wanted to continue to use
> the settings in the following file after switching to Guix Home.
>
> https://git.sr.ht/~taiju/taix/tree/31a37c231ebba60e38f7fa9cfe1c7a5d7362d021/item/dotfiles/fontconfig/.config/fontconfig/fonts.conf
>
> Honestly, I don't know why it is so complicated, but I refered it from
> the following ArchWiki content.
>
> https://wiki.archlinux.org/title/Font_configuration/Examples#Japanese
>
> Therefore, just being able to set font aliasing is unfortunately not
> enough to satisfy my use case.

Oh I see. Do you need every single bit from the ‘fonts.conf’ file
above?

Anyway, it does look like your v2 is the way to go, with the obvious
caveat that using it is tricky: one needs to know about fontconfig’s
config file format and about sxml.

Maybe we can go with v2 for now (it provides a useful “escape hatch”)
but prepare for more conventional configuration bindings?

Thanks,
Ludo’.
T
T
Taiju HIGASHI wrote on 25 Sep 2022 00:58
(name . Ludovic Courtès)(address . ludo@gnu.org)
87edw0v0qk.fsf@taiju.info
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (9 lines)
> Hi,
>
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> I'm not very knowledgeable about G-Expressions, so I don't understand
>> much of what you replied. (I will study it!).
>
> I didn’t mention gexps. :-)

Sorry, that comment of mine was in response to Andrew's comment.

Toggle quote (17 lines)
>> Ludovic Courtès <ludo@gnu.org> writes:
>> My motivation for writing this patch is that I wanted to continue to use
>> the settings in the following file after switching to Guix Home.
>>
>> https://git.sr.ht/~taiju/taix/tree/31a37c231ebba60e38f7fa9cfe1c7a5d7362d021/item/dotfiles/fontconfig/.config/fontconfig/fonts.conf
>>
>> Honestly, I don't know why it is so complicated, but I refered it from
>> the following ArchWiki content.
>>
>> https://wiki.archlinux.org/title/Font_configuration/Examples#Japanese
>>
>> Therefore, just being able to set font aliasing is unfortunately not
>> enough to satisfy my use case.
>
> Oh I see. Do you need every single bit from the ‘fonts.conf’ file
> above?

There may be some settings that are not needed.

Toggle quote (7 lines)
> Anyway, it does look like your v2 is the way to go, with the obvious
> caveat that using it is tricky: one needs to know about fontconfig’s
> config file format and about sxml.
>
> Maybe we can go with v2 for now (it provides a useful “escape hatch”)
> but prepare for more conventional configuration bindings?

By conventional configuration binding, do you mean adding something like
home-fontconfig-configuration to provide a dedicated fontconfig
configuration?

I have been reading the DTD and think it might be a bit of a challenge.

However, I did notice one thing, and that is that there is an include
element.
I thought that if we had a configuration where the include element could
be added, we could handle most of the use cases.
What do you think of this idea?

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 25 Sep 2022 08:25
0fdb0df07f50700454bf34cbb0d86c46bb9afe79.camel@gmail.com
Am Sonntag, dem 25.09.2022 um 07:58 +0900 schrieb Taiju HIGASHI:
Toggle quote (12 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
> > Anyway, it does look like your v2 is the way to go, with the
> > obvious caveat that using it is tricky: one needs to know about
> > fontconfig’s config file format and about sxml.
> >
> > Maybe we can go with v2 for now (it provides a useful “escape
> > hatch”) but prepare for more conventional configuration bindings?
>
> By conventional configuration binding, do you mean adding something
> like home-fontconfig-configuration to provide a dedicated  fontconfig
> configuration?
I think Ludo means that we should provide the most useful options (like
the fontconfig dirs) as dedicated record fields, while leaving an
"extra-config" escape hatch, that can be used with SXML or a raw string
for stuff that's too complicated (my personal preference would still be
SXML over the raw string, but YMMV).

Toggle quote (8 lines)
> I have been reading the DTD and think it might be a bit of a
> challenge.
> https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd
>
> However, I did notice one thing, and that is that there is an include
> element. I thought that if we had a configuration where the include
> element could be added, we could handle most of the use cases.
> What do you think of this idea?
I'd prefer extra-config over include – extra-config doesn't need to go
through file-like objects and an additional layer of G-Expression
quoting.

Cheers
T
T
Taiju HIGASHI wrote on 25 Sep 2022 09:29
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87leq7ud1s.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (19 lines)
> Am Sonntag, dem 25.09.2022 um 07:58 +0900 schrieb Taiju HIGASHI:
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>> > Anyway, it does look like your v2 is the way to go, with the
>> > obvious caveat that using it is tricky: one needs to know about
>> > fontconfig’s config file format and about sxml.
>> >
>> > Maybe we can go with v2 for now (it provides a useful “escape
>> > hatch”) but prepare for more conventional configuration bindings?
>>
>> By conventional configuration binding, do you mean adding something
>> like home-fontconfig-configuration to provide a dedicated  fontconfig
>> configuration?
> I think Ludo means that we should provide the most useful options (like
> the fontconfig dirs) as dedicated record fields, while leaving an
> "extra-config" escape hatch, that can be used with SXML or a raw string
> for stuff that's too complicated (my personal preference would still be
> SXML over the raw string, but YMMV).

I see. For example,

For example, would it be as follows?

Toggle snippet (8 lines)
(service home-fontconfig-service-type
(home-fontconfig-configuration
(dir "~/.config/fontconfig/my-fonts1.conf"))
(extra-config
(list
"<dir>~/.config/fontconfig/my-fonts2.conf")))

Toggle quote (14 lines)
>> I have been reading the DTD and think it might be a bit of a
>> challenge.
>> https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd
>>
>> However, I did notice one thing, and that is that there is an include
>> element. I thought that if we had a configuration where the include
>> element could be added, we could handle most of the use cases.
>> What do you think of this idea?
> I'd prefer extra-config over include – extra-config doesn't need to go
> through file-like objects and an additional layer of G-Expression
> quoting.
>
> Cheers

It is difficult to determine which rules to define as records, but I
thought that if I only had includes, I could handle most use cases.

For example, we assume that you will be able to write settings as
follows:

Toggle snippet (9 lines)
(service home-fontconfig-service-type
(home-fontconfig-configuration
(includes
(list
(include
(path "~/.config/fontconfig/my-fonts1.conf")
(ignore-missing #t))))))


Would it also fit with your assumption if we could also specify
extra-config here?

It is difficult to judge whether the ability to specify includes is
useful or not, though, since extra-config alone will do the job.

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 25 Sep 2022 09:34
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87bkr3ucub.fsf@taiju.info
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (32 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
>> Am Sonntag, dem 25.09.2022 um 07:58 +0900 schrieb Taiju HIGASHI:
>>> Ludovic Courtès <ludo@gnu.org> writes:
>>>
>>> > Anyway, it does look like your v2 is the way to go, with the
>>> > obvious caveat that using it is tricky: one needs to know about
>>> > fontconfig’s config file format and about sxml.
>>> >
>>> > Maybe we can go with v2 for now (it provides a useful “escape
>>> > hatch”) but prepare for more conventional configuration bindings?
>>>
>>> By conventional configuration binding, do you mean adding something
>>> like home-fontconfig-configuration to provide a dedicated  fontconfig
>>> configuration?
>> I think Ludo means that we should provide the most useful options (like
>> the fontconfig dirs) as dedicated record fields, while leaving an
>> "extra-config" escape hatch, that can be used with SXML or a raw string
>> for stuff that's too complicated (my personal preference would still be
>> SXML over the raw string, but YMMV).
>
> I see. For example,
>
> For example, would it be as follows?
>
> (service home-fontconfig-service-type
> (home-fontconfig-configuration
> (dir "~/.config/fontconfig/my-fonts1.conf"))
> (extra-config
> (list
> "<dir>~/.config/fontconfig/my-fonts2.conf")))

It was wrong. The following is more correct.

Toggle snippet (9 lines)
(service home-fontconfig-service-type
(home-fontconfig-configuration
(dirs
(list "~/.config/fontconfig/my-fonts1.conf"))
(extra-config
(list
"<match>...</match>"))))

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 25 Sep 2022 17:50
(name . Taiju HIGASHI)(address . higashi@taiju.info)
bfa2b7d3fccafadfe6c436c850cb29ddaf46f313.camel@gmail.com
Am Sonntag, dem 25.09.2022 um 16:29 +0900 schrieb Taiju HIGASHI:
Toggle quote (36 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Sonntag, dem 25.09.2022 um 07:58 +0900 schrieb Taiju HIGASHI:
> > > Ludovic Courtès <ludo@gnu.org> writes:
> > >
> > > > Anyway, it does look like your v2 is the way to go, with the
> > > > obvious caveat that using it is tricky: one needs to know about
> > > > fontconfig’s config file format and about sxml.
> > > >
> > > > Maybe we can go with v2 for now (it provides a useful “escape
> > > > hatch”) but prepare for more conventional configuration
> > > > bindings?
> > >
> > > By conventional configuration binding, do you mean adding
> > > something
> > > like home-fontconfig-configuration to provide a dedicated 
> > > fontconfig
> > > configuration?
> > I think Ludo means that we should provide the most useful options
> > (like the fontconfig dirs) as dedicated record fields, while
> > leaving an "extra-config" escape hatch, that can be used with SXML
> > or a raw string for stuff that's too complicated (my personal
> > preference would still be SXML over the raw string, but YMMV).
>
> I see.  For example,
>
> For example, would it be as follows?
>
> --8<---------------cut here---------------start------------->8---
> (service home-fontconfig-service-type
>   (home-fontconfig-configuration
>     (dir "~/.config/fontconfig/my-fonts1.conf"))
>   (extra-config
>     (list
>       "<dir>~/.config/fontconfig/my-fonts2.conf")))
> --8<---------------cut here---------------end--------------->8---
Since you can specify more than one dir, that'd be "dirs" or even
something more helpful like "font-directories". Note that those are
directories and not config files.

You corrected the extra-config thing in your reply, but also be aware
of the extra-config as SXML option.

Toggle quote (17 lines)
>
> > > I have been reading the DTD and think it might be a bit of a
> > > challenge.
> > > https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd
> > >
> > > However, I did notice one thing, and that is that there is an
> > > include element.  I thought that if we had a configuration where
> > > the include element could be added, we could handle most of the
> > > use cases. What do you think of this idea?
> > I'd prefer extra-config over include – extra-config doesn't need to
> > go through file-like objects and an additional layer of G-
> > Expression quoting.
> >
> > Cheers
>
> It is difficult to determine which rules to define as records, but I
> thought that if I only had includes, I could handle most use cases.
Go for the obvious low-hanging fruits and typical use cases first.
Don't just add a field that requires a depth of 3 or more to be useful.

Toggle quote (21 lines)
> For example, we assume that you will be able to write settings as
> follows:
>
> --8<---------------cut here---------------start------------->8---
> (service home-fontconfig-service-type
>   (home-fontconfig-configuration
>     (includes
>       (list
>         (include
>           (path "~/.config/fontconfig/my-fonts1.conf")
>           (ignore-missing #t))))))
> --8<---------------cut here---------------end--------------->8---
>
> ref:
> https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd#L59-L74
>
> Would it also fit with your assumption if we could also specify
> extra-config here?
>
> It is difficult to judge whether the ability to specify includes is
> useful or not, though, since extra-config alone will do the job.
Except for possibly some fringe use cases, include will be pointless if
you have extra-config, which is a better include :)

Cheers
T
T
Taiju HIGASHI wrote on 26 Sep 2022 03:43
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87zgemrjub.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (90 lines)
> Am Sonntag, dem 25.09.2022 um 16:29 +0900 schrieb Taiju HIGASHI:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>> > Am Sonntag, dem 25.09.2022 um 07:58 +0900 schrieb Taiju HIGASHI:
>> > > Ludovic Courtès <ludo@gnu.org> writes:
>> > >
>> > > > Anyway, it does look like your v2 is the way to go, with the
>> > > > obvious caveat that using it is tricky: one needs to know about
>> > > > fontconfig’s config file format and about sxml.
>> > > >
>> > > > Maybe we can go with v2 for now (it provides a useful “escape
>> > > > hatch”) but prepare for more conventional configuration
>> > > > bindings?
>> > >
>> > > By conventional configuration binding, do you mean adding
>> > > something
>> > > like home-fontconfig-configuration to provide a dedicated
>> > > fontconfig
>> > > configuration?
>> > I think Ludo means that we should provide the most useful options
>> > (like the fontconfig dirs) as dedicated record fields, while
>> > leaving an "extra-config" escape hatch, that can be used with SXML
>> > or a raw string for stuff that's too complicated (my personal
>> > preference would still be SXML over the raw string, but YMMV).
>>
>> I see.  For example,
>>
>> For example, would it be as follows?
>>
>> --8<---------------cut here---------------start------------->8---
>> (service home-fontconfig-service-type
>>   (home-fontconfig-configuration
>>     (dir "~/.config/fontconfig/my-fonts1.conf"))
>>   (extra-config
>>     (list
>>       "<dir>~/.config/fontconfig/my-fonts2.conf")))
>> --8<---------------cut here---------------end--------------->8---
> Since you can specify more than one dir, that'd be "dirs" or even
> something more helpful like "font-directories". Note that those are
> directories and not config files.
>
> You corrected the extra-config thing in your reply, but also be aware
> of the extra-config as SXML option.
>
>>
>> > > I have been reading the DTD and think it might be a bit of a
>> > > challenge.
>> > > https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd
>> > >
>> > > However, I did notice one thing, and that is that there is an
>> > > include element.  I thought that if we had a configuration where
>> > > the include element could be added, we could handle most of the
>> > > use cases. What do you think of this idea?
>> > I'd prefer extra-config over include – extra-config doesn't need to
>> > go through file-like objects and an additional layer of G-
>> > Expression quoting.
>> >
>> > Cheers
>>
>> It is difficult to determine which rules to define as records, but I
>> thought that if I only had includes, I could handle most use cases.
> Go for the obvious low-hanging fruits and typical use cases first.
> Don't just add a field that requires a depth of 3 or more to be useful.
>
>> For example, we assume that you will be able to write settings as
>> follows:
>>
>> --8<---------------cut here---------------start------------->8---
>> (service home-fontconfig-service-type
>>   (home-fontconfig-configuration
>>     (includes
>>       (list
>>         (include
>>           (path "~/.config/fontconfig/my-fonts1.conf")
>>           (ignore-missing #t))))))
>> --8<---------------cut here---------------end--------------->8---
>>
>> ref:
>> https://github.com/freedesktop/fontconfig/blob/e291fda7d42e5d64379555097a066d9c2c4efce3/fonts.dtd#L59-L74
>>
>> Would it also fit with your assumption if we could also specify
>> extra-config here?
>>
>> It is difficult to judge whether the ability to specify includes is
>> useful or not, though, since extra-config alone will do the job.
> Except for possibly some fringe use cases, include will be pointless if
> you have extra-config, which is a better include :)
>
> Cheers

I have designed a configuration interface with a typical font
configuration pattern. (it implemented yet.)

Toggle snippet (15 lines)
(service home-fontconfig-service-type
(home-fontconfig-configuration
(font-directories
(list "~/fonts"))
(prefered-default-font
(sans-serif "Noto Sans CJK JP")
(serif "Noto Serif CJK JP")
(monospace "PlemolJP Console"))
(extra-config ; Also accepts lists of XML strings.
`((match (@ (target font))
(edit (@ (mode assign)
(name antialias))
(bool true)))))))

This is assumed to be serialized below. (actually, it not pretty-printed.)

Toggle snippet (31 lines)
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.guix-home/profile/share/fonts</dir>
<dir>~/fonts</dir>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans CJK JP</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif CJK JP</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>PlemolJP Console</family>
</prefer>
</alias>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
</match>
</fontconfig>

How about this?

--
Cheers
Taiju
L
L
Liliana Marie Prikler wrote on 26 Sep 2022 20:19
(name . Taiju HIGASHI)(address . higashi@taiju.info)
9e0c997b246e80e66d1b48b44150761aa5e8b634.camel@gmail.com
Am Montag, dem 26.09.2022 um 10:43 +0900 schrieb Taiju HIGASHI:
Toggle quote (53 lines)
> I have designed a configuration interface with a typical font
> configuration pattern. (it implemented yet.)
>
> --8<---------------cut here---------------start------------->8---
> (service home-fontconfig-service-type
>          (home-fontconfig-configuration
>           (font-directories
>            (list "~/fonts"))
>           (prefered-default-font
>            (sans-serif "Noto Sans CJK JP")
>            (serif "Noto Serif CJK JP")
>            (monospace "PlemolJP Console"))
>           (extra-config ; Also accepts lists of XML strings.
>            `((match (@ (target font))
>                     (edit (@ (mode assign)
>                              (name antialias))
>                           (bool true)))))))
> --8<---------------cut here---------------end--------------->8---
>
> This is assumed to be serialized below. (actually, it not pretty-
> printed.)
>
> --8<---------------cut here---------------start------------->8---
> <?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> <fontconfig>
>   <dir>~/.guix-home/profile/share/fonts</dir>
>   <dir>~/fonts</dir>
>   <alias>
>     <family>sans-serif</family>
>     <prefer>
>       <family>Noto Sans CJK JP</family>
>     </prefer>
>   </alias>
>   <alias>
>     <family>serif</family>
>     <prefer>
>       <family>Noto Serif CJK JP</family>
>     </prefer>
>   </alias>
>   <alias>
>     <family>monospace</family>
>     <prefer>
>       <family>PlemolJP Console</family>
>     </prefer>
>   </alias>
>   <match target="font">
>     <edit mode="assign" name="antialias">
>       <bool>true</bool>
>     </edit>
>   </match>
> </fontconfig>
> --8<---------------cut here---------------end--------------->8---
LGTM
T
T
Taiju HIGASHI wrote on 27 Sep 2022 11:55
[PATCH v3] home: fontutils: Support user's fontconfig.
20220927095525.26431-1-higashi@taiju.info
* gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's
fontconfig.
---
gnu/home/services/fontutils.scm | 103 ++++++++++++++++++++++++++++++--
1 file changed, 97 insertions(+), 6 deletions(-)

Toggle diff (151 lines)
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 @@
;;; 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.
;;;
@@ -20,9 +21,16 @@
(define-module (gnu home services fontutils)
#:use-module (gnu home services)
#:use-module (gnu packages fontutils)
+ #:use-module (gnu services configuration)
#:use-module (guix gexp)
+ #: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
+ default-font))
;;; Commentary:
;;;
@@ -33,15 +41,96 @@ (define-module (gnu home services fontutils)
;;;
;;; Code:
-(define (add-fontconfig-config-file he-symlink-path)
+(define-record-type* <default-font> default-font
+ make-default-font
+ default-font?
+ (serif default-font-serif (default ""))
+ (sans-serif defalut-font-sans-serif (default ""))
+ (monospace default-font-monospace (default "")))
+
+(define (sxml->xmlstring sxml)
+ (if (null? sxml)
+ ""
+ (call-with-output-string
+ (lambda (port)
+ (sxml->xml sxml port)
+ (newline port)))))
+
+(define font-directories? list?)
+
+(define (serialize-font-directories field-name value)
+ (sxml->xmlstring
+ (append
+ '((dir "~/.guix-home/profile/share/fonts"))
+ (map
+ (lambda (path)
+ `(dir ,path))
+ value))))
+
+(define extra-config-list? list?)
+
+(define (serialize-extra-config-list field-name value)
+ (sxml->xmlstring
+ (map (match-lambda
+ ((? pair? sxml) sxml)
+ ((? string? xml) (xml->sxml xml))
+ (_ (error "extra-config value must be xml string or sxml list.")))
+ value)))
+
+(define (serialize-default-font field-name value)
+ (match value
+ (($ <default-font> serif sans-serif monospace)
+ (sxml->xmlstring
+ (fold (lambda (pair sxml)
+ (if (string-null? (cdr pair))
+ sxml
+ (append sxml
+ `((alias
+ (family ,(car pair))
+ (prefer
+ (family ,(cdr pair))))))))
+ '()
+ `((serif . ,serif)
+ (sans-serif . ,sans-serif)
+ (monospace . ,monospace)))))))
+
+(define-configuration home-fontconfig-configuration
+ (font-directories
+ (font-directories '())
+ "The directory list that provides fonts.")
+ (preferred-default-font
+ (default-font (default-font))
+ "The preffered default fonts for serif, sans-serif, and monospace.")
+ (extra-config
+ (extra-config-list '())
+ "Extra configuration values to append to the fonts.conf."))
+
+(define (home-fontconfig-extend original-config extend-configs)
+ (home-fontconfig-configuration
+ (inherit original-config)
+ (font-directories
+ (append
+ (home-fontconfig-configuration-font-directories original-config)
+ (append-map home-fontconfig-configuration-font-directories extend-configs)))
+ (preferred-default-font
+ (home-fontconfig-configuration-preferred-default-font
+ (if (null? extend-configs)
+ original-config
+ (last extend-configs))))
+ (extra-config
+ (append
+ (home-fontconfig-configuration-extra-config original-config)
+ (append-map home-fontconfig-configuration-extra-config extend-configs)))))
+
+(define (add-fontconfig-config-file 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>"))))
+<fontconfig>\n"
+ (serialize-configuration user-config home-fontconfig-configuration-fields)
+ "</fontconfig>\n"))))
(define (regenerate-font-cache-gexp _)
`(("profile/share/fonts"
@@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _)
(define home-fontconfig-service-type
(service-type (name 'home-fontconfig)
+ (compose identity)
+ (extend home-fontconfig-extend)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
@@ -59,7 +150,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
T
T
Taiju HIGASHI wrote on 27 Sep 2022 12:10
(address . 57963@debbugs.gnu.org)
87bkr1qg9x.fsf@taiju.info
Hi,

I just sent you the v3 patch.

I have changed only the interface of `preferred-defalut-font` slightly
from what I suggested the other day.

We configure the service as follows.

Toggle snippet (18 lines)
(simple-service
'my-fontconfig-service
home-fontconfig-service-type
(home-fontconfig-configuration
(font-directories
(list "~/fonts"))
(preferred-default-font
(default-font
(serif "Noto Serif CJK JP")
(sans-serif "Noto Sans CJK JP")
(monospace "PlemolJP Console")))
(extra-config
`((match (@ (target font))
(edit (@ (mode assign)
(name antialias))
(bool true)))))))

I didn't understand it properly, but `home-fontconfig-service-type` is
pre-registered as `essential-services` and needs to be extended using
`simple-service`.

Toggle quote (13 lines)
> +(define (home-fontconfig-extend original-config extend-configs)
> + (home-fontconfig-configuration
> + (inherit original-config)
> + (font-directories
> + (append
> + (home-fontconfig-configuration-font-directories original-config)
> + (append-map home-fontconfig-configuration-font-directories extend-configs)))
> + (preferred-default-font
> + (home-fontconfig-configuration-preferred-default-font
> + (if (null? extend-configs)
> + original-config
> + (last extend-configs))))

This is the part I am most concerned about, not sure if replacing the
preferred-default-font setting with the last setting is the proper way
to go about it.

I wanted to write a test as well, but since it was to be handled by
gexp, I could not figure out how to write a test that would validate the
gexp result using only exported methods. (I would like to write tests
for serialized functions that are private functions.)

Cheers,
--
Taiju
L
L
Liliana Marie Prikler wrote on 28 Sep 2022 21:11
(address . 57963@debbugs.gnu.org)
2add7a8c83272c5bcb9aac38e63161a48f321cda.camel@gmail.com
Am Dienstag, dem 27.09.2022 um 18:55 +0900 schrieb Taiju HIGASHI:
Toggle quote (50 lines)
> * gnu/home/services/fontutils.scm (add-fontconfig-config-file):
> Support user's
> fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 103
> ++++++++++++++++++++++++++++++--
>  1 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 @@
>  ;;; 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.
>  ;;;
> @@ -20,9 +21,16 @@
>  (define-module (gnu home services fontutils)
>    #:use-module (gnu home services)
>    #:use-module (gnu packages fontutils)
> +  #:use-module (gnu services configuration)
>    #:use-module (guix gexp)
> +  #: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
> +            default-font))
>  
>  ;;; Commentary:
>  ;;;
> @@ -33,15 +41,96 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>  
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define-record-type* <default-font> default-font
> +  make-default-font
> +  default-font?
> +  (serif default-font-serif (default ""))
> +  (sans-serif defalut-font-sans-serif (default ""))
> +  (monospace default-font-monospace (default "")))
Is the empty string a meaningful value in these places?

Toggle quote (46 lines)
> +(define (sxml->xmlstring sxml)
> +  (if (null? sxml)
> +      ""
> +      (call-with-output-string
> +        (lambda (port)
> +          (sxml->xml sxml port)
> +          (newline port)))))
> +
> +(define font-directories? list?)
> +
> +(define (serialize-font-directories field-name value)
> +  (sxml->xmlstring
> +   (append
> +       '((dir "~/.guix-home/profile/share/fonts"))
> +       (map
> +        (lambda (path)
> +          `(dir ,path))
> +        value))))
> +
> +(define extra-config-list? list?)
> +
> +(define (serialize-extra-config-list field-name value)
> +  (sxml->xmlstring
> +   (map (match-lambda
> +          ((? pair? sxml) sxml)
> +          ((? string? xml) (xml->sxml xml))
> +          (_ (error "extra-config value must be xml string or sxml
> list.")))
> +        value)))
> +
> +(define (serialize-default-font field-name value)
> +  (match value
> +    (($ <default-font> serif sans-serif monospace)
> +     (sxml->xmlstring
> +      (fold (lambda (pair sxml)
> +              (if (string-null? (cdr pair))
> +                  sxml
> +                  (append sxml
> +                      `((alias
> +                         (family ,(car pair))
> +                         (prefer
> +                          (family ,(cdr pair))))))))
> +            '()
> +            `((serif . ,serif)
> +              (sans-serif . ,sans-serif)
> +              (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.

Toggle quote (45 lines)
> +(define-configuration home-fontconfig-configuration
> +  (font-directories
> +   (font-directories '())
> +   "The directory list that provides fonts.")
> +  (preferred-default-font
> +   (default-font (default-font))
> +   "The preffered default fonts for serif, sans-serif, and
> monospace.")
> +  (extra-config
> +   (extra-config-list '())
> +   "Extra configuration values to append to the fonts.conf."))
> +
> +(define (home-fontconfig-extend original-config extend-configs)
> +  (home-fontconfig-configuration
> +   (inherit original-config)
> +   (font-directories
> +    (append
> +        (home-fontconfig-configuration-font-directories original-
> config)
> +        (append-map home-fontconfig-configuration-font-directories
> extend-configs)))
> +   (preferred-default-font
> +    (home-fontconfig-configuration-preferred-default-font
> +     (if (null? extend-configs)
> +         original-config
> +         (last extend-configs))))
> +   (extra-config
> +    (append
> +        (home-fontconfig-configuration-extra-config original-config)
> +        (append-map home-fontconfig-configuration-extra-config
> extend-configs)))))
> +
> +(define (add-fontconfig-config-file 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>"))))
> +<fontconfig>\n"
> +       (serialize-configuration user-config home-fontconfig-
> configuration-fields)
> +       "</fontconfig>\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.

Toggle quote (23 lines)
>  (define (regenerate-font-cache-gexp _)
>    `(("profile/share/fonts"
> @@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _)
>  
>  (define home-fontconfig-service-type
>    (service-type (name 'home-fontconfig)
> +                (compose identity)
> +                (extend home-fontconfig-extend)
>                  (extensions
>                   (list (service-extension
>                          home-xdg-configuration-files-service-type
> @@ -59,7 +150,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.")))

Cheers
L
L
Ludovic Courtès wrote on 28 Sep 2022 23:15
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87v8p7dwvc.fsf_-_@gnu.org
Hi,

Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (24 lines)
> I just sent you the v3 patch.
>
> I have changed only the interface of `preferred-defalut-font` slightly
> from what I suggested the other day.
>
> We configure the service as follows.
>
> (simple-service
> 'my-fontconfig-service
> home-fontconfig-service-type
> (home-fontconfig-configuration
> (font-directories
> (list "~/fonts"))
> (preferred-default-font
> (default-font
> (serif "Noto Serif CJK JP")
> (sans-serif "Noto Sans CJK JP")
> (monospace "PlemolJP Console")))
> (extra-config
> `((match (@ (target font))
> (edit (@ (mode assign)
> (name antialias))
> (bool true)))))))

Looks nicer IMO!

Toggle quote (17 lines)
>> +(define (home-fontconfig-extend original-config extend-configs)
>> + (home-fontconfig-configuration
>> + (inherit original-config)
>> + (font-directories
>> + (append
>> + (home-fontconfig-configuration-font-directories original-config)
>> + (append-map home-fontconfig-configuration-font-directories extend-configs)))
>> + (preferred-default-font
>> + (home-fontconfig-configuration-preferred-default-font
>> + (if (null? extend-configs)
>> + original-config
>> + (last extend-configs))))
>
> This is the part I am most concerned about, not sure if replacing the
> preferred-default-font setting with the last setting is the proper way
> to go about it.

It’s unusual for a service to receive extensions that are the full
configuration object of that service. Because then, indeed, you have to
determine how to “merge” those configuration objects.

The common patterns that we have are:

1. The service accepts as extensions things that represent part of its
configuration and where merging makes sense.

For example, nginx can be extended with
<nginx-location-configuration> objects, but not with a full-blown
<nginx-configuration>.

2. Similar, but the service has specific records for extensions.

The example that comes to mind is ‘home-bash-service-type’, which
accepts <home-bash-extension> records as its extensions.

So…

I wonder, should we, as a first commit, move
‘home-fontconfig-service-type’ out of the essential services to a
‘%base-home-services’ variable yet to be defined?

I don’t see any good reason to have it here (“essential” services should
be limited to those that may not be replaced or removed; in (gnu
system), this includes services that depend on information available in
<operating-system>).

Once we’ve done that, perhaps we can forget about extensions, at least
for now, and let users who need to configure things write:

(modify-services %base-home-services
(home-fontconfig-service-type
config => …))

WDYT?

Toggle quote (5 lines)
> I wanted to write a test as well, but since it was to be handled by
> gexp, I could not figure out how to write a test that would validate the
> gexp result using only exported methods. (I would like to write tests
> for serialized functions that are private functions.)

Hmm.

Once we’ve settled on an interface, the commit that makes this change
should include an update of doc/guix.texi.

Thanks!

Ludo’.
T
T
Taiju HIGASHI wrote on 29 Sep 2022 02:31
Re: [PATCH v3] home: fontutils: Support user's fontconfig.
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87tu4rowc2.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (53 lines)
> 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.
>> ---
>>  gnu/home/services/fontutils.scm | 103
>> ++++++++++++++++++++++++++++++--
>>  1 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 @@
>>  ;;; 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.
>>  ;;;
>> @@ -20,9 +21,16 @@
>>  (define-module (gnu home services fontutils)
>>    #:use-module (gnu home services)
>>    #:use-module (gnu packages fontutils)
>> +  #:use-module (gnu services configuration)
>>    #:use-module (guix gexp)
>> +  #: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
>> +            default-font))
>>
>>  ;;; Commentary:
>>  ;;;
>> @@ -33,15 +41,96 @@ (define-module (gnu home services fontutils)
>>  ;;;
>>  ;;; Code:
>>
>> -(define (add-fontconfig-config-file he-symlink-path)
>> +(define-record-type* <default-font> default-font
>> +  make-default-font
>> +  default-font?
>> +  (serif default-font-serif (default ""))
>> +  (sans-serif defalut-font-sans-serif (default ""))
>> +  (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.

Toggle quote (49 lines)
>> +(define (sxml->xmlstring sxml)
>> +  (if (null? sxml)
>> +      ""
>> +      (call-with-output-string
>> +        (lambda (port)
>> +          (sxml->xml sxml port)
>> +          (newline port)))))
>> +
>> +(define font-directories? list?)
>> +
>> +(define (serialize-font-directories field-name value)
>> +  (sxml->xmlstring
>> +   (append
>> +       '((dir "~/.guix-home/profile/share/fonts"))
>> +       (map
>> +        (lambda (path)
>> +          `(dir ,path))
>> +        value))))
>> +
>> +(define extra-config-list? list?)
>> +
>> +(define (serialize-extra-config-list field-name value)
>> +  (sxml->xmlstring
>> +   (map (match-lambda
>> +          ((? pair? sxml) sxml)
>> +          ((? string? xml) (xml->sxml xml))
>> +          (_ (error "extra-config value must be xml string or sxml
>> list.")))
>> +        value)))
>> +
>> +(define (serialize-default-font field-name value)
>> +  (match value
>> +    (($ <default-font> serif sans-serif monospace)
>> +     (sxml->xmlstring
>> +      (fold (lambda (pair sxml)
>> +              (if (string-null? (cdr pair))
>> +                  sxml
>> +                  (append sxml
>> +                      `((alias
>> +                         (family ,(car pair))
>> +                         (prefer
>> +                          (family ,(cdr pair))))))))
>> +            '()
>> +            `((serif . ,serif)
>> +              (sans-serif . ,sans-serif)
>> +              (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?

Toggle quote (51 lines)
>> +(define-configuration home-fontconfig-configuration
>> +  (font-directories
>> +   (font-directories '())
>> +   "The directory list that provides fonts.")
>> +  (preferred-default-font
>> +   (default-font (default-font))
>> +   "The preffered default fonts for serif, sans-serif, and
>> monospace.")
>> +  (extra-config
>> +   (extra-config-list '())
>> +   "Extra configuration values to append to the fonts.conf."))
>> +
>> +(define (home-fontconfig-extend original-config extend-configs)
>> +  (home-fontconfig-configuration
>> +   (inherit original-config)
>> +   (font-directories
>> +    (append
>> +        (home-fontconfig-configuration-font-directories original-
>> config)
>> +        (append-map home-fontconfig-configuration-font-directories
>> extend-configs)))
>> +   (preferred-default-font
>> +    (home-fontconfig-configuration-preferred-default-font
>> +     (if (null? extend-configs)
>> +         original-config
>> +         (last extend-configs))))
>> +   (extra-config
>> +    (append
>> +        (home-fontconfig-configuration-extra-config original-config)
>> +        (append-map home-fontconfig-configuration-extra-config
>> extend-configs)))))
>> +
>> +(define (add-fontconfig-config-file 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>"))))
>> +<fontconfig>\n"
>> +       (serialize-configuration user-config home-fontconfig-
>> configuration-fields)
>> +       "</fontconfig>\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.

Toggle quote (26 lines)
>>  (define (regenerate-font-cache-gexp _)
>>    `(("profile/share/fonts"
>> @@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _)
>>
>>  (define home-fontconfig-service-type
>>    (service-type (name 'home-fontconfig)
>> +                (compose identity)
>> +                (extend home-fontconfig-extend)
>>                  (extensions
>>                   (list (service-extension
>>                          home-xdg-configuration-files-service-type
>> @@ -59,7 +150,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.")))
>
> Cheers
>

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 29 Sep 2022 03:01
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87y1u3ngds.fsf@taiju.info
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (66 lines)
> Hi,
>
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> I just sent you the v3 patch.
>>
>> I have changed only the interface of `preferred-defalut-font` slightly
>> from what I suggested the other day.
>>
>> We configure the service as follows.
>>
>> (simple-service
>> 'my-fontconfig-service
>> home-fontconfig-service-type
>> (home-fontconfig-configuration
>> (font-directories
>> (list "~/fonts"))
>> (preferred-default-font
>> (default-font
>> (serif "Noto Serif CJK JP")
>> (sans-serif "Noto Sans CJK JP")
>> (monospace "PlemolJP Console")))
>> (extra-config
>> `((match (@ (target font))
>> (edit (@ (mode assign)
>> (name antialias))
>> (bool true)))))))
>
> Looks nicer IMO!
>
>>> +(define (home-fontconfig-extend original-config extend-configs)
>>> + (home-fontconfig-configuration
>>> + (inherit original-config)
>>> + (font-directories
>>> + (append
>>> + (home-fontconfig-configuration-font-directories original-config)
>>> + (append-map home-fontconfig-configuration-font-directories
>>> extend-configs)))
>>> + (preferred-default-font
>>> + (home-fontconfig-configuration-preferred-default-font
>>> + (if (null? extend-configs)
>>> + original-config
>>> + (last extend-configs))))
>>
>> This is the part I am most concerned about, not sure if replacing the
>> preferred-default-font setting with the last setting is the proper way
>> to go about it.
>
> It’s unusual for a service to receive extensions that are the full
> configuration object of that service. Because then, indeed, you have to
> determine how to “merge” those configuration objects.
>
> The common patterns that we have are:
>
> 1. The service accepts as extensions things that represent part of its
> configuration and where merging makes sense.
>
> For example, nginx can be extended with
> <nginx-location-configuration> objects, but not with a full-blown
> <nginx-configuration>.
>
> 2. Similar, but the service has specific records for extensions.
>
> The example that comes to mind is ‘home-bash-service-type’, which
> accepts <home-bash-extension> records as its extensions.

Thank you. I understand well.
I felt out of place because there was no service that can full
configuration such this one.

Toggle quote (20 lines)
> So…
>
> I wonder, should we, as a first commit, move
> ‘home-fontconfig-service-type’ out of the essential services to a
> ‘%base-home-services’ variable yet to be defined?
>
> I don’t see any good reason to have it here (“essential” services should
> be limited to those that may not be replaced or removed; in (gnu
> system), this includes services that depend on information available in
> <operating-system>).
>
> Once we’ve done that, perhaps we can forget about extensions, at least
> for now, and let users who need to configure things write:
>
> (modify-services %base-home-services
> (home-fontconfig-service-type
> config => …))
>
> WDYT?

I found out what essential services should be.
I'm going to move it from essential services to base-home-services.

Toggle quote (10 lines)
>> I wanted to write a test as well, but since it was to be handled by
>> gexp, I could not figure out how to write a test that would validate the
>> gexp result using only exported methods. (I would like to write tests
>> for serialized functions that are private functions.)
>
> Hmm.
>
> Once we’ve settled on an interface, the commit that makes this change
> should include an update of doc/guix.texi.

Yes. I can write the draft, but I may have to ask you to finish it because
I'm not good at writing English.
It would be a waste of time for you to spend a long time correcting my
poor grammar and expressions.

Thanks,
--
Taiju
L
L
Ludovic Courtès wrote on 29 Sep 2022 16:28
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87h70qb6gq.fsf@gnu.org
Hi,

Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (3 lines)
> I found out what essential services should be.
> I'm going to move it from essential services to base-home-services.

Alright, let’s do that (in a separate commit).

Toggle quote (8 lines)
>> Once we’ve settled on an interface, the commit that makes this change
>> should include an update of doc/guix.texi.
>
> Yes. I can write the draft, but I may have to ask you to finish it because
> I'm not good at writing English.
> It would be a waste of time for you to spend a long time correcting my
> poor grammar and expressions.

Sure; I’m not a native speaker either but I can help.

Thanks,
Ludo’.
T
T
Taiju HIGASHI wrote on 29 Sep 2022 16:36
[PATCH v4 1/2] home-services: Add base.
(address . 57963@debbugs.gnu.org)
20220929143633.28844-1-higashi@taiju.info
* gnu/home.scm: Move home-fontconfig-service-type from
home-environment-default-essential-services to %home-base-services.
* gnu/home/services/base.scm: Add base.
---
gnu/home.scm | 5 ++---
gnu/home/services/base.scm | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
create mode 100644 gnu/home/services/base.scm

Toggle diff (76 lines)
diff --git a/gnu/home.scm b/gnu/home.scm
index c95d1e0818..c79db87018 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -19,10 +19,10 @@
(define-module (gnu home)
#:use-module (gnu home services)
+ #:use-module (gnu home services base)
#:use-module (gnu home services symlink-manager)
#:use-module (gnu home services shells)
#:use-module (gnu home services xdg)
- #:use-module (gnu home services fontutils)
#:use-module (gnu services)
#:use-module (guix records)
#:use-module (guix diagnostics)
@@ -66,7 +66,7 @@ (define-record-type* <home-environment> home-environment
this-home-environment)))
(services home-environment-user-services
- (default '()))
+ (default %home-base-services))
(location home-environment-location ; <location>
(default (and=> (current-source-location)
@@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)
(service home-symlink-manager-service-type)
- (service home-fontconfig-service-type)
(service home-xdg-base-directories-service-type)
(service home-shell-profile-service-type)
diff --git a/gnu/home/services/base.scm b/gnu/home/services/base.scm
new file mode 100644
index 0000000000..fbf92ba213
--- /dev/null
+++ b/gnu/home/services/base.scm
@@ -0,0 +1,35 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home services base)
+ #:use-module (gnu home services)
+ #:use-module (gnu home services fontutils)
+ #:export (%home-base-services))
+
+;;; Commentary:
+;;
+;; Base home services---i,e., services that 99% of the users will want to use.
+;;
+;;; Code:
+
+
+(define %home-base-services
+ ;; Convenience variable holding the basic services.
+ (list (service home-fontconfig-service-type)))
+
+;;; base.scm ends here
--
2.37.3
T
T
Taiju HIGASHI wrote on 29 Sep 2022 16:36
[PATCH v4 2/2] home: fontutils: Support user's fontconfig.
(address . 57963@debbugs.gnu.org)
20220929143633.28844-2-higashi@taiju.info
* gnu/home/services/fontutils.scm: Support user's fontconfig.
---
gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++---
1 file changed, 80 insertions(+), 6 deletions(-)

Toggle diff (127 lines)
diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
index 6062eaed6a..32127740f6 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.
;;;
@@ -20,9 +21,16 @@
(define-module (gnu home services fontutils)
#:use-module (gnu home services)
#:use-module (gnu packages fontutils)
+ #:use-module (gnu services configuration)
#:use-module (guix gexp)
+ #: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
+ default-font))
;;; Commentary:
;;;
@@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
;;;
;;; Code:
-(define (add-fontconfig-config-file he-symlink-path)
+(define (default-font-sanitizer type)
+ (lambda (value)
+ (if (null? value)
+ value
+ `(alias
+ (family ,type)
+ (prefer
+ (family ,value))))))
+
+(define-record-type* <default-font> default-font
+ make-default-font
+ default-font?
+ (serif default-font-serif
+ (default '())
+ (sanitize (default-font-sanitizer 'serif)))
+ (sans-serif defalut-font-sans-serif
+ (default '())
+ (sanitize (default-font-sanitizer 'sans-serif)))
+ (monospace default-font-monospace
+ (default '())
+ (sanitize (default-font-sanitizer 'monospace))))
+
+(define (sxml->xmlstring sxml)
+ (if (null? sxml)
+ ""
+ (call-with-output-string
+ (lambda (port)
+ (sxml->xml sxml port)))))
+
+(define font-directories? list?)
+
+(define (serialize-font-directories field-name value)
+ (sxml->xmlstring
+ (append
+ '((dir "~/.guix-home/profile/share/fonts"))
+ (map
+ (lambda (path)
+ `(dir ,path))
+ value))))
+
+(define extra-config-list? list?)
+
+(define (serialize-extra-config-list field-name value)
+ (sxml->xmlstring
+ (map (match-lambda
+ ((? pair? sxml) sxml)
+ ((? string? xml) (xml->sxml xml))
+ (_ (error "extra-config value must be xml string or sxml list.")))
+ value)))
+
+(define (serialize-default-font field-name value)
+ (match value
+ (($ <default-font> serif sans-serif monospace)
+ (sxml->xmlstring (list serif sans-serif monospace)))))
+
+(define-configuration home-fontconfig-configuration
+ (font-directories
+ (font-directories '())
+ "The directory list that provides fonts.")
+ (preferred-default-font
+ (default-font (default-font))
+ "The preffered default fonts for serif, sans-serif, and monospace.")
+ (extra-config
+ (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"
"<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
-<fontconfig>
- <dir>~/.guix-home/profile/share/fonts</dir>
-</fontconfig>"))))
+<fontconfig>"
+ (serialize-configuration user-config home-fontconfig-configuration-fields)
+ "</fontconfig>\n"))))
(define (regenerate-font-cache-gexp _)
`(("profile/share/fonts"
@@ -59,7 +133,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
L
L
Liliana Marie Prikler wrote on 29 Sep 2022 16:43
Re: [PATCH v4 1/2] home-services: Add base.
5fae106ffa5f240d3b41d57a063afee1787ca506.camel@gmail.com
Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
Toggle quote (2 lines)
> * gnu/home.scm: Move home-fontconfig-service-type from
> home-environment-default-essential-services to %home-base-services.
Unless there is a precedent in system, I would make all the currently
"essential" services %home-base-services perhaps move their code
accordingly.
Toggle quote (1 lines)
> * gnu/home/services/base.scm: Add base.
Should be "New file." Also should probably be the first item in the
ChangeLog, so that other items can mention it.

Cheers
T
T
Taiju HIGASHI wrote on 29 Sep 2022 16:46
Re: [PATCH v3] home: fontutils: Support user's fontconfig.
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87fsgansqy.fsf@taiju.info
Hi Liliana,

I've sent you the v4 patch.

Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (13 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
>>> -(define (add-fontconfig-config-file he-symlink-path)
>>> +(define-record-type* <default-font> default-font
>>> +  make-default-font
>>> +  default-font?
>>> +  (serif default-font-serif (default ""))
>>> +  (sans-serif defalut-font-sans-serif (default ""))
>>> +  (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.

I couldn't remove the default value because without a default value, for
example, it can't specify only serifs.
However, I've changed the serialization of the field so that it is now a
comfortable default value.

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 29 Sep 2022 16:51
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Ludovic Courtès)(address . ludo@gnu.org)
875yh6nshm.fsf@taiju.info
Hi Ludovic,

I've sent you the v4 patch.

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (9 lines)
> Hi,
>
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> I found out what essential services should be.
>> I'm going to move it from essential services to base-home-services.
>
> Alright, let’s do that (in a separate commit).

I've tried it. In particular, I'm wondering if I defined
%home-base-services in the right place.

Toggle quote (10 lines)
>>> Once we’ve settled on an interface, the commit that makes this change
>>> should include an update of doc/guix.texi.
>>
>> Yes. I can write the draft, but I may have to ask you to finish it because
>> I'm not good at writing English.
>> It would be a waste of time for you to spend a long time correcting my
>> poor grammar and expressions.
>
> Sure; I’m not a native speaker either but I can help.

I know it will take some time, but I'll try my best. By the way, if I
edit the texi file, am I correct in confirming that I read the built
Info?


Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 29 Sep 2022 16:55
Re: [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
(address . 57963@debbugs.gnu.org)
87y1u2mdrf.fsf@taiju.info
The new way to extend the service is as follows.

Toggle snippet (23 lines)
(home-environment
(packages (list font-google-noto))
(services
(append
(list
(service home-bash-service-type))
(modify-services %home-base-services
(home-fontconfig-service-type
config => (home-fontconfig-configuration
(font-directories
(list "~/fonts"))
(preferred-default-font
(default-font
(serif "Noto Serif CJK JP")
(sans-serif "Noto Sans CJK JP")))
(extra-config
`((match (@ (target font))
(edit (@ (mode assign)
(name antialias))
(bool true)))))))))))


Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (131 lines)
> * gnu/home/services/fontutils.scm: Support user's fontconfig.
> ---
> gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++---
> 1 file changed, 80 insertions(+), 6 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
> index 6062eaed6a..32127740f6 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.
> ;;;
> @@ -20,9 +21,16 @@
> (define-module (gnu home services fontutils)
> #:use-module (gnu home services)
> #:use-module (gnu packages fontutils)
> + #:use-module (gnu services configuration)
> #:use-module (guix gexp)
> + #: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
> + default-font))
>
> ;;; Commentary:
> ;;;
> @@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
> ;;;
> ;;; Code:
>
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (default-font-sanitizer type)
> + (lambda (value)
> + (if (null? value)
> + value
> + `(alias
> + (family ,type)
> + (prefer
> + (family ,value))))))
> +
> +(define-record-type* <default-font> default-font
> + make-default-font
> + default-font?
> + (serif default-font-serif
> + (default '())
> + (sanitize (default-font-sanitizer 'serif)))
> + (sans-serif defalut-font-sans-serif
> + (default '())
> + (sanitize (default-font-sanitizer 'sans-serif)))
> + (monospace default-font-monospace
> + (default '())
> + (sanitize (default-font-sanitizer 'monospace))))
> +
> +(define (sxml->xmlstring sxml)
> + (if (null? sxml)
> + ""
> + (call-with-output-string
> + (lambda (port)
> + (sxml->xml sxml port)))))
> +
> +(define font-directories? list?)
> +
> +(define (serialize-font-directories field-name value)
> + (sxml->xmlstring
> + (append
> + '((dir "~/.guix-home/profile/share/fonts"))
> + (map
> + (lambda (path)
> + `(dir ,path))
> + value))))
> +
> +(define extra-config-list? list?)
> +
> +(define (serialize-extra-config-list field-name value)
> + (sxml->xmlstring
> + (map (match-lambda
> + ((? pair? sxml) sxml)
> + ((? string? xml) (xml->sxml xml))
> + (_ (error "extra-config value must be xml string or sxml list.")))
> + value)))
> +
> +(define (serialize-default-font field-name value)
> + (match value
> + (($ <default-font> serif sans-serif monospace)
> + (sxml->xmlstring (list serif sans-serif monospace)))))
> +
> +(define-configuration home-fontconfig-configuration
> + (font-directories
> + (font-directories '())
> + "The directory list that provides fonts.")
> + (preferred-default-font
> + (default-font (default-font))
> + "The preffered default fonts for serif, sans-serif, and monospace.")
> + (extra-config
> + (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"
> "<?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> -<fontconfig>
> - <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +<fontconfig>"
> + (serialize-configuration user-config home-fontconfig-configuration-fields)
> + "</fontconfig>\n"))))
>
> (define (regenerate-font-cache-gexp _)
> `(("profile/share/fonts"
> @@ -59,7 +133,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.")))

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 29 Sep 2022 17:09
Re: [PATCH v4 1/2] home-services: Add base.
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87leq2md3b.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (7 lines)
> Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
>> * gnu/home.scm: Move home-fontconfig-service-type from
>> home-environment-default-essential-services to %home-base-services.
> Unless there is a precedent in system, I would make all the currently
> "essential" services %home-base-services perhaps move their code
> accordingly.

I thought it was only for home-fontconfig-service. Does that mean
delete "essential" services and move everything to %home-base-services?

Toggle quote (4 lines)
>> * gnu/home/services/base.scm: Add base.
> Should be "New file." Also should probably be the first item in the
> ChangeLog, so that other items can mention it.

I understood that "Add base" should be "New file", but I didn't
understand the second part. I apologize for my lack of understanding.

Cheers,
--
Taiju
(
Re: [bug#57963] [PATCH 0/1] Support user's fontconfig.
CN90FPMQ3C2P.2HK4GB7JG6GAI@guix-aspire
Hey Taiju and Liliana,

On Thu Sep 29, 2022 at 3:51 PM BST, Taiju HIGASHI wrote:
Toggle quote (4 lines)
> > Sure; I’m not a native speaker either but I can help.
>
> I know it will take some time, but I'll try my best.

If you wish I'll help you with the manual. (I'm a native
British English speaker.)

-- (
T
T
Taiju HIGASHI wrote on 30 Sep 2022 02:12
(name . ()(address . paren@disroot.org)
878rm1n2j9.fsf@taiju.info
Hi (,

"(" <paren@disroot.org> writes:

Toggle quote (12 lines)
> Hey Taiju and Liliana,
>
> On Thu Sep 29, 2022 at 3:51 PM BST, Taiju HIGASHI wrote:
>> > Sure; I’m not a native speaker either but I can help.
>>
>> I know it will take some time, but I'll try my best.
>
> If you wish I'll help you with the manual. (I'm a native
> British English speaker.)
>
> -- (

Thank you, it helps!
However, the interface may still change, so it will be a little while
before I write documentation.

Best Regards,
--
Taiju
L
L
liliana.prikler wrote on 30 Sep 2022 20:21
Re: [PATCH v4 1/2] home-services: Add base.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
111ec39af53f41c937a995f494474c6ff7b1e44b.camel@gmail.com
Am Freitag, dem 30.09.2022 um 00:09 +0900 schrieb Taiju HIGASHI:
Toggle quote (14 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
> > > * gnu/home.scm: Move home-fontconfig-service-type from
> > > home-environment-default-essential-services to %home-base-
> > > services.
> > Unless there is a precedent in system, I would make all the
> > currently
> > "essential" services %home-base-services perhaps move their code
> > accordingly.
>
> I thought it was only for home-fontconfig-service.  Does that mean
> delete "essential" services and move everything to %home-base-
> services?
I'd double-check with Andrew, but my personal opinion is "yes".

Toggle quote (8 lines)
> > > * gnu/home/services/base.scm: Add base.
> > Should be "New file."  Also should probably be the first item in
> > the
> > ChangeLog, so that other items can mention it.
>
> I understood that "Add base" should be "New file", but I didn't
> understand the second part.  I apologize for my lack of
> understanding.
It means put the * gnu/home/services/base.scm entry before the *
gnu/home.scm one, so that you can mention the former in the latter.

Cheers
L
L
liliana.prikler wrote on 30 Sep 2022 20:30
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
99cd84d6b5d3e3cc85f90aecae76ae0ef791e18a.camel@gmail.com
Am Donnerstag, dem 29.09.2022 um 23:51 +0900 schrieb Taiju HIGASHI:
Toggle quote (3 lines)
> I know it will take some time, but I'll try my best.  By the way, if
> I edit the texi file, am I correct in confirming that I read the
> built Info?
After running `make', you should run `info doc/guix.info' and scroll to
the edited section to verify that it reads as you intended.

Cheers
L
L
liliana.prikler wrote on 30 Sep 2022 20:34
Re: [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
3e28e656526b901a3fd099d1cd180528f24e15e7.camel@gmail.com
Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
Toggle quote (58 lines)
> * gnu/home/services/fontutils.scm: Support user's fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++-
> --
>  1 file changed, 80 insertions(+), 6 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm
> b/gnu/home/services/fontutils.scm
> index 6062eaed6a..32127740f6 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.
>  ;;;
> @@ -20,9 +21,16 @@
>  (define-module (gnu home services fontutils)
>    #:use-module (gnu home services)
>    #:use-module (gnu packages fontutils)
> +  #:use-module (gnu services configuration)
>    #:use-module (guix gexp)
> +  #: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
> +            default-font))
>  
>  ;;; Commentary:
>  ;;;
> @@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>  
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (default-font-sanitizer type)
> +  (lambda (value)
> +    (if (null? value)
> +        value
> +        `(alias
> +          (family ,type)
> +          (prefer
> +           (family ,value))))))
> +
> +(define-record-type* <default-font> default-font
> +  make-default-font
> +  default-font?
> +  (serif default-font-serif
> +         (default '())
> +         (sanitize (default-font-sanitizer 'serif)))
> +  (sans-serif defalut-font-sans-serif
default-font-sans-serif
Toggle quote (5 lines)
> +              (default '())
> +              (sanitize (default-font-sanitizer 'sans-serif)))
> +  (monospace default-font-monospace
> +             (default '())
> +             (sanitize (default-font-sanitizer 'monospace))))
Rather than having a null default and sanitizing the field as here, can
we have an #f default and omit the field?

Btw. I'm not sure whether making this an extra record is the right
idea. Wouldn't "default-(serif|sans-serif|monospace)-family" at the
root make more sense?

Cheers
T
T
Taiju HIGASHI wrote on 1 Oct 2022 13:08
Re: [PATCH v4 1/2] home-services: Add base.
(address . liliana.prikler@gmail.com)
878rlzsswf.fsf@taiju.info
liliana.prikler@gmail.com writes:

Toggle quote (17 lines)
> Am Freitag, dem 30.09.2022 um 00:09 +0900 schrieb Taiju HIGASHI:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>> > Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
>> > > * gnu/home.scm: Move home-fontconfig-service-type from
>> > > home-environment-default-essential-services to %home-base-
>> > > services.
>> > Unless there is a precedent in system, I would make all the
>> > currently
>> > "essential" services %home-base-services perhaps move their code
>> > accordingly.
>>
>> I thought it was only for home-fontconfig-service.  Does that mean
>> delete "essential" services and move everything to %home-base-
>> services?
> I'd double-check with Andrew, but my personal opinion is "yes".

Noted. It may take some time until he can reply, but I will wait for
Andrew's reply.

Toggle quote (11 lines)
>> > > * gnu/home/services/base.scm: Add base.
>> > Should be "New file."  Also should probably be the first item in
>> > the
>> > ChangeLog, so that other items can mention it.
>>
>> I understood that "Add base" should be "New file", but I didn't
>> understand the second part.  I apologize for my lack of
>> understanding.
> It means put the * gnu/home/services/base.scm entry before the *
> gnu/home.scm one, so that you can mention the former in the latter.

Thank you for the specific explanation, I understand.

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 1 Oct 2022 13:11
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(address . liliana.prikler@gmail.com)
87y1tzre7t.fsf@taiju.info
liliana.prikler@gmail.com writes:

Toggle quote (9 lines)
> Am Donnerstag, dem 29.09.2022 um 23:51 +0900 schrieb Taiju HIGASHI:
>> I know it will take some time, but I'll try my best.  By the way, if
>> I edit the texi file, am I correct in confirming that I read the
>> built Info?
> After running `make', you should run `info doc/guix.info' and scroll to
> the edited section to verify that it reads as you intended.
>
> Cheers

Thank you, I will verify the edited documentation that way.

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 1 Oct 2022 13:19
Re: [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
(address . liliana.prikler@gmail.com)
87o7uvrdt4.fsf@taiju.info
liliana.prikler@gmail.com writes:

Toggle quote (74 lines)
> Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
>> * gnu/home/services/fontutils.scm: Support user's fontconfig.
>> ---
>>  gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++-
>> --
>>  1 file changed, 80 insertions(+), 6 deletions(-)
>>
>> diff --git a/gnu/home/services/fontutils.scm
>> b/gnu/home/services/fontutils.scm
>> index 6062eaed6a..32127740f6 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.
>>  ;;;
>> @@ -20,9 +21,16 @@
>>  (define-module (gnu home services fontutils)
>>    #:use-module (gnu home services)
>>    #:use-module (gnu packages fontutils)
>> +  #:use-module (gnu services configuration)
>>    #:use-module (guix gexp)
>> +  #: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
>> +            default-font))
>>
>>  ;;; Commentary:
>>  ;;;
>> @@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
>>  ;;;
>>  ;;; Code:
>>
>> -(define (add-fontconfig-config-file he-symlink-path)
>> +(define (default-font-sanitizer type)
>> +  (lambda (value)
>> +    (if (null? value)
>> +        value
>> +        `(alias
>> +          (family ,type)
>> +          (prefer
>> +           (family ,value))))))
>> +
>> +(define-record-type* <default-font> default-font
>> +  make-default-font
>> +  default-font?
>> +  (serif default-font-serif
>> +         (default '())
>> +         (sanitize (default-font-sanitizer 'serif)))
>> +  (sans-serif defalut-font-sans-serif
> default-font-sans-serif
>> +              (default '())
>> +              (sanitize (default-font-sanitizer 'sans-serif)))
>> +  (monospace default-font-monospace
>> +             (default '())
>> +             (sanitize (default-font-sanitizer 'monospace))))
> Rather than having a null default and sanitizing the field as here, can
> we have an #f default and omit the field?
>
> Btw. I'm not sure whether making this an extra record is the right
> idea. Wouldn't "default-(serif|sans-serif|monospace)-family" at the
> root make more sense?
>
> Cheers

Do you mean to write as follows?

Toggle snippet (20 lines)
(home-environment
(packages (list font-google-noto))
(services
(append
(list
(service home-bash-service-type))
(modify-services %home-base-services
(home-fontconfig-service-type
config => (home-fontconfig-configuration
(font-directories
(list "~/fonts"))
(default-serif-family "Noto Serif CJK JP")
(default-sans-serif-family "Noto Sans CJK JP")
(extra-config
`((match (@ (target font))
(edit (@ (mode assign)
(name antialias))
(bool true)))))))))))

Cheers,
--
Taiju
L
L
liliana.prikler wrote on 1 Oct 2022 18:14
(name . Taiju HIGASHI)(address . higashi@taiju.info)
6155f2126a6725979ee51079c0d90f5d00c31e1c.camel@gmail.com
Am Samstag, dem 01.10.2022 um 20:19 +0900 schrieb Taiju HIGASHI:
Toggle quote (101 lines)
> liliana.prikler@gmail.com writes:
>
> > Am Donnerstag, dem 29.09.2022 um 23:36 +0900 schrieb Taiju HIGASHI:
> > > * gnu/home/services/fontutils.scm: Support user's fontconfig.
> > > ---
> > >  gnu/home/services/fontutils.scm | 86
> > > ++++++++++++++++++++++++++++++-
> > > --
> > >  1 file changed, 80 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/gnu/home/services/fontutils.scm
> > > b/gnu/home/services/fontutils.scm
> > > index 6062eaed6a..32127740f6 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.
> > >  ;;;
> > > @@ -20,9 +21,16 @@
> > >  (define-module (gnu home services fontutils)
> > >    #:use-module (gnu home services)
> > >    #:use-module (gnu packages fontutils)
> > > +  #:use-module (gnu services configuration)
> > >    #:use-module (guix gexp)
> > > +  #: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
> > > +            default-font))
> > >
> > >  ;;; Commentary:
> > >  ;;;
> > > @@ -33,15 +41,81 @@ (define-module (gnu home services fontutils)
> > >  ;;;
> > >  ;;; Code:
> > >
> > > -(define (add-fontconfig-config-file he-symlink-path)
> > > +(define (default-font-sanitizer type)
> > > +  (lambda (value)
> > > +    (if (null? value)
> > > +        value
> > > +        `(alias
> > > +          (family ,type)
> > > +          (prefer
> > > +           (family ,value))))))
> > > +
> > > +(define-record-type* <default-font> default-font
> > > +  make-default-font
> > > +  default-font?
> > > +  (serif default-font-serif
> > > +         (default '())
> > > +         (sanitize (default-font-sanitizer 'serif)))
> > > +  (sans-serif defalut-font-sans-serif
> > default-font-sans-serif
> > > +              (default '())
> > > +              (sanitize (default-font-sanitizer 'sans-serif)))
> > > +  (monospace default-font-monospace
> > > +             (default '())
> > > +             (sanitize (default-font-sanitizer 'monospace))))
> > Rather than having a null default and sanitizing the field as here,
> > can
> > we have an #f default and omit the field?
> >
> > Btw. I'm not sure whether making this an extra record is the right
> > idea.  Wouldn't "default-(serif|sans-serif|monospace)-family" at
> > the
> > root make more sense?
> >
> > Cheers
>
> Do you mean to write as follows?
>
> --8<---------------cut here---------------start------------->8---
> (home-environment
>  (packages (list font-google-noto))
>  (services
>   (append
>       (list
>        (service home-bash-service-type))
>       (modify-services %home-base-services
>         (home-fontconfig-service-type
>          config => (home-fontconfig-configuration
>                     (font-directories
>                      (list "~/fonts"))
>                     (default-serif-family "Noto Serif CJK JP")
>                     (default-sans-serif-family "Noto Sans CJK JP")
>                     (extra-config
>                      `((match (@ (target font))
>                          (edit (@ (mode assign)
>                                   (name antialias))
>                                (bool true)))))))))))
> --8<---------------cut here---------------end--------------->8---
Yep. Feels more natural imho.
L
L
Ludovic Courtès wrote on 1 Oct 2022 23:47
Re: [PATCH v4 1/2] home-services: Add base.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87r0zrb4hu.fsf@gnu.org
Hi,

Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (4 lines)
> * gnu/home.scm: Move home-fontconfig-service-type from
> home-environment-default-essential-services to %home-base-services.
> * gnu/home/services/base.scm: Add base.

In addition to what Liliana wrote, please make sure to add the new file
to ‘gnu/local.mk’.

Toggle quote (8 lines)
> @@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)
>
> (service home-symlink-manager-service-type)
>
> - (service home-fontconfig-service-type)
> (service home-xdg-base-directories-service-type)
> (service home-shell-profile-service-type)

Like Liliana wrote, it may be that more of these can be moved from
“essential” to “base”, we can keep that for a later patch.

Otherwise LGTM!

Ludo’.
L
L
Ludovic Courtès wrote on 1 Oct 2022 23:57
Re: [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87ill3b41t.fsf@gnu.org
Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (2 lines)
> * gnu/home/services/fontutils.scm: Support user's fontconfig.

I’m nitpicking a bit, but here we would describe all the
variables/procedures added, removed, or modified. Please check ‘git
log’ for examples.

Regarding code, there’s a convention to add a docstring to each
top-level procedure:


It would be nice to follow it here.

Toggle quote (9 lines)
> +(define (default-font-sanitizer type)
> + (lambda (value)
> + (if (null? value)
> + value
> + `(alias
> + (family ,type)
> + (prefer
> + (family ,value))))))

Giving '() special meaning here looks quite unusual. As Liliana wrote,
we’d usually use #f as the value denoting “nothing”.

Toggle quote (7 lines)
> +(define (sxml->xmlstring sxml)
> + (if (null? sxml)
> + ""
> + (call-with-output-string
> + (lambda (port)
> + (sxml->xml sxml port)))))

Same here. Also, “xml-string” rather than “xmlstring”.

Toggle quote (2 lines)
> +(define font-directories? list?)

Is it really needed?

Toggle quote (9 lines)
> +(define (serialize-font-directories field-name value)
> + (sxml->xmlstring
> + (append
> + '((dir "~/.guix-home/profile/share/fonts"))
> + (map
> + (lambda (path)
> + `(dir ,path))
> + value))))

The indentation would rather be:

(append '((dir …))
(map (lambda (directory)
`(dir ,directory))
value))

Toggle quote (5 lines)
> + (map (match-lambda
> + ((? pair? sxml) sxml)
> + ((? string? xml) (xml->sxml xml))
> + (_ (error "extra-config value must be xml string or sxml list.")))

Instead of ‘error’, which would lead to an ugly backtrace and an
untranslated error message, write:

(raise (formatted-message (G_ "'extra-config' …")))

without a trailing dot in the message.

The rest LGTM! Like I wrote, could you please add documentation in
‘doc/guix.texi’, with a configuration example like the one you gave?

Thanks for all the work!

Ludo’.
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:12
[PATCH v5 1/2] home: services: Add base.
(address . 57963@debbugs.gnu.org)
20221002131232.9063-1-higashi@taiju.info
* gnu/home/services/base.scm: New file.
* gnu/home.scm (): Move home-fontconfig-service-type from
home-environment-default-essential-services to its %home-base-services.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
gnu/home.scm | 5 ++---
gnu/home/services/base.scm | 35 +++++++++++++++++++++++++++++++++++
gnu/local.mk | 2 ++
3 files changed, 39 insertions(+), 3 deletions(-)
create mode 100644 gnu/home/services/base.scm

Toggle diff (96 lines)
diff --git a/gnu/home.scm b/gnu/home.scm
index c95d1e0818..c79db87018 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -19,10 +19,10 @@
(define-module (gnu home)
#:use-module (gnu home services)
+ #:use-module (gnu home services base)
#:use-module (gnu home services symlink-manager)
#:use-module (gnu home services shells)
#:use-module (gnu home services xdg)
- #:use-module (gnu home services fontutils)
#:use-module (gnu services)
#:use-module (guix records)
#:use-module (guix diagnostics)
@@ -66,7 +66,7 @@ (define-record-type* <home-environment> home-environment
this-home-environment)))
(services home-environment-user-services
- (default '()))
+ (default %home-base-services))
(location home-environment-location ; <location>
(default (and=> (current-source-location)
@@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)
(service home-symlink-manager-service-type)
- (service home-fontconfig-service-type)
(service home-xdg-base-directories-service-type)
(service home-shell-profile-service-type)
diff --git a/gnu/home/services/base.scm b/gnu/home/services/base.scm
new file mode 100644
index 0000000000..fbf92ba213
--- /dev/null
+++ b/gnu/home/services/base.scm
@@ -0,0 +1,35 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home services base)
+ #:use-module (gnu home services)
+ #:use-module (gnu home services fontutils)
+ #:export (%home-base-services))
+
+;;; Commentary:
+;;
+;; Base home services---i,e., services that 99% of the users will want to use.
+;;
+;;; Code:
+
+
+(define %home-base-services
+ ;; Convenience variable holding the basic services.
+ (list (service home-fontconfig-service-type)))
+
+;;; base.scm ends here
diff --git a/gnu/local.mk b/gnu/local.mk
index 26fdfe7ca9..c0fceafd3f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -54,6 +54,7 @@
# Copyright © 2022 muradm <mail@muradm.net>
# Copyright © 2022 Hilton Chain <hako@ultrarare.space>
# Copyright © 2022 Alex Griffin <a@ajgrf.com>
+# Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
#
# This file is part of GNU Guix.
#
@@ -85,6 +86,7 @@ GNU_SYSTEM_MODULES = \
%D%/compression.scm \
%D%/home.scm \
%D%/home/services.scm \
+ %D%/home/services/base.scm \
%D%/home/services/desktop.scm \
%D%/home/services/symlink-manager.scm \
%D%/home/services/fontutils.scm \
--
2.37.3
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:15
(address . 57963@debbugs.gnu.org)
20221002131535.9972-1-higashi@taiju.info
* gnu/home/services/base.scm: New file.
* gnu/home.scm (home-environment): Move home-fontconfig-service-type from
home-environment-default-essential-services to %home-base-services of it.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
gnu/home.scm | 5 ++---
gnu/home/services/base.scm | 35 +++++++++++++++++++++++++++++++++++
gnu/local.mk | 2 ++
3 files changed, 39 insertions(+), 3 deletions(-)
create mode 100644 gnu/home/services/base.scm

Toggle diff (94 lines)
diff --git a/gnu/home.scm b/gnu/home.scm
index c95d1e0818..c79db87018 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -19,10 +19,10 @@

(define-module (gnu home)
#:use-module (gnu home services)
+ #:use-module (gnu home services base)
#:use-module (gnu home services symlink-manager)
#:use-module (gnu home services shells)
#:use-module (gnu home services xdg)
- #:use-module (gnu home services fontutils)
#:use-module (gnu services)
#:use-module (guix records)
#:use-module (guix diagnostics)
@@ -66,7 +66,7 @@ (define-record-type* <home-environment> home-environment
this-home-environment)))

(services home-environment-user-services
- (default '()))
+ (default %home-base-services))

(location home-environment-location ; <location>
(default (and=> (current-source-location)
@@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)

(service home-symlink-manager-service-type)

- (service home-fontconfig-service-type)
(service home-xdg-base-directories-service-type)
(service home-shell-profile-service-type)

diff --git a/gnu/home/services/base.scm b/gnu/home/services/base.scm
new file mode 100644
index 0000000000..fbf92ba213
--- /dev/null
+++ b/gnu/home/services/base.scm
@@ -0,0 +1,35 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home services base)
+ #:use-module (gnu home services)
+ #:use-module (gnu home services fontutils)
+ #:export (%home-base-services))
+
+;;; Commentary:
+;;
+;; Base home services---i,e., services that 99% of the users will want to use.
+;;
+;;; Code:
+
+
+(define %home-base-services
+ ;; Convenience variable holding the basic services.
+ (list (service home-fontconfig-service-type)))
+
+;;; base.scm ends here
diff --git a/gnu/local.mk b/gnu/local.mk
index 26fdfe7ca9..c0fceafd3f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -54,6 +54,7 @@
# Copyright © 2022 muradm <mail@muradm.net>
# Copyright © 2022 Hilton Chain <hako@ultrarare.space>
# Copyright © 2022 Alex Griffin <a@ajgrf.com>
+# Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
#
# This file is part of GNU Guix.
#
@@ -85,6 +86,7 @@ GNU_SYSTEM_MODULES = \
%D%/compression.scm \
%D%/home.scm \
%D%/home/services.scm \
+ %D%/home/services/base.scm \
%D%/home/services/desktop.scm \
%D%/home/services/symlink-manager.scm \
%D%/home/services/fontutils.scm \
--
2.37.3
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:15
[PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(address . 57963@debbugs.gnu.org)
20221002131535.9972-2-higashi@taiju.info
* 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(-)

Toggle diff (130 lines)
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 <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
+;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
;;;
;;; 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"
"<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
-<fontconfig>
- <dir>~/.guix-home/profile/share/fonts</dir>
-</fontconfig>"))))
+<fontconfig>"
+ (serialize-configuration user-config home-fontconfig-configuration-fields)
+ "</fontconfig>\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
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:20
Re: [PATCH v5 1/2] home: services: Add base.
(address . 57963@debbugs.gnu.org)
87fsg6qs3y.fsf@taiju.info
Hi,

I'm sorry. This email is incorrect; the second email, "[PATCH v5 1/2]
home: services: Add base." is correct.

Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (106 lines)
> * gnu/home/services/base.scm: New file.
> * gnu/home.scm (): Move home-fontconfig-service-type from
> home-environment-default-essential-services to its %home-base-services.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> ---
> gnu/home.scm | 5 ++---
> gnu/home/services/base.scm | 35 +++++++++++++++++++++++++++++++++++
> gnu/local.mk | 2 ++
> 3 files changed, 39 insertions(+), 3 deletions(-)
> create mode 100644 gnu/home/services/base.scm
>
> diff --git a/gnu/home.scm b/gnu/home.scm
> index c95d1e0818..c79db87018 100644
> --- a/gnu/home.scm
> +++ b/gnu/home.scm
> @@ -19,10 +19,10 @@
>
> (define-module (gnu home)
> #:use-module (gnu home services)
> + #:use-module (gnu home services base)
> #:use-module (gnu home services symlink-manager)
> #:use-module (gnu home services shells)
> #:use-module (gnu home services xdg)
> - #:use-module (gnu home services fontutils)
> #:use-module (gnu services)
> #:use-module (guix records)
> #:use-module (guix diagnostics)
> @@ -66,7 +66,7 @@ (define-record-type* <home-environment> home-environment
> this-home-environment)))
>
> (services home-environment-user-services
> - (default '()))
> + (default %home-base-services))
>
> (location home-environment-location ; <location>
> (default (and=> (current-source-location)
> @@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)
>
> (service home-symlink-manager-service-type)
>
> - (service home-fontconfig-service-type)
> (service home-xdg-base-directories-service-type)
> (service home-shell-profile-service-type)
>
> diff --git a/gnu/home/services/base.scm b/gnu/home/services/base.scm
> new file mode 100644
> index 0000000000..fbf92ba213
> --- /dev/null
> +++ b/gnu/home/services/base.scm
> @@ -0,0 +1,35 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify it
> +;;; under the terms of the GNU General Public License as published by
> +;;; the Free Software Foundation; either version 3 of the License, or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu home services base)
> + #:use-module (gnu home services)
> + #:use-module (gnu home services fontutils)
> + #:export (%home-base-services))
> +
> +;;; Commentary:
> +;;
> +;; Base home services---i,e., services that 99% of the users will want to use.
> +;;
> +;;; Code:
> +
> +
> +(define %home-base-services
> + ;; Convenience variable holding the basic services.
> + (list (service home-fontconfig-service-type)))
> +
> +;;; base.scm ends here
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 26fdfe7ca9..c0fceafd3f 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -54,6 +54,7 @@
> # Copyright © 2022 muradm <mail@muradm.net>
> # Copyright © 2022 Hilton Chain <hako@ultrarare.space>
> # Copyright © 2022 Alex Griffin <a@ajgrf.com>
> +# Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
> #
> # This file is part of GNU Guix.
> #
> @@ -85,6 +86,7 @@ GNU_SYSTEM_MODULES = \
> %D%/compression.scm \
> %D%/home.scm \
> %D%/home/services.scm \
> + %D%/home/services/base.scm \
> %D%/home/services/desktop.scm \
> %D%/home/services/symlink-manager.scm \
> %D%/home/services/fontutils.scm \

--
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:22
Re: [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
(address . liliana.prikler@gmail.com)
87a66eqs0t.fsf@taiju.info
Toggle quote (48 lines)
>> > > +(define-record-type* <default-font> default-font
>> > > +  make-default-font
>> > > +  default-font?
>> > > +  (serif default-font-serif
>> > > +         (default '())
>> > > +         (sanitize (default-font-sanitizer 'serif)))
>> > > +  (sans-serif defalut-font-sans-serif
>> > default-font-sans-serif
>> > > +              (default '())
>> > > +              (sanitize (default-font-sanitizer 'sans-serif)))
>> > > +  (monospace default-font-monospace
>> > > +             (default '())
>> > > +             (sanitize (default-font-sanitizer 'monospace))))
>> > Rather than having a null default and sanitizing the field as here,
>> > can
>> > we have an #f default and omit the field?
>> >
>> > Btw. I'm not sure whether making this an extra record is the right
>> > idea.  Wouldn't "default-(serif|sans-serif|monospace)-family" at
>> > the
>> > root make more sense?
>> >
>> > Cheers
>>
>> Do you mean to write as follows?
>>
>> --8<---------------cut here---------------start------------->8---
>> (home-environment
>>  (packages (list font-google-noto))
>>  (services
>>   (append
>>       (list
>>        (service home-bash-service-type))
>>       (modify-services %home-base-services
>>         (home-fontconfig-service-type
>>          config => (home-fontconfig-configuration
>>                     (font-directories
>>                      (list "~/fonts"))
>>                     (default-serif-family "Noto Serif CJK JP")
>>                     (default-sans-serif-family "Noto Sans CJK JP")
>>                     (extra-config
>>                      `((match (@ (target font))
>>                          (edit (@ (mode assign)
>>                                   (name antialias))
>>                                (bool true)))))))))))
>> --8<---------------cut here---------------end--------------->8---
> Yep. Feels more natural imho.

I have changed the interface as you suggested in the v5 patch.

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:38
(name . Ludovic Courtès)(address . ludo@gnu.org)
87pmfapcpc.fsf@taiju.info
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (15 lines)
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> * gnu/home/services/fontutils.scm: Support user's fontconfig.
>
> I’m nitpicking a bit, but here we would describe all the
> variables/procedures added, removed, or modified. Please check ‘git
> log’ for examples.
>
> Regarding code, there’s a convention to add a docstring to each
> top-level procedure:
>
> https://guix.gnu.org/manual/devel/en/html_node/Formatting-Code.html
>
> It would be nice to follow it here.

I have listed them all in the v5 patch.
As for the serializer/predicate procedure, I did not add it because
there was no docstring in the existing procedure.

Toggle quote (12 lines)
>> +(define (default-font-sanitizer type)
>> + (lambda (value)
>> + (if (null? value)
>> + value
>> + `(alias
>> + (family ,type)
>> + (prefer
>> + (family ,value))))))
>
> Giving '() special meaning here looks quite unusual. As Liliana wrote,
> we’d usually use #f as the value denoting “nothing”.

I may have confused it with Common Lisp. I have eliminated the field
with the empty list as the default value.

Toggle quote (9 lines)
>> +(define (sxml->xmlstring sxml)
>> + (if (null? sxml)
>> + ""
>> + (call-with-output-string
>> + (lambda (port)
>> + (sxml->xml sxml port)))))
>
> Same here. Also, “xml-string” rather than “xmlstring”.

Fixed to xml-string.

Toggle quote (4 lines)
>> +(define font-directories? list?)
>
> Is it really needed?

I may not have addressed this point yet. Is it possible to not define a
predicate procedure to be used for a configuration field?

Toggle quote (16 lines)
>> +(define (serialize-font-directories field-name value)
>> + (sxml->xmlstring
>> + (append
>> + '((dir "~/.guix-home/profile/share/fonts"))
>> + (map
>> + (lambda (path)
>> + `(dir ,path))
>> + value))))
>
> The indentation would rather be:
>
> (append '((dir …))
> (map (lambda (directory)
> `(dir ,directory))
> value))

I think I fixed it by refactoring.

Toggle quote (12 lines)
>> + (map (match-lambda
>> + ((? pair? sxml) sxml)
>> + ((? string? xml) (xml->sxml xml))
>> + (_ (error "extra-config value must be xml string or sxml list.")))
>
> Instead of ‘error’, which would lead to an ugly backtrace and an
> untranslated error message, write:
>
> (raise (formatted-message (G_ "'extra-config' …")))
>
> without a trailing dot in the message.

I have fixed it.

Toggle quote (3 lines)
> The rest LGTM! Like I wrote, could you please add documentation in
> ‘doc/guix.texi’, with a configuration example like the one you gave?

Since there were many points raised and interface changes in this case,
I will revise the document after the review is complete.

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 2 Oct 2022 15:45
Re: [PATCH v4 1/2] home-services: Add base.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87edvqpcf4.fsf@taiju.info
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (11 lines)
> Hi,
>
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> * gnu/home.scm: Move home-fontconfig-service-type from
>> home-environment-default-essential-services to %home-base-services.
>> * gnu/home/services/base.scm: Add base.
>
> In addition to what Liliana wrote, please make sure to add the new file
> to ‘gnu/local.mk’.

I have added it.

Toggle quote (11 lines)
>> @@ -82,7 +82,6 @@ (define (home-environment-default-essential-services he)
>>
>> (service home-symlink-manager-service-type)
>>
>> - (service home-fontconfig-service-type)
>> (service home-xdg-base-directories-service-type)
>> (service home-shell-profile-service-type)
>
> Like Liliana wrote, it may be that more of these can be moved from
> “essential” to “base”, we can keep that for a later patch.

Please let us address this in a later patch.

I would like to discuss something with you.
I'm aware that this patch is a breaking change. We are aware that if we
do not add %base-home-services to the existing home configuration, fontconfig will change.
I'm concerned about how the community will react to this.

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 2 Oct 2022 16:59
50fb35fa126af65eae644dbe543ffc70267908c1.camel@gmail.com
Am Sonntag, dem 02.10.2022 um 22:45 +0900 schrieb Taiju HIGASHI:
Toggle quote (10 lines)
> > Like Liliana wrote, it may be that more of these can be moved from
> > “essential” to “base”, we can keep that for a later patch.
>
> Please let us address this in a later patch.
>
> I would like to discuss something with you.
> I'm aware that this patch is a breaking change. We are aware that if
> we do not add %base-home-services to the existing home configuration,
> fontconfig will change. I'm concerned about how the community will
> react to this.
As long as the out-of-the-box behaviour stays the same, the community
has no reason to complain. For what it's worth, you could also leave
fontconfig as an essential service, but then you get another field to
configure.

As far as I see, essential services are also a thing on the system
side, but the home and system variants have a somewhat different feel
to them. The fontconfig-service is not actually essential, the profile
service type arguably isn't either (it acts as yet another profile and
simultaneously fails to satisfy the multi-profile use-case; more on
that elsewhere), the xdg-base-directories one notably violates the XDG
Base Directories specification, and so on.

I'd get Andrew's approval before moving services, but I'd move them in
one go rather than bit by bit.

Cheers
T
T
Taiju HIGASHI wrote on 4 Oct 2022 01:27
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87zgeco5da.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (24 lines)
> Am Sonntag, dem 02.10.2022 um 22:45 +0900 schrieb Taiju HIGASHI:
>> > Like Liliana wrote, it may be that more of these can be moved from
>> > “essential” to “base”, we can keep that for a later patch.
>>
>> Please let us address this in a later patch.
>>
>> I would like to discuss something with you.
>> I'm aware that this patch is a breaking change. We are aware that if
>> we do not add %base-home-services to the existing home configuration,
>> fontconfig will change. I'm concerned about how the community will
>> react to this.
> As long as the out-of-the-box behaviour stays the same, the community
> has no reason to complain. For what it's worth, you could also leave
> fontconfig as an essential service, but then you get another field to
> configure.
>
> As far as I see, essential services are also a thing on the system
> side, but the home and system variants have a somewhat different feel
> to them. The fontconfig-service is not actually essential, the profile
> service type arguably isn't either (it acts as yet another profile and
> simultaneously fails to satisfy the multi-profile use-case; more on
> that elsewhere), the xdg-base-directories one notably violates the XDG
> Base Directories specification, and so on.

I was relieved to hear that.

Toggle quote (3 lines)
> I'd get Andrew's approval before moving services, but I'd move them in
> one go rather than bit by bit.

Noted. I'll wait for his reply.

Cheers,
--
Taiju
T
T
Taiju HIGASHI wrote on 7 Oct 2022 07:20
Next steps for this issue
(address . 57963@debbugs.gnu.org)
875ygwnr9t.fsf@taiju.info
Hi,

What are the next steps for this issue?

I recognize that the following work remains.

1. Review of the v5 patch
2. Consider which services to move from essentials services to base services
3. Modify Document

If I forgot to do something, please point it out.

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 7 Oct 2022 07:44
(address . 57963@debbugs.gnu.org)
87tu4gmbl3.fsf@taiju.info
Hi Liliana,

I'm sorry, I had the wrong email address.

Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (14 lines)
> Hi,
>
> What are the next steps for this issue?
>
> I recognize that the following work remains.
>
> 1. Review of the v5 patch
> 2. Consider which services to move from essentials services to base services
> 3. Modify Document
>
> If I forgot to do something, please point it out.
>
> Thanks,

--
Taiju
A
A
Andrew Tropin wrote on 10 Oct 2022 07:50
Re: [PATCH v4 1/2] home-services: Add base.
(address . 57963@debbugs.gnu.org)
874jwcdy73.fsf@trop.in
On 2022-10-02 16:59, Liliana Marie Prikler wrote:

Toggle quote (20 lines)
> Am Sonntag, dem 02.10.2022 um 22:45 +0900 schrieb Taiju HIGASHI:
>> > Like Liliana wrote, it may be that more of these can be moved from
>> > “essential” to “base”, we can keep that for a later patch.
>>
>> Please let us address this in a later patch.
>>
>> I would like to discuss something with you.
>> I'm aware that this patch is a breaking change. We are aware that if
>> we do not add %base-home-services to the existing home configuration,
>> fontconfig will change. I'm concerned about how the community will
>> react to this.
> As long as the out-of-the-box behaviour stays the same, the community
> has no reason to complain. For what it's worth, you could also leave
> fontconfig as an essential service, but then you get another field to
> configure.
>
> As far as I see, essential services are also a thing on the system
> side, but the home and system variants have a somewhat different feel
> to them.

Originially purpose was the same - to have services depending on
home-environment record fields (fontconfig depended on symlink-path
field, which was configurable back in the days), later we made
~/.guix-home hardcoded and did other changes to remove all the
dependencies for essential services from home-environment. Now the
purpose feels somewhat different, because it basically a good list of
default services, but not actually essential. The only thing, that
still depends on home-environment fields is home-profile-service-type.

Globally, I'm good with the reorganization of essential services, but
let's make another thread for this issue.

Toggle quote (11 lines)
> The fontconfig-service is not actually essential, the profile service
> type arguably isn't either (it acts as yet another profile and
> simultaneously fails to satisfy the multi-profile use-case; more on
> that elsewhere), the xdg-base-directories one notably violates the XDG
> Base Directories specification, and so on.
>
> I'd get Andrew's approval before moving services, but I'd move them in
> one go rather than bit by bit.
>
> Cheers

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNDsqAACgkQIgjSCVjB
3rAqEBAAiliL4I9yTGVH+IqLz7DEy427oqPu3sSH+xc+CZy9wz/5pUZH2ym5syJk
wsc6To00fLYl35vYhW8w43RpnpDQD6UKr4A/nht0792vdSdmMjI7l0EQsPYVgtKX
+33xuMkUsRw19+L4YHsFXZTY7vfNBwvyk8JZj8QR7T4mSa7qkGsUSRNsmIhlCHVT
pJbG2VBeNw/jguQvLRFjzqd4mYN6liM0jrtOLaK3IK/4trz7M1lalJxMY7Y5L0ai
GSLhhOWJfJ53T5EeE5EwNf4432zy+f76ILqQeThc3DWW7k/wlVahCswvzeft8x4g
nnmaKLNkX1iZf2KQMIwSFfrmL2aT07xPr9KFcLzG9aIgWbFm/QxCCmrgTue1vn6x
HPe0829qscxWepMOO9JbLUTC/H+mjY+d4XO6AmCMm67N4RrkR9a8A3O82IDLUfk0
sy2sDNYWX/VIMahdV7sBeYC//EO466NTFVSunnng0ywSNmpciUYzwZR3/B9WkQEt
kq11UquKYf1Tjf+zpuPH9PiizvVCkM/pDFaEgWw2WsY0Mgjcd7407pD4IbqtUHAU
KD8b/hLfelPm2n1p+DU4M5r/pylmGPQsJIa+IlGDXbX61G462eJ9RJ3+2TWBwspH
6gzW8l3qkaGwMst54lzDidyU5Tq09dos9LGbDGv0nuqKsyJLdhY=
=jS4A
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 10 Oct 2022 08:40
Re: [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
87zge4chb5.fsf@trop.in
On 2022-10-02 22:15, Taiju HIGASHI wrote:

Toggle quote (59 lines)
> * 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 <andrew@trop.in>
> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
> ;;;
> ;;; 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)))

Better to use list? here and in the other places, at least for the
consistency, but also for semantic meaning.

Toggle quote (35 lines)
> +
> +(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?).

Also, making multi-type fields is debatable, but isn't great IMO.

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")))

Toggle quote (11 lines)
> + ((? 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.

Toggle quote (26 lines)
> + "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"
> "<?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> -<fontconfig>
> - <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +<fontconfig>"
> + (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"))))

Toggle quote (14 lines)
> + "</fontconfig>\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.")))

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNDvl4ACgkQIgjSCVjB
3rCueA/+PBM5g/Qe3+91C8u4h+s/0Ot6D9VJhBDQRLEgNYPkFKHKQ4dqsR0WQVHC
QHpNmBlHp8cuh34q7UJ2YHMj+5MNzZK/iwekUu7eG0ioWTqTZe6dfVoq5ImPawgd
4f8CmcOFLRlmGD29EOjka9qkb7K8vHlBrOL3GBWiutLO7jmWgdlt3AcX6ehggqD7
8Jb5+aSwAcGl580RBMr/0SyTUqsvesyGjoRQn6T1AWZQI/2QRtYP6TAGlZ8TDbbr
tYTU7Mgcvw9WkxjfpwK4JU6kDvp9e1I9HzfjlPfCgALOeYmpCjUWIAOSaouyZxXX
JT5FmNXO+tY3Fra0SaD7CpyEF9JhtEnAgyPNECM35Ym/dP9mV/zaL4miZdJTC+Ef
2ItbOCHNU5LFWKXCOLLorKl+4D1o4Ux9csFrH9u/kHfxuZhJk8WKFW0IraMViXRN
u4TF432subComkGGyBkoe5egCahVmD6CwqpQI0YMhje5vppN6bdjp5oY94oBoLuL
MoibLZffrYmc4mTigrgzF7fA1+kg80Vm0SyOB3uVPgqokzXVJrp1vgRNVj2K0/NA
4Sq3hMPEknfLUgBktZI60C1OqFo6Eur1VAcq6DdOrJknpO2pd934gKveoFt39xcJ
sXz9YgeU0kEU68FEdDo7pS732O6WCz/Q5HNkuAXyp9e1YtPz6yY=
=ngCV
-----END PGP SIGNATURE-----

L
L
Liliana Marie Prikler wrote on 10 Oct 2022 18:15
(address . ludo@gnu.org)
c0d5bf21a99468571c7ba010e9eb9c329828dca8.camel@gmail.com
Am Montag, dem 10.10.2022 um 10:40 +0400 schrieb Andrew Tropin:
Toggle quote (5 lines)
> 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.
Actually, I think the default value should (if possible) explicitly
contain the one being added by Guix Home. I also think it shouldn't be
added when the user explicitly removed it.

Cheers
T
T
Taiju HIGASHI wrote on 11 Oct 2022 05:54
(name . Andrew Tropin)(address . andrew@trop.in)
87edvfkob8.fsf@taiju.info
Hi Andrew,

Thank you for your review!

Toggle quote (6 lines)
>> +(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.

Toggle snippet (4 lines)
(define (string-list? value)
(and (list? value) (every string? value)))

Toggle quote (39 lines)
>> +
>> +(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).

Toggle quote (2 lines)
> 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.

Toggle quote (8 lines)
> 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?

Toggle quote (24 lines)
>> + ((? 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.

Toggle quote (34 lines)
>> + "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"
>> "<?xml version='1.0'?>
>> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>> -<fontconfig>
>> - <dir>~/.guix-home/profile/share/fonts</dir>
>> -</fontconfig>"))))
>> +<fontconfig>"
>> + (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
L
L
Liliana Marie Prikler wrote on 11 Oct 2022 06:21
7a7ba84518d2f6afa387e1e2649bc249acd74750.camel@gmail.com
Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
Toggle quote (1 lines)
> We can specify invalid value such as (list "foo" '(foo bar) 123).
It will be sanitized before that.

Toggle quote (4 lines)
> > 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.
Prefer sexp-type.

Toggle quote (10 lines)
> > 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?
I think your serialize would have to unpack the G-Expressions. You can
test that with some example configs of your own.

Toggle quote (1 lines)
> >
Cheers
T
T
Taiju HIGASHI wrote on 11 Oct 2022 10:09
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87pmeykchl.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (4 lines)
> Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
>> We can specify invalid value such as (list "foo" '(foo bar) 123).
> It will be sanitized before that.

I'm sorry, I may not be getting it.

When I reconfigure with the following settings:

Toggle snippet (13 lines)
(home-environment
(packages (list font-google-noto))
(services
(append
(list
(service home-bash-service-type))
(modify-services %home-base-services
(home-fontconfig-service-type
config => (home-fontconfig-configuration
(extra-config
(list "<dir>foo</dir>" 123))))))))

The following error occurs.

Toggle snippet (39 lines)
./pre-inst-env guix home container home-fontconfig-config.scm
Backtrace:
In guix/monads.scm:
487:9 19 (_ _)
In gnu/services.scm:
1137:16 18 (_ _)
In guix/monads.scm:
487:9 17 (_ _)
In gnu/services.scm:
1140:36 16 (_ _)
In srfi/srfi-1.scm:
586:17 15 (map1 (#<<service> type: #<service-type home-fontconfig 7f1926abf…>))
In ice-9/eval.scm:
155:9 14 (_ #(#(#<directory (gnu home services fontutils) 7f1926df8780>) #))
159:9 13 (_ #(#(#<directory (gnu home services fontutils) 7f1926df8780>) #))
173:55 12 (_ #(#(#<directory (gnu home services fontutils) 7f1926df8780>) #))
In gnu/services/configuration.scm:
124:8 11 (serialize-configuration _ _)
In srfi/srfi-1.scm:
586:29 10 (map1 (#<<configuration-field> name: font-directories type: str…> …))
586:29 9 (map1 (#<<configuration-field> name: default-font-serif-family …> …))
586:29 8 (map1 (#<<configuration-field> name: default-font-sans-serif-fa…> …))
586:29 7 (map1 (#<<configuration-field> name: default-font-monospace-fam…> …))
586:17 6 (map1 (#<<configuration-field> name: extra-config type: maybe-ext…>))
In ice-9/eval.scm:
155:9 5 (_ #(#(#<directory (gnu home services fontutils) 7f1926df8780>) # …))
In srfi/srfi-1.scm:
586:29 4 (map1 ("<dir>foo</dir>" 123))
586:17 3 (map1 (123))
In unknown file:
2 (raise #<&formatted-message format: "'extra-config' type must be x…>)
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1685:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type (expecting exact integer): #<&formatted-message format: "'extra-config' type must be xml string or sxml list, was given: ~a\n" arguments: (("<dir>foo</dir>" 123))>

Is it sanitized before?

Toggle quote (6 lines)
>> > 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.
> Prefer sexp-type.

I too would like to write my settings in S-expression, but for users who
know the XML format of fontconfig but do not know how to use SXML, I
believe the effort of converting XML to SXML in their head and writing
it cannot be ignored.
Still, users can write settings in SXML and convert them to
strings. That is a choice the user prefers to make; someone who doesn't
know SXML writing strings and converting them to SXML is not a choice
the user prefers to make.

Toggle quote (13 lines)
>> > 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?
> I think your serialize would have to unpack the G-Expressions. You can
> test that with some example configs of your own.

Thank you. I'll give it a try.

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 11 Oct 2022 20:24
(name . Taiju HIGASHI)(address . higashi@taiju.info)
796ace856ca7ccb44fda2b15f8f7abc6990e53e0.camel@gmail.com
Am Dienstag, dem 11.10.2022 um 17:09 +0900 schrieb Taiju HIGASHI:
Toggle quote (80 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
> > > We can specify invalid value such as (list "foo" '(foo bar) 123).
> > It will be sanitized before that.
>
> I'm sorry, I may not be getting it.
>
> When I reconfigure with the following settings:
>
> --8<---------------cut here---------------start------------->8---
> (home-environment
>  (packages (list font-google-noto))
>  (services
>   (append
>       (list
>        (service home-bash-service-type))
>       (modify-services %home-base-services
>         (home-fontconfig-service-type
>          config => (home-fontconfig-configuration
>                     (extra-config
>                      (list "<dir>foo</dir>" 123))))))))
> --8<---------------cut here---------------end--------------->8---
>
> The following error occurs.
>
> --8<---------------cut here---------------start------------->8---
> ./pre-inst-env guix home container home-fontconfig-config.scm
> Backtrace:
> In guix/monads.scm:
>     487:9 19 (_ _)
> In gnu/services.scm:
>   1137:16 18 (_ _)
> In guix/monads.scm:
>     487:9 17 (_ _)
> In gnu/services.scm:
>   1140:36 16 (_ _)
> In srfi/srfi-1.scm:
>    586:17 15 (map1 (#<<service> type: #<service-type home-fontconfig
> 7f1926abf…>))
> In ice-9/eval.scm:
>     155:9 14 (_ #(#(#<directory (gnu home services fontutils)
> 7f1926df8780>) #))
>     159:9 13 (_ #(#(#<directory (gnu home services fontutils)
> 7f1926df8780>) #))
>    173:55 12 (_ #(#(#<directory (gnu home services fontutils)
> 7f1926df8780>) #))
> In gnu/services/configuration.scm:
>     124:8 11 (serialize-configuration _ _)
> In srfi/srfi-1.scm:
>    586:29 10 (map1 (#<<configuration-field> name: font-directories
> type: str…> …))
>    586:29  9 (map1 (#<<configuration-field> name: default-font-serif-
> family …> …))
>    586:29  8 (map1 (#<<configuration-field> name: default-font-sans-
> serif-fa…> …))
>    586:29  7 (map1 (#<<configuration-field> name: default-font-
> monospace-fam…> …))
>    586:17  6 (map1 (#<<configuration-field> name: extra-config type:
> maybe-ext…>))
> In ice-9/eval.scm:
>     155:9  5 (_ #(#(#<directory (gnu home services fontutils)
> 7f1926df8780>) # …))
> In srfi/srfi-1.scm:
>    586:29  4 (map1 ("<dir>foo</dir>" 123))
>    586:17  3 (map1 (123))
> In unknown file:
>            2 (raise #<&formatted-message format: "'extra-config' type
> must be x…>)
> In ice-9/boot-9.scm:
>   1685:16  1 (raise-exception _ #:continuable? _)
>   1685:16  0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Wrong type (expecting exact integer): #<&formatted-message format:
> "'extra-config' type must be xml string or sxml list, was given:
> ~a\n" arguments: (("<dir>foo</dir>" 123))>
> --8<---------------cut here---------------end--------------->8---
>
> Is it sanitized before?
That error seems to be coming from your sanitizer if I read this
correctly.

Toggle quote (15 lines)
> > > > 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.
> > Prefer sexp-type.
>
> I too would like to write my settings in S-expression, but for users
> who know the XML format of fontconfig but do not know how to use
> SXML, I believe the effort of converting XML to SXML in their head
> and writing it cannot be ignored.
> Still, users can write settings in SXML and convert them to
> strings. That is a choice the user prefers to make; someone who
> doesn't know SXML writing strings and converting them to SXML is not
> a choice the user prefers to make.
You can likewise convert xml->sxml explicitly, there's not really any
difference here. Providing this in a sanitizer just makes it more
user-friendly.

Cheers
T
T
Taiju HIGASHI wrote on 12 Oct 2022 05:59
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
875ygpk7zt.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (84 lines)
> Am Dienstag, dem 11.10.2022 um 17:09 +0900 schrieb Taiju HIGASHI:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>> > Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
>> > > We can specify invalid value such as (list "foo" '(foo bar) 123).
>> > It will be sanitized before that.
>>
>> I'm sorry, I may not be getting it.
>>
>> When I reconfigure with the following settings:
>>
>> --8<---------------cut here---------------start------------->8---
>> (home-environment
>>  (packages (list font-google-noto))
>>  (services
>>   (append
>>       (list
>>        (service home-bash-service-type))
>>       (modify-services %home-base-services
>>         (home-fontconfig-service-type
>>          config => (home-fontconfig-configuration
>>                     (extra-config
>>                      (list "<dir>foo</dir>" 123))))))))
>> --8<---------------cut here---------------end--------------->8---
>>
>> The following error occurs.
>>
>> --8<---------------cut here---------------start------------->8---
>> ./pre-inst-env guix home container home-fontconfig-config.scm
>> Backtrace:
>> In guix/monads.scm:
>>     487:9 19 (_ _)
>> In gnu/services.scm:
>>   1137:16 18 (_ _)
>> In guix/monads.scm:
>>     487:9 17 (_ _)
>> In gnu/services.scm:
>>   1140:36 16 (_ _)
>> In srfi/srfi-1.scm:
>>    586:17 15 (map1 (#<<service> type: #<service-type home-fontconfig
>> 7f1926abf…>))
>> In ice-9/eval.scm:
>>     155:9 14 (_ #(#(#<directory (gnu home services fontutils)
>> 7f1926df8780>) #))
>>     159:9 13 (_ #(#(#<directory (gnu home services fontutils)
>> 7f1926df8780>) #))
>>    173:55 12 (_ #(#(#<directory (gnu home services fontutils)
>> 7f1926df8780>) #))
>> In gnu/services/configuration.scm:
>>     124:8 11 (serialize-configuration _ _)
>> In srfi/srfi-1.scm:
>>    586:29 10 (map1 (#<<configuration-field> name: font-directories
>> type: str…> …))
>>    586:29  9 (map1 (#<<configuration-field> name: default-font-serif-
>> family …> …))
>>    586:29  8 (map1 (#<<configuration-field> name: default-font-sans-
>> serif-fa…> …))
>>    586:29  7 (map1 (#<<configuration-field> name: default-font-
>> monospace-fam…> …))
>>    586:17  6 (map1 (#<<configuration-field> name: extra-config type:
>> maybe-ext…>))
>> In ice-9/eval.scm:
>>     155:9  5 (_ #(#(#<directory (gnu home services fontutils)
>> 7f1926df8780>) # …))
>> In srfi/srfi-1.scm:
>>    586:29  4 (map1 ("<dir>foo</dir>" 123))
>>    586:17  3 (map1 (123))
>> In unknown file:
>>            2 (raise #<&formatted-message format: "'extra-config' type
>> must be x…>)
>> In ice-9/boot-9.scm:
>>   1685:16  1 (raise-exception _ #:continuable? _)
>>   1685:16  0 (raise-exception _ #:continuable? _)
>>
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> Wrong type (expecting exact integer): #<&formatted-message format:
>> "'extra-config' type must be xml string or sxml list, was given:
>> ~a\n" arguments: (("<dir>foo</dir>" 123))>
>> --8<---------------cut here---------------end--------------->8---
>>
>> Is it sanitized before?
> That error seems to be coming from your sanitizer if I read this
> correctly.

Yes, I think so. So I do not know what he meant when he said "Other
branches would never be visited."

Other branches would never be visited because it will fail earlier
by define-configuration predicate check for extra-config-list?
(which is basically list?).

I may have misunderstood the location of the code to which his comment
refers.

Toggle quote (19 lines)
>> > > > 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.
>> > Prefer sexp-type.
>>
>> I too would like to write my settings in S-expression, but for users
>> who know the XML format of fontconfig but do not know how to use
>> SXML, I believe the effort of converting XML to SXML in their head
>> and writing it cannot be ignored.
>> Still, users can write settings in SXML and convert them to
>> strings. That is a choice the user prefers to make; someone who
>> doesn't know SXML writing strings and converting them to SXML is not
>> a choice the user prefers to make.
> You can likewise convert xml->sxml explicitly, there's not really any
> difference here. Providing this in a sanitizer just makes it more
> user-friendly.

I believe the v5 patch currently does that. Do you think a multi-type
field is acceptable? Or do you think it is better to keep only the
SXML-type field?

Cheers,
--
Taiju
L
L
Liliana Marie Prikler wrote on 12 Oct 2022 06:21
(name . Taiju HIGASHI)(address . higashi@taiju.info)
0ead19bea58a05eccfe71d2d7035419bed33cf51.camel@gmail.com
Am Mittwoch, dem 12.10.2022 um 12:59 +0900 schrieb Taiju HIGASHI:
Toggle quote (105 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Dienstag, dem 11.10.2022 um 17:09 +0900 schrieb Taiju HIGASHI:
> > > Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> > >
> > > > Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju
> > > > HIGASHI:
> > > > > We can specify invalid value such as (list "foo" '(foo bar)
> > > > > 123).
> > > > It will be sanitized before that.
> > >
> > > I'm sorry, I may not be getting it.
> > >
> > > When I reconfigure with the following settings:
> > >
> > > --8<---------------cut here---------------start------------->8---
> > > (home-environment
> > >  (packages (list font-google-noto))
> > >  (services
> > >   (append
> > >       (list
> > >        (service home-bash-service-type))
> > >       (modify-services %home-base-services
> > >         (home-fontconfig-service-type
> > >          config => (home-fontconfig-configuration
> > >                     (extra-config
> > >                      (list "<dir>foo</dir>" 123))))))))
> > > --8<---------------cut here---------------end--------------->8---
> > >
> > > The following error occurs.
> > >
> > > --8<---------------cut here---------------start------------->8---
> > > ./pre-inst-env guix home container home-fontconfig-config.scm
> > > Backtrace:
> > > In guix/monads.scm:
> > >     487:9 19 (_ _)
> > > In gnu/services.scm:
> > >   1137:16 18 (_ _)
> > > In guix/monads.scm:
> > >     487:9 17 (_ _)
> > > In gnu/services.scm:
> > >   1140:36 16 (_ _)
> > > In srfi/srfi-1.scm:
> > >    586:17 15 (map1 (#<<service> type: #<service-type home-
> > > fontconfig
> > > 7f1926abf…>))
> > > In ice-9/eval.scm:
> > >     155:9 14 (_ #(#(#<directory (gnu home services fontutils)
> > > 7f1926df8780>) #))
> > >     159:9 13 (_ #(#(#<directory (gnu home services fontutils)
> > > 7f1926df8780>) #))
> > >    173:55 12 (_ #(#(#<directory (gnu home services fontutils)
> > > 7f1926df8780>) #))
> > > In gnu/services/configuration.scm:
> > >     124:8 11 (serialize-configuration _ _)
> > > In srfi/srfi-1.scm:
> > >    586:29 10 (map1 (#<<configuration-field> name: font-
> > > directories
> > > type: str…> …))
> > >    586:29  9 (map1 (#<<configuration-field> name: default-font-
> > > serif-
> > > family …> …))
> > >    586:29  8 (map1 (#<<configuration-field> name: default-font-
> > > sans-
> > > serif-fa…> …))
> > >    586:29  7 (map1 (#<<configuration-field> name: default-font-
> > > monospace-fam…> …))
> > >    586:17  6 (map1 (#<<configuration-field> name: extra-config
> > > type:
> > > maybe-ext…>))
> > > In ice-9/eval.scm:
> > >     155:9  5 (_ #(#(#<directory (gnu home services fontutils)
> > > 7f1926df8780>) # …))
> > > In srfi/srfi-1.scm:
> > >    586:29  4 (map1 ("<dir>foo</dir>" 123))
> > >    586:17  3 (map1 (123))
> > > In unknown file:
> > >            2 (raise #<&formatted-message format: "'extra-config'
> > > type
> > > must be x…>)
> > > In ice-9/boot-9.scm:
> > >   1685:16  1 (raise-exception _ #:continuable? _)
> > >   1685:16  0 (raise-exception _ #:continuable? _)
> > >
> > > ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> > > Wrong type (expecting exact integer): #<&formatted-message
> > > format:
> > > "'extra-config' type must be xml string or sxml list, was given:
> > > ~a\n" arguments: (("<dir>foo</dir>" 123))>
> > > --8<---------------cut here---------------end--------------->8---
> > >
> > > Is it sanitized before?
> > That error seems to be coming from your sanitizer if I read this
> > correctly.
>
> Yes, I think so.  So I do not know what he meant when he said "Other
> branches would never be visited."
>
>     Other branches would never be visited because it will fail
> earlier
>     by define-configuration predicate check for extra-config-list?
>     (which is basically list?).
>
> I may have misunderstood the location of the code to which his
> comment refers.
I think this basically means that you can't have a raw string, but only
a list of strings, which conflicts with how you distinguish xml and
sxml?

Toggle quote (28 lines)
> > > > > > 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.
> > > > Prefer sexp-type.
> > >
> > > I too would like to write my settings in S-expression, but for
> > > users
> > > who know the XML format of fontconfig but do not know how to use
> > > SXML, I believe the effort of converting XML to SXML in their
> > > head
> > > and writing it cannot be ignored.
> > > Still, users can write settings in SXML and convert them to
> > > strings. That is a choice the user prefers to make; someone who
> > > doesn't know SXML writing strings and converting them to SXML is
> > > not
> > > a choice the user prefers to make.
> > You can likewise convert xml->sxml explicitly, there's not really
> > any
> > difference here.  Providing this in a sanitizer just makes it more
> > user-friendly.
>
> I believe the v5 patch currently does that. Do you think a multi-type
> field is acceptable? Or do you think it is better to keep only the
> SXML-type field?
I think the field, once sanitized, should be SXML. I care little about
what happens before.

Cheers
A
A
Andrew Tropin wrote on 12 Oct 2022 08:05
(address . ludo@gnu.org)
87zge1mv97.fsf@trop.in
On 2022-10-10 18:15, Liliana Marie Prikler wrote:

Toggle quote (11 lines)
> Am Montag, dem 10.10.2022 um 10:40 +0400 schrieb Andrew Tropin:
>> 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.
> Actually, I think the default value should (if possible) explicitly
> contain the one being added by Guix Home. I also think it shouldn't be
> added when the user explicitly removed it.
>

Completely agree. Probably I had to be more explicit on the implication
of my comment.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGWUQACgkQIgjSCVjB
3rC0CQ/9EU30aFWBMMQCSTFJC/FnpUftnXg3HtPPG8fbVqL7ZfXJk71+KNiyuEcj
4sNrtJ46qATVv05l5/PzA9fvioshAY/yEj5MGesNlE2WVmmAFCR7LZucLijPDexu
OjEpAz/hrj9hXn+QWvD7Vj3Y3vZETzA8C+oaRe6X+hs2V8DF08yvUL1S2v/o4PeE
8mvCXYY+7Sa8jrphJjklWArBzr+OpR5yyyYqGEtDq1CVUPZMO1NoMWErcGl4fksv
PJuXSzkY5pCZGdVDWkQoDySitz+FzFaKzjGGvDLentK0gpisG1YL1rmkFhNsve8d
/xmCKvx2Us4lSI7NDqjo8FSxBx13r7GJwcbTpnP+K6ybjnvo/IJah0dXw2bGlHgt
hYOBDg3U+WktsDUTILLvBKSldK8LUMu52wZrjBDo+KM+H2vliMwv8DopQwvOOC+7
kfpn5dJaylG3MdA2Cu2Te5tqEeRL8MSZQtN5mDzJkpmDRXqtQyX3YJRVEaZLW1MU
1LkCg2OeuMKdneLUv4EyEpUsRF7vmX0MknRM7CHwgg6oFlIs1or0cuEHvMmj7Ob4
gMNFOyMWmWtVihD7Df3qqbuwQ/AWtgUbbKJboPF4QSMZhm9PYODzArpYs4AlD65m
im/aLHSv9t4VyMPOh7uG81EgRhWJIkvUoNLkKqXKw9Zoqb2KgRo=
=xw86
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 12 Oct 2022 08:43
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87wn95mtih.fsf@trop.in
On 2022-10-11 12:54, Taiju HIGASHI wrote:

Toggle quote (56 lines)
> 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?).

Oh, I missed the map over the list elements and slightly missread the
code. I thought (according to my incorrect perception of
implementation) extra-config have to be either sxml or string, that's is
why I said that it will fail earlier because plan string value won't
satisfy list predicate attached to extra-config field, but in a fact
extra-config is always a list, but can be a list of sxml's and strings
mixed together.

Thus, some of my comments are invalid. Sorry for the confusion. I'll
rephrase and elaborate in the later message.

Toggle quote (20 lines)
>
> 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?
>

It's not possible with the current implementation.

Toggle quote (22 lines)
>>> + ((? 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.
>

As Liliana mentioned in the other message, it's better not to set
anything implicitly. It's better to keep the name, but change the
implementation and remove implicitly and unconditionally added
directory.

Toggle quote (40 lines)
>>> + "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"
>>> "<?xml version='1.0'?>
>>> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>>> -<fontconfig>
>>> - <dir>~/.guix-home/profile/share/fonts</dir>
>>> -</fontconfig>"))))
>>> +<fontconfig>"
>>> + (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

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGYhYACgkQIgjSCVjB
3rAPzw/+L/OhOp1INFRdX4m/Qp+1BbEo5hyEKHOkDk4USdpe9Olky2izvkTU8ujH
aeZU2m/+TsbtleJaIENasmzpIVds8TrUdItwaECOxjhmyG+PbvBZyhXiBvmzKp3p
AdxvbYSU3AVlVGKETs5suyNCail9JuX9JkaTAJFWJPm6Xc9FqZwXUtvdGC9FW/5p
px+hLw0upj2h0ZmSuDU7q2LMQFk7Iehiwf4VkTNxedacx6a6FkYF9upk+j1k5o+U
2XntQxcEiCH4bHfrSte8WfBKuCQid2cHj2mYedGZ1NiSaTr59CNUb3ZL+/ABRxYc
oFiw2IIq7LbOpmJym33PITsVm1OMChLZQfaMldBMXxrndrxl7vHw333DDhxMjWyz
dZunfZsRuwqnmSG8oVmljPd243Cc0SVvDY6IDiGPIbFiwoYO5mYUAth1+mES8CS5
YJKgzgjXsTI97nSlZ4zPagnhD1wrOZzzbHqkhaPPzVV+lQue8yWiIxZDhPZ7WMDb
MnV4tVoVt5U1+Nz9pGmEmjFq+AX4IoHDZilvdLA5Vtgd3xklduyqca6LRRPrNLKn
DdtX9DDPcVxNaVeReJ0D7vpH8ZF47PZH7gUPpOsGv9V1746SsMGas5kp2PNTB3ST
KOfwDGBp8+qeHFH+gemFP/ht8GI1KAgNpQ07631r+4w1w5aFvdI=
=mzvN
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 12 Oct 2022 09:07
Almost plain SXML serializer
87pmexmsei.fsf@trop.in
On 2022-10-11 06:21, Liliana Marie Prikler wrote:

Toggle quote (11 lines)
> Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
>> We can specify invalid value such as (list "foo" '(foo bar) 123).
> It will be sanitized before that.
>
>> > 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.
> Prefer sexp-type.
>

Current (v5) extra-config has a list type. This list can contain strings
and nested lists, string elements are for raw XML, and list
elements are for SXML.

This is done I guess to support following use case:

Toggle snippet (9 lines)
(list "<tag>Already existing XML copied from existing .xml file, which
we don't want to rewrite to SXML.</tag>"
'((tag (@ (attr1 "value1")
(attr2 "value2"))
(nested "Part of the configuration defined with SXML")
(empty)))
"<another-tag>Maybe some other part of raw XML</another-tag>")

This way we can combine SXML with already existing raw XML.

Am I right?

Toggle quote (16 lines)
>> > 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?
> I think your serialize would have to unpack the G-Expressions. You can
> test that with some example configs of your own.
>
>> >
> Cheers

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGZ7UACgkQIgjSCVjB
3rACTxAAgofw7IrJ8T85rEom7ncoIF3E20jNhvDa34qXS2oxAzrqgCJpNNHDQZfM
t2V7RI+oqeliC0doWQTmz+gSlpbL4ilX8cFTr12fROE6wS5Mn9KQH2jeRtkGK8eC
lBj22I7wnnQHYP+5nJWvF0maPZdPU914kXcxBmFN1wJuf5k5uL3uwJf8hgAxLDG/
mkmBgQ/PLLLxgKmDcx/YVb9roPQHG9Tz6W7rbVsoWZy+1bCLYkZApUIXDALGb82w
0YQ3gkTia1E6cNEtEkrOaFGLO1UQPZyEj6S7DvRqkoSH90J/ShaI5gTUYGLdCMC2
+EFwVH9YGW4Sb9DF5V2oVuJyT5nc+NMtjG+InBcKBgRoTLwFHejjLoROBFfqj2bx
QmB3lDzXmWmt9QSonfMEBK8VUi89wsDrFkIxafATm7x42Ck7GodyrP8jW1wRx2+M
m6m0isQ3ykIojEr9bkWGSJw+eFqEh3qPjohwcgRSxphd0w0Z+597oy2CfciXxJzo
C0LY4lnFyfirasQ5fMG78FKunHQwjE++EW6BTmaRPzAjB7sE6CTbFcMPp4mx1iyU
HMQxAQWl9IkyrSOuYu8ZT2+jhPAkh0Dn4DzgmEjBj1MxU3E9HMorwDm+YBP79Qsk
S9Q1iHk5AmXr4ULXF0KkZUDGdh5bpFawWdwSAEScMmpWg53TE5E=
=uiRO
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 12 Oct 2022 13:38
Re: [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(name . Andrew Tropin)(address . andrew@trop.in)
87k055i864.fsf@taiju.info
Andrew Tropin <andrew@trop.in> writes:

Toggle quote (69 lines)
> On 2022-10-11 12:54, Taiju HIGASHI wrote:
>
>> 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?).
>
> Oh, I missed the map over the list elements and slightly missread the
> code. I thought (according to my incorrect perception of
> implementation) extra-config have to be either sxml or string, that's is
> why I said that it will fail earlier because plan string value won't
> satisfy list predicate attached to extra-config field, but in a fact
> extra-config is always a list, but can be a list of sxml's and strings
> mixed together.
>
> Thus, some of my comments are invalid. Sorry for the confusion. I'll
> rephrase and elaborate in the later message.

I was worried that I was the only one who did not understand the code I
wrote, but I've relieved to hear that it was a misunderstanding :)

Is it OK to have multiple data types (XML string and SXML list) in a
list?

Toggle quote (21 lines)
>> 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?
>>
>
> It's not possible with the current implementation.

I'll try to modify it so that it can support G-exps.

Toggle quote (27 lines)
>>>> + ((? 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.
>>
>
> As Liliana mentioned in the other message, it's better not to set
> anything implicitly. It's better to keep the name, but change the
> implementation and remove implicitly and unconditionally added
> directory.

OK. I'll modify the default value to an empty list and include
~/.guix-home/profile/share/fonts in the sample code in the
documentation.

Toggle quote (40 lines)
>>>> + "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"
>>>> "<?xml version='1.0'?>
>>>> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>>>> -<fontconfig>
>>>> - <dir>~/.guix-home/profile/share/fonts</dir>
>>>> -</fontconfig>"))))
>>>> +<fontconfig>"
>>>> + (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

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 12 Oct 2022 13:42
Re: Almost plain SXML serializer
(name . Andrew Tropin)(address . andrew@trop.in)
87a661i7zm.fsf@taiju.info
Andrew Tropin <andrew@trop.in> writes:

Toggle quote (31 lines)
> On 2022-10-11 06:21, Liliana Marie Prikler wrote:
>
>> Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
>>> We can specify invalid value such as (list "foo" '(foo bar) 123).
>> It will be sanitized before that.
>>
>>> > 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.
>> Prefer sexp-type.
>>
>
> Current (v5) extra-config has a list type. This list can contain strings
> and nested lists, string elements are for raw XML, and list
> elements are for SXML.
>
> This is done I guess to support following use case:
>
> (list "<tag>Already existing XML copied from existing .xml file, which
> we don't want to rewrite to SXML.</tag>"
> '((tag (@ (attr1 "value1")
> (attr2 "value2"))
> (nested "Part of the configuration defined with SXML")
> (empty)))
> "<another-tag>Maybe some other part of raw XML</another-tag>")
>
> This way we can combine SXML with already existing raw XML.
>
> Am I right?

You're right. The current implementation allows XML string and SXML
list in the list. Also, it can mix those.

Toggle quote (16 lines)
>>> > 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?
>> I think your serialize would have to unpack the G-Expressions. You can
>> test that with some example configs of your own.
>>
>>> >
>> Cheers

Thanks,
--
Taiju
A
A
Andrew Tropin wrote on 12 Oct 2022 14:41
Re: [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87a661mcyb.fsf@trop.in
On 2022-10-12 20:38, Taiju HIGASHI wrote:

Toggle quote (78 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
>> On 2022-10-11 12:54, Taiju HIGASHI wrote:
>>
>>> 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?).
>>
>> Oh, I missed the map over the list elements and slightly missread the
>> code. I thought (according to my incorrect perception of
>> implementation) extra-config have to be either sxml or string, that's is
>> why I said that it will fail earlier because plan string value won't
>> satisfy list predicate attached to extra-config field, but in a fact
>> extra-config is always a list, but can be a list of sxml's and strings
>> mixed together.
>>
>> Thus, some of my comments are invalid. Sorry for the confusion. I'll
>> rephrase and elaborate in the later message.
>
> I was worried that I was the only one who did not understand the code I
> wrote, but I've relieved to hear that it was a misunderstanding :)
>
> Is it OK to have multiple data types (XML string and SXML list) in a
> list?
>

I think it's not a great practice, I'll describe an alternative approach
in the other message.

Toggle quote (55 lines)
>>> 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?
>>>
>>
>> It's not possible with the current implementation.
>
> I'll try to modify it so that it can support G-exps.
>
>>>>> + ((? 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.
>>>
>>
>> As Liliana mentioned in the other message, it's better not to set
>> anything implicitly. It's better to keep the name, but change the
>> implementation and remove implicitly and unconditionally added
>> directory.
>
> OK. I'll modify the default value to an empty list and include
> ~/.guix-home/profile/share/fonts in the sample code in the
> documentation.
>

The default value is good, but the code, which always adds
~/.guix-home/profile/share/fonts to fontdirs is not.

Toggle snippet (6 lines)
+ (if (member guix-home-font-dir value)
+ value
+ (append (list guix-home-font-dir) value))


Toggle quote (44 lines)
>>>>> + "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"
>>>>> "<?xml version='1.0'?>
>>>>> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>>>>> -<fontconfig>
>>>>> - <dir>~/.guix-home/profile/share/fonts</dir>
>>>>> -</fontconfig>"))))
>>>>> +<fontconfig>"
>>>>> + (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
>
> Thanks,
> --
> Taiju

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGtewACgkQIgjSCVjB
3rBjhw/+PHqGEzKvXRkm8osF/xuxxOIclJUU2bi0N85/+9/KquL0QOlCf2QcxIS1
DHBrLEe6LCEgpqeQSVrsAxsMRs8wWDglPinafFtl3fbqqHdzVcOTs/xj5iZiYcew
thDUoUtXneAlfrKj7QONyd6aBaluhcG1fgRYKq9OXLQxwPD188vDjfIlQ6rflthk
A+umhNcrqX3QM34/shK8OzDwb7p+T33z/xy/dlzDlbwXGkpiFRE2/je1i5I8kP8q
oyXD33oBDuql4Z688btUqeWVfGFo17LUILFc237TDSaq70OsD3itjGbsRpykR/cw
F2OQNfjOYPx21T8p4rhlNUy6H7guy4s+vaqC1Fc+3lB0QMMinL5yTncC58BnDIiy
yKzBYDs+MssqK98cNHA2QurKtj+d0afhB8Eiqq7iDZ3iKQP7Ea8wkGGglGbev0hQ
U872q92rLjKsQxQrFHKQPpGLgGPJx183Bw+P4ARXgev3yj30+68R+HejOkOR9bAF
U2jKOO24oIMeALK8ASTzMDXLtxdAjyt2K5hwsc2QnoOarsUqHcVOkxjqyjGgPR9M
MV0VOg/DHQR3rn/Lcb1XOWjTwqm6GZnVLzZrVg/vuB611cGdHq/h+e+eiqiYa9xo
VUX9D9bjsrlWC+f/WQMMiodvdzLlLWmeyGP2t1CP4t4tsAakcw0=
=iXYB
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 12 Oct 2022 15:03
Re: Almost plain SXML serializer
(name . Taiju HIGASHI)(address . higashi@taiju.info)
874jw9mbxc.fsf@trop.in
On 2022-10-12 20:42, Taiju HIGASHI wrote:

Toggle quote (37 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
>> On 2022-10-11 06:21, Liliana Marie Prikler wrote:
>>
>>> Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju HIGASHI:
>>>> We can specify invalid value such as (list "foo" '(foo bar) 123).
>>> It will be sanitized before that.
>>>
>>>> > 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.
>>> Prefer sexp-type.
>>>
>>
>> Current (v5) extra-config has a list type. This list can contain strings
>> and nested lists, string elements are for raw XML, and list
>> elements are for SXML.
>>
>> This is done I guess to support following use case:
>>
>> (list "<tag>Already existing XML copied from existing .xml file, which
>> we don't want to rewrite to SXML.</tag>"
>> '((tag (@ (attr1 "value1")
>> (attr2 "value2"))
>> (nested "Part of the configuration defined with SXML")
>> (empty)))
>> "<another-tag>Maybe some other part of raw XML</another-tag>")
>>
>> This way we can combine SXML with already existing raw XML.
>>
>> Am I right?
>
> You're right. The current implementation allows XML string and SXML
> list in the list. Also, it can mix those.
>

Ok, that means we can cover this use case, but at the same time have
more functionality, clarity and consistency.

We can make extra-config to be SXML only (with G-exps support), this way
we will achieve not only the same functionality, but will get more
advanced features like referencing files/directiories in the /gnu/store
or generating parts of configuration using full-fledged scheme (the
simpliest example is just reading the content of the existing file-like
object or using format to generate "raw XML" and insert it in arbitrary
place of SXML tree).

Toggle snippet (13 lines)
(list #~"<tag>Already existing XML copied from existing .xml file, which
we don't want to rewrite to SXML.</tag>"
`((tag (@ (attr1 "value1")
(attr2 "value2"))
(nested "Part of the configuration defined with SXML")
,#~(format #f " <nested-tag>~a</nested-tag>" #$variable)
(fontdirs
(dirs ,(file-append font-iosevka "/share/fonts")))
(empty)))
#~(call-with-input-file #$(local-file "old.xml") get-string-all)
#~"<another-tag>Maybe some other part of raw XML</another-tag>")

Liliana, Ludo what do you think?

Toggle quote (18 lines)
>>>> > 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?
>>> I think your serialize would have to unpack the G-Expressions. You can
>>> test that with some example configs of your own.
>>>
>>>> >
>>> Cheers
>
> Thanks,

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNGux8ACgkQIgjSCVjB
3rByiw//ccD4PWgx5vOF9EsKb5sZfeDD4bYEPnV5O0LcAwT1ZcJd+NbfOIwbjAw1
3rsCiYnpfXZy2qcDd1fUO7w4e1lZDVzEBYBykrHAkaqLNE8acr4nSEutIE16fWK4
1AmoiFnLN0cE4XyYZNtuklDewflQ9jraS2emuWNpvKDOb+yAfx5aBQ0ZLadB3N4L
4fTVqQD0j/PCAbRJUW+sYGAaa+oRrJK+xNENEC8xXHIUFcXHny1S6C5I5SD4aBwx
PQLxTLHo7NwGqVQOsCT0Ar3ucRPeSVnrotwmooBJ7L2sWIuyvA3Ml61R+fJSD4FS
7QYfbsiXp2kQwNC9nQ1z2YgIW11DtM0ofUCwLqy5EoHwpVA9MaGP4nQyqGpRGfUq
YubY2YO3pvmdb7OrWZIsrKtRjRaAYZLEQ8TjGczSIpOJHDx5MhHCVxm5sHZXjudR
Cp+Sq98AiJNi8zQzCUb2gp/1ukOvZg/CBHT2Cx2Y+V7qcd/qsFsNYZEbvH/DJOw9
4lKurc1ULCUDEbeaqDDz/yjUHU/qHNlaopSSvCJW5Yb4AFOljLqkTgD4MHwCh8oZ
glA9FuxZFqLqIXeDCCJrz74rX/35GVyh+DYDnwI1MxENeWIvMNekuXsY2j5ad2bu
/5ODLsMLEjKK78dPuGLYJakEIioEbk6XiWo1/6r4jXrcmckLKUI=
=MX+m
-----END PGP SIGNATURE-----

L
L
Liliana Marie Prikler wrote on 12 Oct 2022 20:23
4e239948c075c47041a4ac1087b25de65a9172b3.camel@gmail.com
Am Mittwoch, dem 12.10.2022 um 17:03 +0400 schrieb Andrew Tropin:
Toggle quote (78 lines)
> On 2022-10-12 20:42, Taiju HIGASHI wrote:
>
> > Andrew Tropin <andrew@trop.in> writes:
> >
> > > On 2022-10-11 06:21, Liliana Marie Prikler wrote:
> > >
> > > > Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju
> > > > HIGASHI:
> > > > > We can specify invalid value such as (list "foo" '(foo bar)
> > > > > 123).
> > > > It will be sanitized before that.
> > > >
> > > > > > 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.
> > > > Prefer sexp-type.
> > > >
> > >
> > > Current (v5) extra-config has a list type.  This list can contain
> > > strings
> > > and nested lists, string elements are for raw XML, and list
> > > elements are for SXML.
> > >
> > > This is done I guess to support following use case:
> > >
> > > (list "<tag>Already existing XML copied from existing .xml file,
> > > which
> > > we don't want to rewrite to SXML.</tag>"
> > >       '((tag (@ (attr1 "value1")
> > >                 (attr2 "value2"))
> > >              (nested "Part of the configuration defined with
> > > SXML")
> > >              (empty)))
> > >       "<another-tag>Maybe some other part of raw XML</another-
> > > tag>")
> > >
> > > This way we can combine SXML with already existing raw XML.
> > >
> > > Am I right?
> >
> > You're right.  The current implementation allows XML string and
> > SXML
> > list in the list.  Also, it can mix those.
> >
>
> Ok, that means we can cover this use case, but at the same time have
> more functionality, clarity and consistency.
>
> We can make extra-config to be SXML only (with G-exps support), this
> way we will achieve not only the same functionality, but will get
> more advanced features like referencing files/directiories in the
> /gnu/store or generating parts of configuration using full-fledged
> scheme (the simpliest example is just reading the content of the
> existing file-like object or using format to generate "raw XML" and
> insert it in arbitrary place of SXML tree).
>
> --8<---------------cut here---------------start------------->8---
> (list #~"<tag>Already existing XML copied from existing .xml file,
> which
> we don't want to rewrite to SXML.</tag>"
>       `((tag (@ (attr1 "value1")
>                 (attr2 "value2"))
>              (nested "Part of the configuration defined with SXML")
>              ,#~(format #f "    <nested-tag>~a</nested-tag>"
> #$variable)
>              (fontdirs
>               (dirs ,(file-append font-iosevka "/share/fonts")))
>              (empty)))
>       #~(call-with-input-file #$(local-file "old.xml") get-string-
> all)
>       #~"<another-tag>Maybe some other part of raw XML</another-
> tag>")
> --8<---------------cut here---------------end--------------->8---
>
> Liliana, Ludo what do you think?
I think the mockup implementation is a little unclear. Do you mean
that G-Expressions should imply a string that is to be parsed? Because
note that gexp->sexp exists and you could likewise #~(sxml->xml #$some-
file-in-the-store) imho.

Cheers
A
A
Andrew Tropin wrote on 13 Oct 2022 05:51
875ygoe5yw.fsf@trop.in
On 2022-10-12 20:23, Liliana Marie Prikler wrote:

Toggle quote (81 lines)
> Am Mittwoch, dem 12.10.2022 um 17:03 +0400 schrieb Andrew Tropin:
>> On 2022-10-12 20:42, Taiju HIGASHI wrote:
>>
>> > Andrew Tropin <andrew@trop.in> writes:
>> >
>> > > On 2022-10-11 06:21, Liliana Marie Prikler wrote:
>> > >
>> > > > Am Dienstag, dem 11.10.2022 um 12:54 +0900 schrieb Taiju
>> > > > HIGASHI:
>> > > > > We can specify invalid value such as (list "foo" '(foo bar)
>> > > > > 123).
>> > > > It will be sanitized before that.
>> > > >
>> > > > > > 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.
>> > > > Prefer sexp-type.
>> > > >
>> > >
>> > > Current (v5) extra-config has a list type.  This list can contain
>> > > strings
>> > > and nested lists, string elements are for raw XML, and list
>> > > elements are for SXML.
>> > >
>> > > This is done I guess to support following use case:
>> > >
>> > > (list "<tag>Already existing XML copied from existing .xml file,
>> > > which
>> > > we don't want to rewrite to SXML.</tag>"
>> > >       '((tag (@ (attr1 "value1")
>> > >                 (attr2 "value2"))
>> > >              (nested "Part of the configuration defined with
>> > > SXML")
>> > >              (empty)))
>> > >       "<another-tag>Maybe some other part of raw XML</another-
>> > > tag>")
>> > >
>> > > This way we can combine SXML with already existing raw XML.
>> > >
>> > > Am I right?
>> >
>> > You're right.  The current implementation allows XML string and
>> > SXML
>> > list in the list.  Also, it can mix those.
>> >
>>
>> Ok, that means we can cover this use case, but at the same time have
>> more functionality, clarity and consistency.
>>
>> We can make extra-config to be SXML only (with G-exps support), this
>> way we will achieve not only the same functionality, but will get
>> more advanced features like referencing files/directiories in the
>> /gnu/store or generating parts of configuration using full-fledged
>> scheme (the simpliest example is just reading the content of the
>> existing file-like object or using format to generate "raw XML" and
>> insert it in arbitrary place of SXML tree).
>>
>> --8<---------------cut here---------------start------------->8---
>> (list #~"<tag>Already existing XML copied from existing .xml file,
>> which
>> we don't want to rewrite to SXML.</tag>"
>>       `((tag (@ (attr1 "value1")
>>                 (attr2 "value2"))
>>              (nested "Part of the configuration defined with SXML")
>>              ,#~(format #f "    <nested-tag>~a</nested-tag>"
>> #$variable)
>>              (fontdirs
>>               (dirs ,(file-append font-iosevka "/share/fonts")))
>>              (empty)))
>>       #~(call-with-input-file #$(local-file "old.xml") get-string-
>> all)
>>       #~"<another-tag>Maybe some other part of raw XML</another-
>> tag>")
>> --8<---------------cut here---------------end--------------->8---
>>
>> Liliana, Ludo what do you think?
> I think the mockup implementation is a little unclear.

The file generated from definition above should look like:
Toggle snippet (16 lines)
<tag>Already existing XML copied from existing .xml file, which we don't want to rewrite to SXML.</tag>
<tag attr1="value1"
attr2="value2">
<nested>Text node</nested>
<nested-tag>variable value here</nested-tag>
<fontdirs>
<dirs>
/gnu/store/w2wvg2229lj3qba0r44pmd786mkllvjl-font-iosevka-15.2.0/share/fonts
</dirs>
</fontdirs>
<empty/>
</tag>
<!-- the literal content of old.xml file here -->
<another-tag>Maybe some other part of raw XML</another-tag>

Hope it helps, let me know if you want me to rephrase or clarify
something.

Toggle quote (4 lines)
> Do you mean that G-Expressions should imply a string that is to be
> parsed? Because note that gexp->sexp exists and you could likewise
> #~(sxml->xml #$some- file-in-the-store) imho.

Not sure what you mean. Can you elaborate, please?

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNHi0cACgkQIgjSCVjB
3rBGJQ/+ItF65K+KBzlbNOK7obqzx4lPDPAYySYvwWW/lOyDpseiCSpM2dly+bAc
LuxoIB7Fa5/00hkCla+zobJurKekvLPEcvf6aDaYJMAXcvtkoWXFnWta3ikh+zYD
VImbcPUCIIeJ03JvpL8+KMKWq2GNeVvUiUCyzhhJTqB5na5eZ6p9EKUiHFExIcKe
mXA4je1XjZ/1DcEEIemrOfce1p2/h3uoJ7Oft+qgyUgNUXDkHZFhV7T7q0Y9/qkt
J883T9L+XLbkTVYMbtUnddK4rq0jTFUaZBnqMQxgh4vQewU7NswuaNM0Qyjjk3+W
1GIunVqaHqapOMKSp5KA5SeatyxfqpXL32//fh1J5aoXLpUmOOozuN75V+PcirWp
xkJEgmH/q6t3ZiXy5OH6yuR2S2vBJtCF5EzrF2+oJV4cu3yiC8xsef+Q35kRXriv
KSGX8z/M/C/6qBMLjNpwdmgAAs7vycl3ToD0l8yV/vSgNwOCRhsAL1M7NjtIOwIP
L+WSYKSoaeNWyI2NPHdc5wE+73Tyry8Sp8/z9tBcyIkbusWiabEQSFSX4Vn40ndY
xP/2ZY42l/N4Ifge6oSE5FfdQWsd28X2Iqbz88Vci8uZRtui4SBl/rmWB+zoWLxD
QoEgagpk4Ka2QEYuRXxNU3CMYBE0kL8QutY1RRGwguLwKbSB9AA=
=f3Pk
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 13 Oct 2022 14:37
Re: [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(name . Andrew Tropin)(address . andrew@trop.in)
87k053sxur.fsf@gnu.org
Hello,

Andrew Tropin <andrew@trop.in> skribis:

Toggle quote (4 lines)
> If serialization would support G-exps, we could write
>
> (list #~"RAW_XML_HERE")

There’s a one-to-one lossless mapping between XML and SXML, so I don’t
think it makes sense to support XML-in-strings when we have SXML.

The only thing it would give us, as I see it, is the ability to generate
syntactically-invalid XML. Maybe we can live without it? :-)

Thanks,
Ludo’.
A
A
Andrew Tropin wrote on 14 Oct 2022 07:06
Re: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87zgdzat99.fsf@trop.in
On 2022-10-13 14:37, Ludovic Courtès wrote:

Toggle quote (14 lines)
> Hello,
>
> Andrew Tropin <andrew@trop.in> skribis:
>
>> If serialization would support G-exps, we could write
>>
>> (list #~"RAW_XML_HERE")
>
> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
> think it makes sense to support XML-in-strings when we have SXML.
>
> The only thing it would give us, as I see it, is the ability to generate
> syntactically-invalid XML. Maybe we can live without it? :-)

Of course we can :), but we won't be able:

1. To take already existing xml config and use it without rewriting.

2. Use full path to gnu store of file-like objects.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmNI7mIACgkQIgjSCVjB
3rC1fhAAj3ZZm1jXqI9Iqkn2tRywvyBLBmsJjcZJSQibDCAk5jV1g8e0J22NhXAb
0Vs5CLt0hYS5WztRl2l55RtXPjG59fPwLQqWzENlAF0/RRXJlyRF4iLGkZTKnp6q
0taYR8IzQtwrU0SHNnTtNKjEEcnRyUutivAUMfc4GPMJgrDCF4YHtpLaeR2sj/X2
rPYgN2+nryZlkmKI4TWoZzBwo2beVtTKKtV+s+DMZPEPdrBpeY4fmJaT0LXfJMdT
3oiDGYGmgahmNjrRSMS9eh9SdihLpjVPltB83/nDDaSUPN9XK2kWdxM8RkWmfM6O
wXzuMf0iupn4IQpeWNCGC6ARggCBf/wgWA9Pv771+TN1lrEskbORM1/+ncf+FTUs
5WZGxJF0bSGWYnkRGW9VdHFwN18bKCkANXmeC+9Kj1udGsWkXXrqmskT5a1YP77p
SQfBRlyV5YJ2j1Rovw6vEN9TPCpuY66y+3URewwuLBZOsRWc4GMPYjG7vfiiDMj1
gyl8IlMM4xnJcBfJV9lQYzq3B/xMLAmP2ircbSt2t9Zxun0Xe+nAwDR88TUs5eXz
0JyA9HrXYZ6xpkWlkR+Cqlf3yCtuWgJeXsjnY0ejsx+hrHlgrPKiDhc2Uykx4g/3
yg+JzYkPFr9jtb3tOgX39dMVeiRj6t0GD+NPMWCxozaXXJuxi/s=
=CxsF
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 15 Oct 2022 13:13
(name . Andrew Tropin)(address . andrew@trop.in)
87zgdxgx0l.fsf@taiju.info
Andrew Tropin <andrew@trop.in> writes:

Toggle quote (20 lines)
> On 2022-10-13 14:37, Ludovic Courtès wrote:
>
>> Hello,
>>
>> Andrew Tropin <andrew@trop.in> skribis:
>>
>>> If serialization would support G-exps, we could write
>>>
>>> (list #~"RAW_XML_HERE")
>>
>> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
>> think it makes sense to support XML-in-strings when we have SXML.
>>
>> The only thing it would give us, as I see it, is the ability to generate
>> syntactically-invalid XML. Maybe we can live without it? :-)
>
> Of course we can :), but we won't be able:
>
> 1. To take already existing xml config and use it without rewriting.

I find it surprisingly important to be able to simply copy and paste
settings without having to rewrite existing settings or those listed on
a web page somewhere. I know we can easily convert from XML to SXML,
but those unfamiliar with SXML may find it a bothering task.

Toggle quote (2 lines)
> 2. Use full path to gnu store of file-like objects.

Thanks,
--
Taiju
L
L
Ludovic Courtès wrote on 17 Oct 2022 18:28
(name . Taiju HIGASHI)(address . higashi@taiju.info)
875ygiqur9.fsf@gnu.org
Hi,

Taiju HIGASHI <higashi@taiju.info> skribis:

Toggle quote (2 lines)
> Andrew Tropin <andrew@trop.in> writes:

[...]

Toggle quote (21 lines)
>>> Andrew Tropin <andrew@trop.in> skribis:
>>>
>>>> If serialization would support G-exps, we could write
>>>>
>>>> (list #~"RAW_XML_HERE")
>>>
>>> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
>>> think it makes sense to support XML-in-strings when we have SXML.
>>>
>>> The only thing it would give us, as I see it, is the ability to generate
>>> syntactically-invalid XML. Maybe we can live without it? :-)
>>
>> Of course we can :), but we won't be able:
>>
>> 1. To take already existing xml config and use it without rewriting.
>
> I find it surprisingly important to be able to simply copy and paste
> settings without having to rewrite existing settings or those listed on
> a web page somewhere. I know we can easily convert from XML to SXML,
> but those unfamiliar with SXML may find it a bothering task.

OK, that makes sense.

But then, let’s not allow users to intersperse XML-in-strings in the
middle of XML. It should be either a user-provided file/string or the
generated config, but not a mixture of both; that’d be a recipe for
confusion.

How about this: the service takes either a <fontconfig-configuration>
record or a file-like object?

(We can even have a “gexp compiler” for <fontconfig-configuration> to
make that transparent.)

Thanks,
Ludo’.
T
T
Taiju HIGASHI wrote on 18 Oct 2022 14:41
(name . Ludovic Courtès)(address . ludo@gnu.org)
87r0z5e23k.fsf@taiju.info
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (42 lines)
> Hi,
>
> Taiju HIGASHI <higashi@taiju.info> skribis:
>
>> Andrew Tropin <andrew@trop.in> writes:
>
> [...]
>
>>>> Andrew Tropin <andrew@trop.in> skribis:
>>>>
>>>>> If serialization would support G-exps, we could write
>>>>>
>>>>> (list #~"RAW_XML_HERE")
>>>>
>>>> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
>>>> think it makes sense to support XML-in-strings when we have SXML.
>>>>
>>>> The only thing it would give us, as I see it, is the ability to generate
>>>> syntactically-invalid XML. Maybe we can live without it? :-)
>>>
>>> Of course we can :), but we won't be able:
>>>
>>> 1. To take already existing xml config and use it without rewriting.
>>
>> I find it surprisingly important to be able to simply copy and paste
>> settings without having to rewrite existing settings or those listed on
>> a web page somewhere. I know we can easily convert from XML to SXML,
>> but those unfamiliar with SXML may find it a bothering task.
>
> OK, that makes sense.
>
> But then, let’s not allow users to intersperse XML-in-strings in the
> middle of XML. It should be either a user-provided file/string or the
> generated config, but not a mixture of both; that’d be a recipe for
> confusion.
>
> How about this: the service takes either a <fontconfig-configuration>
> record or a file-like object?
>
> (We can even have a “gexp compiler” for <fontconfig-configuration> to
> make that transparent.)

Thank you for your consideration.

That idea sounds good. I don't know if I can successfully implement
this, but I will consider it and give it a try.

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 19 Oct 2022 23:42
(name . Ludovic Courtès)(address . ludo@gnu.org)
87czanebhd.fsf@taiju.info
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (53 lines)
> Hi,
>
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hi,
>>
>> Taiju HIGASHI <higashi@taiju.info> skribis:
>>
>>> Andrew Tropin <andrew@trop.in> writes:
>>
>> [...]
>>
>>>>> Andrew Tropin <andrew@trop.in> skribis:
>>>>>
>>>>>> If serialization would support G-exps, we could write
>>>>>>
>>>>>> (list #~"RAW_XML_HERE")
>>>>>
>>>>> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
>>>>> think it makes sense to support XML-in-strings when we have SXML.
>>>>>
>>>>> The only thing it would give us, as I see it, is the ability to generate
>>>>> syntactically-invalid XML. Maybe we can live without it? :-)
>>>>
>>>> Of course we can :), but we won't be able:
>>>>
>>>> 1. To take already existing xml config and use it without rewriting.
>>>
>>> I find it surprisingly important to be able to simply copy and paste
>>> settings without having to rewrite existing settings or those listed on
>>> a web page somewhere. I know we can easily convert from XML to SXML,
>>> but those unfamiliar with SXML may find it a bothering task.
>>
>> OK, that makes sense.
>>
>> But then, let’s not allow users to intersperse XML-in-strings in the
>> middle of XML. It should be either a user-provided file/string or the
>> generated config, but not a mixture of both; that’d be a recipe for
>> confusion.
>>
>> How about this: the service takes either a <fontconfig-configuration>
>> record or a file-like object?
>>
>> (We can even have a “gexp compiler” for <fontconfig-configuration> to
>> make that transparent.)
>
> Thank you for your consideration.
>
> That idea sounds good. I don't know if I can successfully implement
> this, but I will consider it and give it a try.
>
> Thanks,

I'm trying to implement the following, is it consistent with the intent
of what you suggested?

Toggle snippet (13 lines)
(define (add-fontconfig-config-file user-config)
`(("fontconfig/fonts.conf"
,(if (home-fontconfig-configuration? user-config)
(mixed-text-file
"fonts.conf"
"<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>"
(serialize-configuration user-config home-fontconfig-configuration-fields)
"</fontconfig>\n")
user-config))))

It is assumed that configurations can be specified in one of the
following ways.

* fontconfig-configuration:

Toggle snippet (18 lines)
(home-environment
(packages (list font-google-noto))
(services
(append
(list
(service home-bash-service-type))
(modify-services %home-base-services
(home-fontconfig-service-type
config => (home-fontconfig-configuration
(font-directories
(cons* "~/fonts" %home-fontconfig-base-font-directories))
(default-font-serif-family "Noto Serif CJK JP")
(default-font-sans-serif-family "Noto Sans Serif CJK JP")
(default-font-monospace-family "PlemolJP Console")
(extra-config
'(foo "bar"))))))))

Note:
%home-fontconfig-base-font-directories is the new variable I plan to
export as the default value, based on Andrew's and Liliana's point.

* file-like objects:

Toggle snippet (11 lines)
(home-environment
(packages (list font-google-noto))
(services
(append
(list
(service home-bash-service-type))
(modify-services %home-base-services
(home-fontconfig-service-type
config => (local-file "/path/to/your/fonts.conf"))))))

Thanks,
--
Taiju
D
D
Declan Tsien wrote on 20 Oct 2022 03:23
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87o7u7e1ai.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (4 lines)
> (default-font-serif-family "Noto Serif CJK JP")
> (default-font-sans-serif-family "Noto Sans Serif CJK JP")
> (default-font-monospace-family "PlemolJP Console")

Does this take a list as value? Because I have specified some fallback fonts in my configuration.
I directly use sxml to serialize the config file right now. Below is a portion of it.

It would be great if I could use this home-service without writing extra sxml code once it gets merged.

#+begin_src scheme
(alias (@ (binding "strong"))
(family "sans-serif")
(prefer
(family "WenQuanYi Micro Hei")
(family "Noto Sans")))

(alias (@ (binding "strong"))
(family "monospace")
(prefer
(family "Sarasa Mono CL")
(family "Inconsolata")
(family "Noto Mono")))
#+end_src
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNQovUXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vUbVgv/U1xHJ6dMuyZc0T1O0uV5mSNr
9KndwGd3BiOJndmNyFvriePC6fnKJIkdbzL8Ts1B/gUHDGbeeGp+rUkXdpXqRUUb
ZNLrB+CzSoI+ezLaZz6RClFX8BqjTwXxu2Gr9xuCPv9kw7SSwGBSeS84BwHfdHBU
JR6jQh4ECb+XS3T4FavvQJNSklAp2gPvCNe8Pzi5JsrQCUzNR53cptfZqLQyw553
7i4e+7y/Hr9Y2nOje8aAiIbkn8MvwhVfNdwWbE4J5MElFPcvNqNvAA+1Dsc9e7tY
qX7UHVqhCllPXzpfdY5rWU2LgWd+WmPw9+UrdC2ytl2bLvtCCyeFgh8oSSm+OeZE
9BJ1GBVz3c3zT1txeB6w1dGjQFlBcDTZcgkKZArFTJ0+WoN52W9zGfqu1DgEFKPp
fPmqTqUOeOhGt4lnm4ZcbcOI/7BVZeUMoLr/CRJNZyXE5jk596gofWjxvZSJcJcP
FH/BOO2cSYcU+1jUCO3xm4+lWFeXK6239Ri3RUqM
=siHZ
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 20 Oct 2022 03:37
(name . Declan Tsien)(address . declantsien@riseup.net)
87wn8vcm1y.fsf@taiju.info
Hi Declan,

Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (27 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>> (default-font-serif-family "Noto Serif CJK JP")
>> (default-font-sans-serif-family "Noto Sans Serif CJK JP")
>> (default-font-monospace-family "PlemolJP Console")
>
> Does this take a list as value? Because I have specified some fallback fonts in my configuration.
> I directly use sxml to serialize the config file right now. Below is a portion of it.
>
> It would be great if I could use this home-service without writing extra sxml code once it gets merged.
>
> #+begin_src scheme
> (alias (@ (binding "strong"))
> (family "sans-serif")
> (prefer
> (family "WenQuanYi Micro Hei")
> (family "Noto Sans")))
>
> (alias (@ (binding "strong"))
> (family "monospace")
> (prefer
> (family "Sarasa Mono CL")
> (family "Inconsolata")
> (family "Noto Mono")))
> #+end_src
>

That makes sense.
I thought that being able to specify one preferred font would be
sufficient, but since actual fontconfig allows multiple specification, I
thought it would certainly be better to be able to specify more than one
in this setting as well.
By the way, should we be able to specify the binding attribute as well?

Best Regards,
--
Taiju
D
D
Declan Tsien wrote on 20 Oct 2022 04:03
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87czan45fs.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (4 lines)
>
> By the way, should we be able to specify the binding attribute as well?
>

I checked the fontconfig doc.
Here is the relevant portation:

Toggle quote (7 lines)
> There is one special case to this rule; family names are split into
> two bindings; strong and weak. Strong family names are given greater
> precedence in the match than lang elements while weak family names are
> given lower precedence than lang elements. This permits the document
> language to drive font selection when any document specified font is
> unavailable.

I guess it's ok to ignore or set a default =strong= when serializing?
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNQrHcXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vW9Tgv/YTzV9CfjNztURy7uEDXeTzHv
qEr3aFUxqB8g2fmdGKgPNTOdGjh8BHMvuEoGKJQrnQ7C5m7M81VjNioVMX1F5lFv
RYQ6lx9Vp9c0TljMKWLoPp+j0Fv2NUGd0af0sgmj6chsbY5jGt6ftbfXAMezeupU
o9cu/H3nUE5QbMNBGJwWUkNJ8ycrouajEeCrdLuAtvZ5TwJ0XLq+CSk38SnLhtGW
8J5B7mF05MclsfIwZGitYs2br/QAysOCo9MorbMPRpFG992gRRHsssYKLji6RGGq
k83n0VfFjCfDJ1dyHD1/+UkDlBFRRxCQCyo1dl2MlG5wekRM9F3ANZnyxdJo4cyh
PvoN+k50VvwYHRbuTx0ibmjQVWJWFJ6y5sb+6KzBpaeydHMN8oV1hNCjFi9bxeDL
MfkQSQDmwC1JYBQOLwhMg4gdcDRLVBmKDBwXPZuXIqbCx8qEY5EMZ26NVDRZZjUy
kP2u1roa0rgsWLBBLDIKq+hAdCcwzzsraqfuu1Kg
=5fmb
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 20 Oct 2022 05:44
(name . Declan Tsien)(address . declantsien@riseup.net)
87zgdrb1lq.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (20 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>>
>> By the way, should we be able to specify the binding attribute as well?
>>
>
> I checked the fontconfig doc.
> https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
> Here is the relevant portation:
>
>> There is one special case to this rule; family names are split into
>> two bindings; strong and weak. Strong family names are given greater
>> precedence in the match than lang elements while weak family names are
>> given lower precedence than lang elements. This permits the document
>> language to drive font selection when any document specified font is
>> unavailable.
>
> I guess it's ok to ignore or set a default =strong= when serializing?
>

If you put the setting below,

Toggle snippet (6 lines)
(home-fontconfig-configuration
(default-font-serif-family "Noto Serif CJK JP")
(default-font-sans-serif-family "Noto Sans Serif CJK JP")
(default-font-monospace-family "PlemolJP Console"))

The current implementation serializes below.

Toggle snippet (24 lines)
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.guix-home/profile/share/fonts</dir>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif CJK JP</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans Serif CJK JP</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>PlemolJP Console</family>
</prefer>
</alias>
</fontconfig>

Since the binding attribute is omitted, it would be interpreted as the
default weak.

I would like the default-font-* fields to cover only typical settings.
Instead, we provide extra-config field to be used for settings that are
not typical.

You can also configure the settings you want by specifying them in
extra-config.

Toggle snippet (15 lines)
(home-fontconfig-configuration
(extra-config
'((alias (@ (binding "strong"))
(family "sans-serif")
(prefer
(family "WenQuanYi Micro Hei")
(family "Noto Sans")))
(alias (@ (binding "strong"))
(family "monospace")
(prefer
(family "Sarasa Mono CL")
(family "Inconsolata")
(family "Noto Mono"))))))

I don't see clearly what the typical configuration of alias should be,
but I believe the current specification is sufficient for our needs.

Do you still think it is preferable to change the default-font-* field
interface, even knowing that you can configure it in the extra-config
field? Please give me your frank opinion :)

Thanks,
--
Taiju
D
D
Declan Tsien wrote on 20 Oct 2022 07:06
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87fsfj84p0.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (5 lines)
>
> You can also configure the settings you want by specifying them in
> extra-config.
>

Oh, nice. So my use case is covered. Didn't realize that. Nice work.

Toggle quote (9 lines)
>
> I don't see clearly what the typical configuration of alias should be,
> but I believe the current specification is sufficient for our needs.
>
> Do you still think it is preferable to change the default-font-* field
> interface, even knowing that you can configure it in the extra-config
> field? Please give me your frank opinion :)
>

Let's stick to the current specification, no changes needed. Cheers.

Thanks
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNQ1zwXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vV9RQv9HHPzEG/6yZMeeatNNrvFXnh6
91gD4o62goMe2+QtaGAnagvMbmDumxP/7caeojKl/kZOWxjgNzXyRz6EOkUPHXZy
fctlvWbM1jpAbAugrKpTZHuk329KKvK4fuDvpkdKNgVdJ4N/xgF5O79l2LjEpYdy
oT64ZAusRv58L1S+I24KgLmZ1Gbcud3TwsuBZd4UK8nPcpDcxxb8iiITs39hTqKS
+J602JKw3hmj2Tngi4Hdt3jxz49zyoFxW5sUo2LAVDRZojh1DEk/948+YYQ787hw
OWp0+82lnPT3e6x5WgQpwJkvf5a3DRdcUUV1VLiwvlVvyqk3F5lVHpaqvDOv5E3H
ZsgiquD1AlxONt0xtiscdKtcSs3nbWIKvq9uyIEK5FXWbG+A3gpNAudr0IjtZUkR
r6vAx/fWqJUVHusOMaEaRVGr1JKvMApzUox+RxnS+F5kLaIlRteIdzNIu4MlbB7s
RgTTS5m3ZM6RDMtvom3GmES8chOMGzeIOUa2ydUG
=zNoA
-----END PGP SIGNATURE-----

D
D
Declan Tsien wrote on 20 Oct 2022 07:40
Re: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(address . 57963@debbugs.gnu.org)
875ygf3ve6.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (12 lines)
> @@ -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

Do we also have support service extension here? like this.

#+begin_src scheme
(compose identity)
(extend home-fontconfig-extensions)
(default-value (home-fontconfig-configuration))
#+end_src
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNQ31EXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vVThQwAmDBuz7kxR/ODEezsmu1hCCmf
dawNEX3fFe9IQDPt7jUrwmSKaqOzYEc/WpnRlH39wKtsI6V8meIDd0vWVFUNjdPk
tBs70y2Ip4/g7/62K8Tj9NraZZwaOq+ZFlsLofF1PlyowS6ushfKXyVc3jfG4z8V
/PSA1eO8nuGLMCal7/ADTU8ngcxbuEcEiKEk5C+txXjbktc4lKz4e6sVNcS8ScZd
xM+ZV6+7ijkyGH/OcG1iyhJ3IvQmYKBA8eIQqEC2w8Ns1q4nuN5NeLqyDvudVe5g
ccPkKulAYBOeLy25LmkYzPod5EQrlDRQOeswy9ujixwsDGsEnczKceirnwXHPHJ4
O2Fiy4ReBtxzBZ6GJFfehZStGjtMs40qVCsMtUp4LhU1b7udgk8KUTaGBJLJqTZe
vagoZxCBfB5Dfy/qcTA4EMfP/I/RFhyZKkT+majRWmB5jyi70UCQ4T9hufoGLCLt
ansqEIzsIXMfnHU98H4gIfatW6pKfMLxNR644MX8
=kR4/
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 21 Oct 2022 03:02
Re: bug#57963: [PATCH 0/1] Support user's fontconfig.
(name . Declan Tsien)(address . declantsien@riseup.net)
87r0z2at0t.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (20 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>>
>> You can also configure the settings you want by specifying them in
>> extra-config.
>>
>
> Oh, nice. So my use case is covered. Didn't realize that. Nice work.
>
>>
>> I don't see clearly what the typical configuration of alias should be,
>> but I believe the current specification is sufficient for our needs.
>>
>> Do you still think it is preferable to change the default-font-* field
>> interface, even knowing that you can configure it in the extra-config
>> field? Please give me your frank opinion :)
>>
>
> Let's stick to the current specification, no changes needed. Cheers.

OK. Thank you for your input!

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 21 Oct 2022 06:03
Re: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
(name . Declan Tsien)(address . declantsien@riseup.net)
87ilkdbz75.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (23 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>> @@ -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
>
> Do we also have support service extension here? like this.
>
> #+begin_src scheme
> (compose identity)
> (extend home-fontconfig-extensions)
> (default-value (home-fontconfig-configuration))
> #+end_src
>

Sorry, I didn't understand your question. Could you give me more
specific needs?

Thanks,
--
Taiju
D
D
Declan Tsien wrote on 21 Oct 2022 07:02
(name . Taiju HIGASHI)(address . higashi@taiju.info)
87a65psra1.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (5 lines)
>
> Sorry, I didn't understand your question. Could you give me more
> specific needs?
>

My apologies. I should be more clear.

I think I saw we are using =modify-services= (somewhere in this
thread) to configure =home-fontconfig-service-type=. But wouldn't be nice
if user can just use =simple-service= to extend it?

Like this in my guix-config:

-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNSJ+YXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vVMBAv/b6gpU7YoVDRrbA+bXjZcjgVf
huKi02NQJniP7Erpxziz4l0vxO8jIKRAsgVHPK+DB6LVMunNvNkn5Kkf0MKoNVX4
GU5JIkDcy8Sapm742lOCk6Vx7v+O7QxCu9wbUNfDuAmAFhVMXt3Whb4H5CUC+9Kz
nFFx55mKbmB54em5/qOXuFJbXOn/TkKbOEQcqqSBOurPzmB3Q6CdzQfl0hCRXfZn
OiYk+stvbxUktsK3p40xHQTDdLeu2V9MmDDtQUMzx0L4cRVqdjpUdX2Pqfvbad36
1ILj9X0fU5pup34ozqweRTLA7jGJhrTUtZzlvNTdTnMajLzAUEKqqg5vT4ZmcX+Z
hm8xkDek6flSQKH6Rsd7kaUBteMBVV1muWnwkvk9SzIYVix8WH8VO6hUOZIP68UB
fv9VfSHnMwLJL2trVeXaQOv4cqPTVHuUSb08MwamQ+qeeh5/wS0rsSmfa00IGTwf
LRCbpRWHjzGJEu8i2KPnXX6zkjK2+T+ha1pgPaO9
=YHGF
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 21 Oct 2022 10:01
(name . Declan Tsien)(address . declantsien@riseup.net)
87wn8ta9ma.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (19 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>>
>> Sorry, I didn't understand your question. Could you give me more
>> specific needs?
>>
>
> My apologies. I should be more clear.
>
> I think I saw we are using =modify-services= (somewhere in this
> thread) to configure =home-fontconfig-service-type=. But wouldn't be nice
> if user can just use =simple-service= to extend it?
>
> Like this in my guix-config:
>
> https://git.sr.ht/~declantsien/guix-config/tree/master/item/home-conf/appearance/font.scm#L30-55
> https://git.sr.ht/~declantsien/guix-config/tree/master/item/guix/gnu/home/services/fontutils.scm#L94-96
>

Thank you for detail information.
Currently, It not support. The interface is not suitable for extension,
so we decided to forgot it.

We have to come up with a merge strategy if we allow to extend, how
would you like to extend it?

Perhaps I am less experienced in Guix customization than you are, and
don't understand the use cases that cannot be achieved with
modify-services.

Thanks,
--
Taiju
D
D
Declan Tsien wrote on 21 Oct 2022 11:15
(name . Taiju HIGASHI)(address . higashi@taiju.info)(address . 57963@debbugs.gnu.org)
87czalzgei.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (5 lines)
>
> We have to come up with a merge strategy if we allow to extend, how
> would you like to extend it?

OK, got it. Sounds reasonable.
I should have followed the conversation thoroughly, Sorry about that.

Toggle quote (3 lines)
>
> Perhaps I am less experienced in Guix customization than you are, and

Nah, I haven't contributed much to Guix community yet. Only poking around with my
guix-config ha.

Toggle quote (3 lines)
> don't understand the use cases that cannot be achieved with
> modify-services.

I'd prefer =simple-service= over =modify-services= when possible.
For example, in this case. Let's say I want to add an item to
=font-directories=, I should not forget to include =guix-home-font-dir=
too, like this:

#+begin_src scheme
(home-fontconfig-configuration
(font-directories
(string-list (list guix-home-font-dir "another-dir")))
#+end_src

But with service extension I can just write:

#+begin_src scheme
(home-fontconfig-extension
(font-directories
(string-list (list "another-dir")))
#+end_src

=guix-home-font-dir= doesn't need to show up in my configuration.

----
Thanks
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNSYzUXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vXHkwwAtHUOPTBnc/bIM4pmNW9C6ax4
d+r9yifg8bVIYN/x+L0hpgACPK2TKMQs5v/2oLcTWVJ9iuXIHl2Dyo6jF7om1rO2
H4OESDYT0gfPenctTJWdaT6n8GJkn9vpx9HcS4jxuzQx2Zv8r7pwJHw8IL1SloXV
db5vHAVUDyjIkXNHuh6+O+GYVISeeU/psl2VhtQ6qghO5TmZek1IMCaOw728honw
iarDuF58NU/TAeEkplPlAAsaiWNgKKfWJhRuEplCLZ8W8DXPnKv9ZmIWFrF3NeR0
IYHOduH4zjSfJON2DwlxMgBR4KGrYVre08zcOQ1oYutlbY59zpDzR9A6mVj/HqRL
gNZ1oyg3L5buT33JXFgngBN4kk6gvZppm0Pwi5D21nJj0avAMMVvj0YczEmk+JF8
mZoTsQPiqgaa4M7agecksSNbOuTdZLfaWhamac0kdlKKh4vqq0uDt8JmOTIF2GVK
Qxm5YsTKXpJAnGQJcQgfGzcR1jzMiK5PE7dUgHZr
=NMlp
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 23 Oct 2022 08:32
(name . Declan Tsien)(address . declantsien@riseup.net)(address . 57963@debbugs.gnu.org)
87mt9n9hiq.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (41 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>> See: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#71
>>
>> We have to come up with a merge strategy if we allow to extend, how
>> would you like to extend it?
>
> OK, got it. Sounds reasonable.
> I should have followed the conversation thoroughly, Sorry about that.
>
>>
>> Perhaps I am less experienced in Guix customization than you are, and
>
> Nah, I haven't contributed much to Guix community yet. Only poking around with my
> guix-config ha.
>
>> don't understand the use cases that cannot be achieved with
>> modify-services.
>
> I'd prefer =simple-service= over =modify-services= when possible.
> For example, in this case. Let's say I want to add an item to
> =font-directories=, I should not forget to include =guix-home-font-dir=
> too, like this:
>
> #+begin_src scheme
> (home-fontconfig-configuration
> (font-directories
> (string-list (list guix-home-font-dir "another-dir")))
> #+end_src
>
>
> But with service extension I can just write:
>
> #+begin_src scheme
> (home-fontconfig-extension
> (font-directories
> (string-list (list "another-dir")))
> #+end_src
>
> =guix-home-font-dir= doesn't need to show up in my configuration.

I see. We may make the interface even more unsuitable for extensions
since we plan to allow the user to choose whether to configure with the
fontconfig-configuration or a file-like object.

I am taking a very long time to finalize the interface on this issue,
should I still think about it more carefully...?

Thanks,
--
Taiju
D
D
Declan Tsien wrote on 23 Oct 2022 09:33
(name . Taiju HIGASHI)(address . higashi@taiju.info)(address . 57963@debbugs.gnu.org)
87r0yzro2v.fsf@riseup.net
Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (12 lines)
>
> I see. We may make the interface even more unsuitable for extensions
> since we plan to allow the user to choose whether to configure with the
> fontconfig-configuration or a file-like object.
>
> I am taking a very long time to finalize the interface on this issue,
> should I still think about it more carefully...?
>
> Thanks,
> --
> Taiju

I think we can stick to the current specification for now. We can go from
there later.
-----BEGIN PGP SIGNATURE-----

iQHLBAEBCAA1FiEE9pXznsYl4IEztXWfD8aHA3Xv4vUFAmNU7lgXHGRlY2xhbnRz
aWVuQHJpc2V1cC5uZXQACgkQD8aHA3Xv4vUSHwv+Me2ZI33DAdLYPT5S2TYj+wDO
sazmox+5i/qFQjU4Ni+XigUsnmToIXtE7suTvV8Z0tcKKtOHotXACA7PRzhZe1hN
RkfIZ9zcKPNHitqTmmSORUtZJz5JYZkEcAZk7sCy2yaXPwBZ/y9XB4bSQ0OyHxmD
1yJvvMR+Grsg81X8lx7h2AXgNK55SwdMwtnmemCno+AgnE38t5dMv8LQfvxOcWKA
tS4k6/qjiL/uoIKKbcboyysESnn5O6iw2fne6WNSt5b/uXLLvAqZvdWUSboo/i2G
LKRd5OdvzZkNdHibMj1OCiaJSmrGhiSINCdjsQwf0ClC1WtyeAbd5SV9pbkXnNO0
zny7/nvPKinM4yDPeom7PSb4yGo67opEBp6Yg7El7y3rv9vvM9xmZxvjzJ6zXaqo
OtntmBH8Qi2aS52LL9GRFXBSJufSmmAcTj3uErNFg9vgX7niPBL/BpK7b4QXFxCD
+fKkeK282q2HW/We0Jp6CvpWGK6mdw71jk2p2W00
=6AZi
-----END PGP SIGNATURE-----

T
T
Taiju HIGASHI wrote on 23 Oct 2022 13:40
(name . Declan Tsien)(address . declantsien@riseup.net)(address . 57963@debbugs.gnu.org)
87fsfeahts.fsf@taiju.info
Declan Tsien <declantsien@riseup.net> writes:

Toggle quote (18 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>>
>> I see. We may make the interface even more unsuitable for extensions
>> since we plan to allow the user to choose whether to configure with the
>> fontconfig-configuration or a file-like object.
>>
>> I am taking a very long time to finalize the interface on this issue,
>> should I still think about it more carefully...?
>>
>> Thanks,
>> --
>> Taiju
>
> I think we can stick to the current specification for now. We can go from
> there later.
>

Thank you. I will proceed with the current specification.

Thanks,
--
Taiju
T
T
Taiju HIGASHI wrote on 27 Oct 2022 06:00
(name . Ludovic Courtès)(address . ludo@gnu.org)
871qqtapbo.fsf@taiju.info
Hi,

Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (112 lines)
> Taiju HIGASHI <higashi@taiju.info> writes:
>
>> Hi,
>>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> Hi,
>>>
>>> Taiju HIGASHI <higashi@taiju.info> skribis:
>>>
>>>> Andrew Tropin <andrew@trop.in> writes:
>>>
>>> [...]
>>>
>>>>>> Andrew Tropin <andrew@trop.in> skribis:
>>>>>>
>>>>>>> If serialization would support G-exps, we could write
>>>>>>>
>>>>>>> (list #~"RAW_XML_HERE")
>>>>>>
>>>>>> There’s a one-to-one lossless mapping between XML and SXML, so I don’t
>>>>>> think it makes sense to support XML-in-strings when we have SXML.
>>>>>>
>>>>>> The only thing it would give us, as I see it, is the ability to generate
>>>>>> syntactically-invalid XML. Maybe we can live without it? :-)
>>>>>
>>>>> Of course we can :), but we won't be able:
>>>>>
>>>>> 1. To take already existing xml config and use it without rewriting.
>>>>
>>>> I find it surprisingly important to be able to simply copy and paste
>>>> settings without having to rewrite existing settings or those listed on
>>>> a web page somewhere. I know we can easily convert from XML to SXML,
>>>> but those unfamiliar with SXML may find it a bothering task.
>>>
>>> OK, that makes sense.
>>>
>>> But then, let’s not allow users to intersperse XML-in-strings in the
>>> middle of XML. It should be either a user-provided file/string or the
>>> generated config, but not a mixture of both; that’d be a recipe for
>>> confusion.
>>>
>>> How about this: the service takes either a <fontconfig-configuration>
>>> record or a file-like object?
>>>
>>> (We can even have a “gexp compiler” for <fontconfig-configuration> to
>>> make that transparent.)
>>
>> Thank you for your consideration.
>>
>> That idea sounds good. I don't know if I can successfully implement
>> this, but I will consider it and give it a try.
>>
>> Thanks,
>
> I'm trying to implement the following, is it consistent with the intent
> of what you suggested?
>
> (define (add-fontconfig-config-file user-config)
> `(("fontconfig/fonts.conf"
> ,(if (home-fontconfig-configuration? user-config)
> (mixed-text-file
> "fonts.conf"
> "<?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> <fontconfig>"
> (serialize-configuration user-config home-fontconfig-configuration-fields)
> "</fontconfig>\n")
> user-config))))
>
>
> It is assumed that configurations can be specified in one of the
> following ways.
>
> * fontconfig-configuration:
>
> (home-environment
> (packages (list font-google-noto))
> (services
> (append
> (list
> (service home-bash-service-type))
> (modify-services %home-base-services
> (home-fontconfig-service-type
> config => (home-fontconfig-configuration
> (font-directories
> (cons* "~/fonts" %home-fontconfig-base-font-directories))
> (default-font-serif-family "Noto Serif CJK JP")
> (default-font-sans-serif-family "Noto Sans Serif CJK JP")
> (default-font-monospace-family "PlemolJP Console")
> (extra-config
> '(foo "bar"))))))))
>
>
> Note:
> %home-fontconfig-base-font-directories is the new variable I plan to
> export as the default value, based on Andrew's and Liliana's point.
>
> * file-like objects:
>
> (home-environment
> (packages (list font-google-noto))
> (services
> (append
> (list
> (service home-bash-service-type))
> (modify-services %home-base-services
> (home-fontconfig-service-type
> config => (local-file "/path/to/your/fonts.conf"))))))
>
> Thanks,

Sorry for the long time it has taken to resolve the issue.
What do you think about it?

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 27 Oct 2022 07:18
20a8312539654df3c98954620979078e3e41a150.camel@gmail.com
Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju HIGASHI:
Toggle quote (2 lines)
> Sorry for the long time it has taken to resolve the issue.
> What do you think about it?
Putting the discussion with Declan aside, the last thing mentioned was
not trying to mix SXML and XML-in-strings. Ludo offered the solutions:
1. Taking a <fontconfig-configuration> or a file-like object
2. (Optionally) using a gexp-compiler for the former

Cheers
T
T
Taiju HIGASHI wrote on 27 Oct 2022 07:31
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87r0yt96iy.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (10 lines)
> Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju HIGASHI:
>> Sorry for the long time it has taken to resolve the issue.
>> What do you think about it?
> Putting the discussion with Declan aside, the last thing mentioned was
> not trying to mix SXML and XML-in-strings. Ludo offered the solutions:
> 1. Taking a <fontconfig-configuration> or a file-like object
> 2. (Optionally) using a gexp-compiler for the former
>
> Cheers

Sorry for the lack of clarity.
I had sent you a past email confirming that the direction of the
implementation was correct and was waiting for your response.


Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 27 Oct 2022 08:36
(name . Taiju HIGASHI)(address . higashi@taiju.info)
c9ed26b9378d8af618498daebb36d416b826ca3e.camel@gmail.com
Am Donnerstag, dem 27.10.2022 um 14:31 +0900 schrieb Taiju HIGASHI:
Toggle quote (19 lines)
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju HIGASHI:
> > > Sorry for the long time it has taken to resolve the issue.
> > > What do you think about it?
> > Putting the discussion with Declan aside, the last thing mentioned
> > was
> > not trying to mix SXML and XML-in-strings.  Ludo offered the
> > solutions:
> > 1. Taking a <fontconfig-configuration> or a file-like object
> > 2. (Optionally) using a gexp-compiler for the former
> >
> > Cheers
>
> Sorry for the lack of clarity.
> I had sent you a past email confirming that the direction of the
> implementation was correct and was waiting for your response.
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#239
Ahh, I missed that. If you pull in the XML declarations and the
<fontconfig></fontconfig> stuff to the serialization, you should
basically have most of what you'd need for a G-Exp compiler, but even
if not it'd simplify this to

(match
((? home-font-config-configuration? config)
(serialize-... config ...))
((? file-like? config) config))

Not sure if a match for type-checking would be needed since it's
already taken care of elsewhere, so writing it just in case.

Cheers
T
T
Taiju HIGASHI wrote on 2 Nov 2022 02:43
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87y1sugmh2.fsf@taiju.info
Hi,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (35 lines)
> Am Donnerstag, dem 27.10.2022 um 14:31 +0900 schrieb Taiju HIGASHI:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>> > Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju HIGASHI:
>> > > Sorry for the long time it has taken to resolve the issue.
>> > > What do you think about it?
>> > Putting the discussion with Declan aside, the last thing mentioned
>> > was
>> > not trying to mix SXML and XML-in-strings.  Ludo offered the
>> > solutions:
>> > 1. Taking a <fontconfig-configuration> or a file-like object
>> > 2. (Optionally) using a gexp-compiler for the former
>> >
>> > Cheers
>>
>> Sorry for the lack of clarity.
>> I had sent you a past email confirming that the direction of the
>> implementation was correct and was waiting for your response.
>>
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#239
> Ahh, I missed that. If you pull in the XML declarations and the
> <fontconfig></fontconfig> stuff to the serialization, you should
> basically have most of what you'd need for a G-Exp compiler, but even
> if not it'd simplify this to
>
> (match
> ((? home-font-config-configuration? config)
> (serialize-... config ...))
> ((? file-like? config) config))
>
> Not sure if a match for type-checking would be needed since it's
> already taken care of elsewhere, so writing it just in case.
>
> Cheers

Sorry for my response delay.
Is my recognition correct? I have plan to rewrite it as below.

Toggle snippet (21 lines)
(define (serialize-fontconfig-configuration config)
(define start-of-fontconfig "<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>")

(define end-of-fontconfig "</fontconfig>\n")

(mixed-text-file
"fonts.conf"
start-of-fontconfig
(serialize-configuration config home-fontconfig-configuration-fields)
end-of-fontconfig))

(define (add-fontconfig-config-file user-config)
`(("fontconfig/fonts.conf"
,(match user-config
((? home-fontconfig-configuration? user-config)
(serialize-fontconfig-configuration user-config))
((? file-like? user-config) user-config)))))

Thanks,
--
Taiju
L
L
Liliana Marie Prikler wrote on 2 Nov 2022 07:45
(name . Taiju HIGASHI)(address . higashi@taiju.info)
0b28bb01db01fafe30acb45f4b12e259b79121a6.camel@gmail.com
Am Mittwoch, dem 02.11.2022 um 10:43 +0900 schrieb Taiju HIGASHI:
Toggle quote (67 lines)
> Hi,
>
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > Am Donnerstag, dem 27.10.2022 um 14:31 +0900 schrieb Taiju HIGASHI:
> > > Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> > >
> > > > Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju
> > > > HIGASHI:
> > > > > Sorry for the long time it has taken to resolve the issue.
> > > > > What do you think about it?
> > > > Putting the discussion with Declan aside, the last thing
> > > > mentioned
> > > > was
> > > > not trying to mix SXML and XML-in-strings.  Ludo offered the
> > > > solutions:
> > > > 1. Taking a <fontconfig-configuration> or a file-like object
> > > > 2. (Optionally) using a gexp-compiler for the former
> > > >
> > > > Cheers
> > >
> > > Sorry for the lack of clarity.
> > > I had sent you a past email confirming that the direction of the
> > > implementation was correct and was waiting for your response.
> > >
> > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#239
> > Ahh, I missed that.  If you pull in the XML declarations and the
> > <fontconfig></fontconfig> stuff to the serialization, you should
> > basically have most of what you'd need for a G-Exp compiler, but
> > even
> > if not it'd simplify this to
> >
> > (match
> >   ((? home-font-config-configuration? config)
> >    (serialize-... config ...))
> >   ((? file-like? config) config))
> >
> > Not sure if a match for type-checking would be needed since it's
> > already taken care of elsewhere, so writing it just in case.
> >
> > Cheers
>
> Sorry for my response delay.
> Is my recognition correct?  I have plan to rewrite it as below.
>
> --8<---------------cut here---------------start------------->8---
> (define (serialize-fontconfig-configuration config)
>   (define start-of-fontconfig "<?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> <fontconfig>")
>
>   (define end-of-fontconfig "</fontconfig>\n")
>
>   (mixed-text-file
>    "fonts.conf"
>    start-of-fontconfig
>    (serialize-configuration config home-fontconfig-configuration-
> fields)
>    end-of-fontconfig))
>
> (define (add-fontconfig-config-file user-config)
>   `(("fontconfig/fonts.conf"
>      ,(match user-config
>           ((? home-fontconfig-configuration? user-config)
>            (serialize-fontconfig-configuration user-config))
>         ((? file-like? user-config) user-config)))))
> --8<---------------cut here---------------end--------------->8---
More or less. For one, I don't think start-of-fontconfig and end-of-
fontconfig need to be declared. The (serialize-configuration ) call is
a little opaque atm, but let's suppose it returns properly formatted
XML. Finally, as hinted already and since you're returning a file-like
object anyway, you may want to make this serializer a gexp-compiler
instead.

Cheers
T
T
Taiju HIGASHI wrote on 4 Nov 2022 09:46
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87leorqf7w.fsf@taiju.info
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (77 lines)
> Am Mittwoch, dem 02.11.2022 um 10:43 +0900 schrieb Taiju HIGASHI:
>> Hi,
>>
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>> > Am Donnerstag, dem 27.10.2022 um 14:31 +0900 schrieb Taiju HIGASHI:
>> > > Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>> > >
>> > > > Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju
>> > > > HIGASHI:
>> > > > > Sorry for the long time it has taken to resolve the issue.
>> > > > > What do you think about it?
>> > > > Putting the discussion with Declan aside, the last thing
>> > > > mentioned
>> > > > was
>> > > > not trying to mix SXML and XML-in-strings.  Ludo offered the
>> > > > solutions:
>> > > > 1. Taking a <fontconfig-configuration> or a file-like object
>> > > > 2. (Optionally) using a gexp-compiler for the former
>> > > >
>> > > > Cheers
>> > >
>> > > Sorry for the lack of clarity.
>> > > I had sent you a past email confirming that the direction of the
>> > > implementation was correct and was waiting for your response.
>> > >
>> > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#239
>> > Ahh, I missed that.  If you pull in the XML declarations and the
>> > <fontconfig></fontconfig> stuff to the serialization, you should
>> > basically have most of what you'd need for a G-Exp compiler, but
>> > even
>> > if not it'd simplify this to
>> >
>> > (match
>> >   ((? home-font-config-configuration? config)
>> >    (serialize-... config ...))
>> >   ((? file-like? config) config))
>> >
>> > Not sure if a match for type-checking would be needed since it's
>> > already taken care of elsewhere, so writing it just in case.
>> >
>> > Cheers
>>
>> Sorry for my response delay.
>> Is my recognition correct?  I have plan to rewrite it as below.
>>
>> --8<---------------cut here---------------start------------->8---
>> (define (serialize-fontconfig-configuration config)
>>   (define start-of-fontconfig "<?xml version='1.0'?>
>> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>> <fontconfig>")
>>
>>   (define end-of-fontconfig "</fontconfig>\n")
>>
>>   (mixed-text-file
>>    "fonts.conf"
>>    start-of-fontconfig
>>    (serialize-configuration config home-fontconfig-configuration-
>> fields)
>>    end-of-fontconfig))
>>
>> (define (add-fontconfig-config-file user-config)
>>   `(("fontconfig/fonts.conf"
>>      ,(match user-config
>>           ((? home-fontconfig-configuration? user-config)
>>            (serialize-fontconfig-configuration user-config))
>>         ((? file-like? user-config) user-config)))))
>> --8<---------------cut here---------------end--------------->8---
> More or less. For one, I don't think start-of-fontconfig and end-of-
> fontconfig need to be declared. The (serialize-configuration ) call is
> a little opaque atm, but let's suppose it returns properly formatted
> XML. Finally, as hinted already and since you're returning a file-like
> object anyway, you may want to make this serializer a gexp-compiler
> instead.
>
> Cheers

Sorry. I did not understand what you meant by making it a gexp-compiler
instead. Is there anything reference documents or codes?

I believe it was presented to me in advance as an optional proposal, but
I do not know what it means and have not been able to respond.

Thanks,
--
Taiju
(
CO3NK706PMH8.2PCJQCLUZRRHE@guix-framework
Heya,

On Fri Nov 4, 2022 at 8:46 AM GMT, Taiju HIGASHI wrote:
Toggle quote (3 lines)
> Sorry. I did not understand what you meant by making it a gexp-compiler
> instead. Is there anything reference documents or codes?

Guix's file-like objects are compiled into derivations using gexp-compilers,
which may be defined using the ``define-gexp-compiler'' form. These two are
equivalent:

;;; with procedure

(define (foo->file-like foo)
"Turns FOO into a derivation."
(plain-file "foo"
(foo-text foo)))

;; this way, you need to use foo->file-like whenever you want to use
;; foo in place of a file-like object

(foo->file-like (foo (text "hello")))

;;; with gexp compiler

(define-gexp-compiler (foo-compiler (foo <foo-record>) system target)
;;
(lower-object
(plain-file "foo"
(foo-text foo))))

;; now, a ``foo'' can be treated as a lowerable file-like object! you
;; can put it anywhere you'd put a file-like.
(foo (text "hello"))

So, basically, define-gexp-compiler lets you make new kinds of file-like
object from records! This is actually how computed-file, file-append, et
al are defined; see guix/gexp.scm. (Many of the gexp-compilers define both
a compiler and an expander; the compiler is a derivation to build when
the object is built, and the expander is the string to return when it's
gexped. file-append [line 680 in my checkout] is a good, clear example of
this.)

-- (
T
T
Taiju HIGASHI wrote on 6 Nov 2022 14:24
(name . ()(address . paren@disroot.org)
87tu3cp65c.fsf@taiju.info
"(" <paren@disroot.org> writes:

Toggle quote (44 lines)
> Heya,
>
> On Fri Nov 4, 2022 at 8:46 AM GMT, Taiju HIGASHI wrote:
>> Sorry. I did not understand what you meant by making it a gexp-compiler
>> instead. Is there anything reference documents or codes?
>
> Guix's file-like objects are compiled into derivations using gexp-compilers,
> which may be defined using the ``define-gexp-compiler'' form. These two are
> equivalent:
>
> ;;; with procedure
>
> (define (foo->file-like foo)
> "Turns FOO into a derivation."
> (plain-file "foo"
> (foo-text foo)))
>
> ;; this way, you need to use foo->file-like whenever you want to use
> ;; foo in place of a file-like object
>
> (foo->file-like (foo (text "hello")))
>
> ;;; with gexp compiler
>
> (define-gexp-compiler (foo-compiler (foo <foo-record>) system target)
> ;;
> (lower-object
> (plain-file "foo"
> (foo-text foo))))
>
> ;; now, a ``foo'' can be treated as a lowerable file-like object! you
> ;; can put it anywhere you'd put a file-like.
> (foo (text "hello"))
>
> So, basically, define-gexp-compiler lets you make new kinds of file-like
> object from records! This is actually how computed-file, file-append, et
> al are defined; see guix/gexp.scm. (Many of the gexp-compilers define both
> a compiler and an expander; the compiler is a derivation to build when
> the object is built, and the expander is the string to return when it's
> gexped. file-append [line 680 in my checkout] is a good, clear example of
> this.)
>
> -- (

Thank you for your kindness.
I think I understand a little more now, and I will read the surrounding
source code to better understand it. Thanks to you, I may be able to
understand what was suggested earlier in this thread!

Thanks,
--
Taiju
M
M
Maxim Cournoyer wrote on 12 Nov 07:17 +0100
Re: [bug#57963] Next steps for this issue
87pln16knl.fsf@gmail.com
Hi,

Taiju HIGASHI <higashi@taiju.info> writes:

Toggle quote (12 lines)
> Hi,
>
> What are the next steps for this issue?
>
> I recognize that the following work remains.
>
> 1. Review of the v5 patch
> 2. Consider which services to move from essentials services to base services
> 3. Modify Document
>
> If I forgot to do something, please point it out.

Liliana, Andrew, Ludovic; as you were involved in the initial review (2
years ago!), would you mind to have a look at what's missing here? It
seems a valuable contribution.

--
Thanks,
Maxim
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 57963@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 57963
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch