* [bug#57963] [PATCH 0/1] Support user's fontconfig.
@ 2022-09-21 0:27 Taiju HIGASHI
2022-09-21 0:29 ` [bug#57963] [PATCH 1/1] home: fontutils: " Taiju HIGASHI
` (6 more replies)
0 siblings, 7 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-21 0:27 UTC (permalink / raw)
To: 57963; +Cc: Taiju HIGASHI
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
@ 2022-09-21 0:29 ` Taiju HIGASHI
2022-09-21 8:54 ` Liliana Marie Prikler
2022-09-22 1:20 ` [bug#57963] [PATCH v2] " Taiju HIGASHI
` (5 subsequent siblings)
6 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-21 0:29 UTC (permalink / raw)
To: 57963; +Cc: Taiju HIGASHI
* 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"))))
(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
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-21 0:29 ` [bug#57963] [PATCH 1/1] home: fontutils: " Taiju HIGASHI
@ 2022-09-21 8:54 ` Liliana Marie Prikler
2022-09-21 9:59 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-21 8:54 UTC (permalink / raw)
To: Taiju HIGASHI, 57963
Am Mittwoch, dem 21.09.2022 um 09:29 +0900 schrieb Taiju HIGASHI:
> * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-21 8:54 ` Liliana Marie Prikler
@ 2022-09-21 9:59 ` Taiju HIGASHI
2022-09-21 11:40 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-21 9:59 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: 57963
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?
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-21 9:59 ` Taiju HIGASHI
@ 2022-09-21 11:40 ` Liliana Marie Prikler
2022-09-22 1:27 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-21 11:40 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963
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.
> > 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 :)
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
2022-09-21 0:29 ` [bug#57963] [PATCH 1/1] home: fontutils: " Taiju HIGASHI
@ 2022-09-22 1:20 ` Taiju HIGASHI
2022-09-22 6:14 ` Andrew Tropin
2022-09-27 9:55 ` [bug#57963] [PATCH v3] home: fontutils: " Taiju HIGASHI
` (4 subsequent siblings)
6 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-22 1:20 UTC (permalink / raw)
To: 57963; +Cc: Taiju HIGASHI
* 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.")))
--
2.37.3
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-21 11:40 ` Liliana Marie Prikler
@ 2022-09-22 1:27 ` Taiju HIGASHI
2022-09-23 7:20 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-22 1:27 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: 57963
[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:
> 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.
[-- Attachment #2: tests/home-services/fontutils.scm --]
[-- Type: text/plain, Size: 3389 bytes --]
;;; 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")
[-- Attachment #3: Type: text/plain, Size: 752 bytes --]
>> > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
2022-09-22 1:20 ` [bug#57963] [PATCH v2] " Taiju HIGASHI
@ 2022-09-22 6:14 ` Andrew Tropin
2022-09-22 8:53 ` Ludovic Courtès
0 siblings, 1 reply; 102+ messages in thread
From: Andrew Tropin @ 2022-09-22 6:14 UTC (permalink / raw)
To: Taiju HIGASHI, 57963; +Cc: Ludovic Courtès, Liliana Marie Prikler
[-- Attachment #1: Type: text/plain, Size: 4389 bytes --]
On 2022-09-22 10:20, Taiju HIGASHI wrote:
> * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's
> fontconfig.
> ---
> gnu/home/services/fontutils.scm | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
> index 6062eaed6a..b57cccbaae 100644
> --- a/gnu/home/services/fontutils.scm
> +++ b/gnu/home/services/fontutils.scm
> @@ -1,6 +1,7 @@
> ;;; GNU Guix --- Functional package management for GNU
> ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -21,6 +22,9 @@ (define-module (gnu home services fontutils)
> #:use-module (gnu home services)
> #:use-module (gnu packages fontutils)
> #:use-module (guix gexp)
> + #:use-module (srfi srfi-1)
> + #:use-module (sxml simple)
> + #:use-module (ice-9 match)
>
> #:export (home-fontconfig-service-type))
>
> @@ -33,15 +37,28 @@ (define-module (gnu home services fontutils)
> ;;;
> ;;; Code:
>
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (parse-extra-user-config extra-user-config)
> + (map (match-lambda
> + ((? pair? sxml) sxml)
> + ((? string? xml) (xml->sxml xml))
> + (_ (error "extra-user-config must be xml string or sxml.")))
> + extra-user-config))
> +
> +(define (add-fontconfig-config-file extra-user-config)
> `(("fontconfig/fonts.conf"
> ,(mixed-text-file
> "fonts.conf"
> "<?xml version='1.0'?>
> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
> -<fontconfig>
> - <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +"
> + (call-with-output-string
> + (lambda (port)
> + (sxml->xml
> + `(fontconfig
> + (dir "~/.guix-home/profile/share/fonts")
> + ,@(parse-extra-user-config extra-user-config))
> + port)
> + (newline port)))))))
>
> (define (regenerate-font-cache-gexp _)
> `(("profile/share/fonts"
> @@ -49,6 +66,8 @@ (define (regenerate-font-cache-gexp _)
>
> (define home-fontconfig-service-type
> (service-type (name 'home-fontconfig)
> + (compose concatenate)
> + (extend append)
> (extensions
> (list (service-extension
> home-xdg-configuration-files-service-type
> @@ -59,7 +78,7 @@ (define home-fontconfig-service-type
> (service-extension
> home-profile-service-type
> (const (list fontconfig)))))
> - (default-value #f)
> + (default-value '())
> (description
> "Provides configuration file for fontconfig and make
> fc-* utilities aware of font packages installed in Guix Home's profile.")))
I like the current approach, but I have two concerns:
1. Serialization happens on client side, not daemon side (during the
build), thus it doesn't support gexp and file-likes, so it would be hard
to append part of already existing file to the config or do similiar thing.
2. We had a discussion with Ludovic about rde home services vs guix home
services styles. And this one looks like rde style, not guix.
rde takes arbitrary s-exps and g-exps with optional structure checks and
serializes them to target format.
guix uses nested records with rigid nesting structure.
rde services style examples:
https://git.sr.ht/~abcdw/rde/tree/8ec99884fad18a80a08a7c1d6a7cf46a006327c4/rde/home/services/wm.scm#L145
https://git.sr.ht/~abcdw/rde/tree/8ec99884fad18a80a08a7c1d6a7cf46a006327c4/rde/home/services/xdisorg.scm#L55
guix services style examples:
https://guix.gnu.org/manual/devel/en/guix.html#Web-Services
Related discussions:
https://issues.guix.gnu.org/53466
https://issues.guix.gnu.org/52698
https://yhetil.org/guix-devel/87h79qx5db.fsf@trop.in/
To sum up, personally I like and prefer the configuration style from
this patch, but to keep it consistent with guix system services we need
to use guix style.
--
Best regards,
Andrew Tropin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
2022-09-22 6:14 ` Andrew Tropin
@ 2022-09-22 8:53 ` Ludovic Courtès
2022-09-22 9:50 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-09-22 8:53 UTC (permalink / raw)
To: Andrew Tropin, Taiju HIGASHI; +Cc: 57963, Liliana Marie Prikler
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:
--8<---------------cut here---------------start------------->8---
(define font-family-map
'((sans-serif . "Noto Sans CJK JP")
(serif . "Noto Serif CJK JP")))
(home-environment
(packages (list font-google-noto))
(services
(list
(simple-service 'my-fontconfig-service
home-fontconfig-service-type
(list
(call-with-output-string
(lambda (port)
(sxml->xml
(map (lambda (pair)
`(alias
(family ,(car pair))
(prefer
(family ,(cdr pair)))))
font-family-map)
port))))))))
--8<---------------cut here---------------end--------------->8---
(With v2 they’d provide SXML instead of XML-in-a-string, so it’s
slightly less verbose but quite similar.)
In this particular case, I would find it easier to use if one could
provide a set of <font-alias> records, let’s say along these lines:
(simple-service 'my-fontconfig-service
home-fontconfig-service-type
(list (font-alias 'sans-serif "Noto Sans CJK JP") …))
That way, users wouldn’t need to know the details of the XML syntax for
fontconfig.
The downside is that it restricts what can be done: it lets you add font
aliases, but nothing more.
Do you have other use cases in mind, Taiju?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v2] home: fontutils: Support user's fontconfig.
2022-09-22 8:53 ` Ludovic Courtès
@ 2022-09-22 9:50 ` Taiju HIGASHI
2022-09-24 15:52 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-22 9:50 UTC (permalink / raw)
To: Andrew Tropin, Ludovic Courtès; +Cc: 57963, Liliana Marie Prikler
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:
> 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.
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.
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.
2022-09-22 1:27 ` Taiju HIGASHI
@ 2022-09-23 7:20 ` Liliana Marie Prikler
0 siblings, 0 replies; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-23 7:20 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963
Am Donnerstag, dem 22.09.2022 um 10:27 +0900 schrieb Taiju HIGASHI:
> 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.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-22 9:50 ` Taiju HIGASHI
@ 2022-09-24 15:52 ` Ludovic Courtès
2022-09-24 22:58 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-09-24 15:52 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, Liliana Marie Prikler, Andrew Tropin
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. :-)
> 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’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-24 15:52 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
@ 2022-09-24 22:58 ` Taiju HIGASHI
2022-09-25 6:25 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-24 22:58 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, Liliana Marie Prikler, Andrew Tropin
Ludovic Courtès <ludo@gnu.org> writes:
> 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.
>> 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.
> 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.
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?
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-24 22:58 ` Taiju HIGASHI
@ 2022-09-25 6:25 ` Liliana Marie Prikler
2022-09-25 7:29 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-25 6:25 UTC (permalink / raw)
To: Taiju HIGASHI, Ludovic Courtès; +Cc: 57963, Andrew Tropin
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 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-25 6:25 ` Liliana Marie Prikler
@ 2022-09-25 7:29 ` Taiju HIGASHI
2022-09-25 7:34 ` Taiju HIGASHI
2022-09-25 15:50 ` Liliana Marie Prikler
0 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-25 7:29 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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---
>> 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:
--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.
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-25 7:29 ` Taiju HIGASHI
@ 2022-09-25 7:34 ` Taiju HIGASHI
2022-09-25 15:50 ` Liliana Marie Prikler
1 sibling, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-25 7:34 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
Taiju HIGASHI <higashi@taiju.info> writes:
> 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.
--8<---------------cut here---------------start------------->8---
(service home-fontconfig-service-type
(home-fontconfig-configuration
(dirs
(list "~/.config/fontconfig/my-fonts1.conf"))
(extra-config
(list
"<match>...</match>"))))
--8<---------------cut here---------------end--------------->8---
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-25 7:29 ` Taiju HIGASHI
2022-09-25 7:34 ` Taiju HIGASHI
@ 2022-09-25 15:50 ` Liliana Marie Prikler
2022-09-26 1:43 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-25 15:50 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-25 15:50 ` Liliana Marie Prikler
@ 2022-09-26 1:43 ` Taiju HIGASHI
2022-09-26 18:19 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-26 1:43 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> 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.)
--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---
How about this?
--
Cheers
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-26 1:43 ` Taiju HIGASHI
@ 2022-09-26 18:19 ` Liliana Marie Prikler
0 siblings, 0 replies; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-26 18:19 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: Ludovic Courtès, 57963, Andrew Tropin
Am Montag, dem 26.09.2022 um 10:43 +0900 schrieb Taiju HIGASHI:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
2022-09-21 0:29 ` [bug#57963] [PATCH 1/1] home: fontutils: " Taiju HIGASHI
2022-09-22 1:20 ` [bug#57963] [PATCH v2] " Taiju HIGASHI
@ 2022-09-27 9:55 ` Taiju HIGASHI
2022-09-27 10:10 ` Taiju HIGASHI
2022-09-28 19:11 ` [bug#57963] [PATCH v3] home: fontutils: " Liliana Marie Prikler
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
` (3 subsequent siblings)
6 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-27 9:55 UTC (permalink / raw)
To: ludo, liliana.prikler, andrew; +Cc: 57963, 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 "")))
+
+(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
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig.
2022-09-27 9:55 ` [bug#57963] [PATCH v3] home: fontutils: " Taiju HIGASHI
@ 2022-09-27 10:10 ` Taiju HIGASHI
2022-09-28 21:15 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
2022-09-28 19:11 ` [bug#57963] [PATCH v3] home: fontutils: " Liliana Marie Prikler
1 sibling, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-27 10:10 UTC (permalink / raw)
To: 57963; +Cc: ludo, liliana.prikler, andrew
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.
--8<---------------cut here---------------start------------->8---
(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)))))))
--8<---------------cut here---------------end--------------->8---
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`.
> +(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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig.
2022-09-27 9:55 ` [bug#57963] [PATCH v3] home: fontutils: " Taiju HIGASHI
2022-09-27 10:10 ` Taiju HIGASHI
@ 2022-09-28 19:11 ` Liliana Marie Prikler
2022-09-29 0:31 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-28 19:11 UTC (permalink / raw)
To: Taiju HIGASHI, ludo, andrew; +Cc: 57963
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?
> +(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.
> +(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.
> (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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-27 10:10 ` Taiju HIGASHI
@ 2022-09-28 21:15 ` Ludovic Courtès
2022-09-29 1:01 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-09-28 21:15 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, andrew
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.
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 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’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig.
2022-09-28 19:11 ` [bug#57963] [PATCH v3] home: fontutils: " Liliana Marie Prikler
@ 2022-09-29 0:31 ` Taiju HIGASHI
2022-09-29 14:46 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 0:31 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: ludo, 57963, andrew
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> 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.
>> +(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?
>> +(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.
>> (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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-28 21:15 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
@ 2022-09-29 1:01 ` Taiju HIGASHI
2022-09-29 14:28 ` Ludovic Courtès
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 1:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, andrew
Ludovic Courtès <ludo@gnu.org> writes:
> 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.
> 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.
>> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-29 1:01 ` Taiju HIGASHI
@ 2022-09-29 14:28 ` Ludovic Courtès
2022-09-29 14:51 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-09-29 14:28 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, andrew
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).
>> 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’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
` (2 preceding siblings ...)
2022-09-27 9:55 ` [bug#57963] [PATCH v3] home: fontutils: " Taiju HIGASHI
@ 2022-09-29 14:36 ` Taiju HIGASHI
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
` (2 more replies)
2022-10-02 13:12 ` [bug#57963] [PATCH v5 1/2] home: services: " Taiju HIGASHI
` (2 subsequent siblings)
6 siblings, 3 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 14:36 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
* 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
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:
+
+\f
+(define %home-base-services
+ ;; Convenience variable holding the basic services.
+ (list (service home-fontconfig-service-type)))
+
+;;; base.scm ends here
--
2.37.3
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
@ 2022-09-29 14:36 ` Taiju HIGASHI
2022-09-29 14:55 ` Taiju HIGASHI
` (2 more replies)
2022-09-29 14:43 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Liliana Marie Prikler
2022-10-01 21:47 ` Ludovic Courtès
2 siblings, 3 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 14:36 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
* 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.")))
--
2.37.3
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
@ 2022-09-29 14:43 ` Liliana Marie Prikler
2022-09-29 15:09 ` Taiju HIGASHI
2022-10-01 21:47 ` Ludovic Courtès
2 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-09-29 14:43 UTC (permalink / raw)
To: Taiju HIGASHI, 57963; +Cc: ludo, andrew
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.
> * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig.
2022-09-29 0:31 ` Taiju HIGASHI
@ 2022-09-29 14:46 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 14:46 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: ludo, 57963, andrew
Hi Liliana,
I've sent you the v4 patch.
Taiju HIGASHI <higashi@taiju.info> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-29 14:28 ` Ludovic Courtès
@ 2022-09-29 14:51 ` Taiju HIGASHI
2022-09-29 16:02 ` ( via Guix-patches via
2022-09-30 18:30 ` liliana.prikler
0 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 14:51 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, andrew
Hi Ludovic,
I've sent you the v4 patch.
Ludovic Courtès <ludo@gnu.org> writes:
> 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.
>>> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
@ 2022-09-29 14:55 ` Taiju HIGASHI
2022-09-30 18:34 ` liliana.prikler
2022-10-01 21:57 ` Ludovic Courtès
2 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 14:55 UTC (permalink / raw)
To: 57963; +Cc: ludo, liliana.prikler, andrew
The new way to extend the service is 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"))
(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)))))))))))
--8<---------------cut here---------------end--------------->8---
Taiju HIGASHI <higashi@taiju.info> writes:
> * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-29 14:43 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Liliana Marie Prikler
@ 2022-09-29 15:09 ` Taiju HIGASHI
2022-09-30 18:21 ` liliana.prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-29 15:09 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: ludo, 57963, andrew
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?
>> * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-29 14:51 ` Taiju HIGASHI
@ 2022-09-29 16:02 ` ( via Guix-patches via
2022-09-30 0:12 ` Taiju HIGASHI
2022-09-30 18:30 ` liliana.prikler
1 sibling, 1 reply; 102+ messages in thread
From: ( via Guix-patches via @ 2022-09-29 16:02 UTC (permalink / raw)
To: Taiju HIGASHI, Ludovic Courtès; +Cc: 57963, liliana.prikler, andrew
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.)
-- (
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-29 16:02 ` ( via Guix-patches via
@ 2022-09-30 0:12 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-09-30 0:12 UTC (permalink / raw)
To: (; +Cc: Ludovic Courtès, 57963, liliana.prikler, andrew
Hi (,
"(" <paren@disroot.org> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-29 15:09 ` Taiju HIGASHI
@ 2022-09-30 18:21 ` liliana.prikler
2022-10-01 11:08 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: liliana.prikler @ 2022-09-30 18:21 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, andrew
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".
> > > * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-29 14:51 ` Taiju HIGASHI
2022-09-29 16:02 ` ( via Guix-patches via
@ 2022-09-30 18:30 ` liliana.prikler
2022-10-01 11:11 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: liliana.prikler @ 2022-09-30 18:30 UTC (permalink / raw)
To: Taiju HIGASHI, Ludovic Courtès; +Cc: 57963, andrew
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
2022-09-29 14:55 ` Taiju HIGASHI
@ 2022-09-30 18:34 ` liliana.prikler
2022-10-01 11:19 ` Taiju HIGASHI
2022-10-01 21:57 ` Ludovic Courtès
2 siblings, 1 reply; 102+ messages in thread
From: liliana.prikler @ 2022-09-30 18:34 UTC (permalink / raw)
To: Taiju HIGASHI, 57963; +Cc: ludo, andrew
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-30 18:21 ` liliana.prikler
@ 2022-10-01 11:08 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-01 11:08 UTC (permalink / raw)
To: liliana.prikler; +Cc: ludo, 57963, andrew
liliana.prikler@gmail.com writes:
> 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.
>> > > * 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-09-30 18:30 ` liliana.prikler
@ 2022-10-01 11:11 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-01 11:11 UTC (permalink / raw)
To: liliana.prikler; +Cc: Ludovic Courtès, 57963, andrew
liliana.prikler@gmail.com writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-09-30 18:34 ` liliana.prikler
@ 2022-10-01 11:19 ` Taiju HIGASHI
2022-10-01 16:14 ` liliana.prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-01 11:19 UTC (permalink / raw)
To: liliana.prikler; +Cc: ludo, 57963, andrew
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---
Cheers,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-10-01 11:19 ` Taiju HIGASHI
@ 2022-10-01 16:14 ` liliana.prikler
2022-10-02 13:22 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: liliana.prikler @ 2022-10-01 16:14 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, andrew
Am Samstag, dem 01.10.2022 um 20:19 +0900 schrieb Taiju HIGASHI:
> 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.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
2022-09-29 14:43 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Liliana Marie Prikler
@ 2022-10-01 21:47 ` Ludovic Courtès
2022-10-02 13:45 ` Taiju HIGASHI
2 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-10-01 21:47 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, andrew
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’.
> @@ -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’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
2022-09-29 14:55 ` Taiju HIGASHI
2022-09-30 18:34 ` liliana.prikler
@ 2022-10-01 21:57 ` Ludovic Courtès
2022-10-02 13:38 ` Taiju HIGASHI
2 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-10-01 21:57 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, andrew
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.
> +(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”.
> +(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”.
> +(define font-directories? list?)
Is it really needed?
> +(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))
> + (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’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 1/2] home: services: Add base.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
` (3 preceding siblings ...)
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
@ 2022-10-02 13:12 ` Taiju HIGASHI
2022-10-02 13:20 ` Taiju HIGASHI
2022-10-02 13:15 ` Taiju HIGASHI
2022-10-07 5:20 ` [bug#57963] Next steps for this issue Taiju HIGASHI
6 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:12 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=__emacs_complete_pre_command; echo -n "^[^[pwd=${PWD}^[^["; compgen -b -c -a -A function -- n 2>/dev/null, Size: 3788 bytes --]
* 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:
+
+\f
+(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
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 1/2] home: services: Add base.
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
` (4 preceding siblings ...)
2022-10-02 13:12 ` [bug#57963] [PATCH v5 1/2] home: services: " Taiju HIGASHI
@ 2022-10-02 13:15 ` Taiju HIGASHI
2022-10-02 13:15 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
2022-10-07 5:20 ` [bug#57963] Next steps for this issue Taiju HIGASHI
6 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:15 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
* 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
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:
+
+\f
+(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
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-02 13:15 ` Taiju HIGASHI
@ 2022-10-02 13:15 ` Taiju HIGASHI
2022-10-10 6:40 ` Andrew Tropin
2022-10-20 5:40 ` Declan Tsien
0 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:15 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
* 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)))
+
+(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
^ permalink raw reply related [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 1/2] home: services: Add base.
2022-10-02 13:12 ` [bug#57963] [PATCH v5 1/2] home: services: " Taiju HIGASHI
@ 2022-10-02 13:20 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:20 UTC (permalink / raw)
To: 57963; +Cc: ludo, liliana.prikler, andrew
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:
> * 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:
> +
> +\f
> +(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 \
--
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-10-01 16:14 ` liliana.prikler
@ 2022-10-02 13:22 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:22 UTC (permalink / raw)
To: liliana.prikler; +Cc: ludo, 57963, andrew
>> > > +(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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig.
2022-10-01 21:57 ` Ludovic Courtès
@ 2022-10-02 13:38 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:38 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, andrew
Hi,
Ludovic Courtès <ludo@gnu.org> writes:
> 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.
>> +(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.
>> +(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.
>> +(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?
>> +(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.
>> + (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.
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-10-01 21:47 ` Ludovic Courtès
@ 2022-10-02 13:45 ` Taiju HIGASHI
2022-10-02 14:59 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-02 13:45 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, andrew
Ludovic Courtès <ludo@gnu.org> writes:
> 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.
>> @@ -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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-10-02 13:45 ` Taiju HIGASHI
@ 2022-10-02 14:59 ` Liliana Marie Prikler
2022-10-03 23:27 ` Taiju HIGASHI
2022-10-10 5:50 ` Andrew Tropin
0 siblings, 2 replies; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-02 14:59 UTC (permalink / raw)
To: Taiju HIGASHI, Ludovic Courtès; +Cc: 57963, andrew
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'd get Andrew's approval before moving services, but I'd move them in
one go rather than bit by bit.
Cheers
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-10-02 14:59 ` Liliana Marie Prikler
@ 2022-10-03 23:27 ` Taiju HIGASHI
2022-10-10 5:50 ` Andrew Tropin
1 sibling, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-03 23:27 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, andrew
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> 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.
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Next steps for this issue
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
` (5 preceding siblings ...)
2022-10-02 13:15 ` Taiju HIGASHI
@ 2022-10-07 5:20 ` Taiju HIGASHI
2022-10-07 5:44 ` Taiju HIGASHI
6 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-07 5:20 UTC (permalink / raw)
To: 57963; +Cc: iliana.prikler, ludo, andrew
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Next steps for this issue
2022-10-07 5:20 ` [bug#57963] Next steps for this issue Taiju HIGASHI
@ 2022-10-07 5:44 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-07 5:44 UTC (permalink / raw)
To: 57963; +Cc: ludo, liliana.prikler, andrew
Hi Liliana,
I'm sorry, I had the wrong email address.
Taiju HIGASHI <higashi@taiju.info> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v4 1/2] home-services: Add base.
2022-10-02 14:59 ` Liliana Marie Prikler
2022-10-03 23:27 ` Taiju HIGASHI
@ 2022-10-10 5:50 ` Andrew Tropin
1 sibling, 0 replies; 102+ messages in thread
From: Andrew Tropin @ 2022-10-10 5:50 UTC (permalink / raw)
To: Liliana Marie Prikler, Taiju HIGASHI, Ludovic Courtès; +Cc: 57963
[-- Attachment #1: Type: text/plain, Size: 2160 bytes --]
On 2022-10-02 16:59, Liliana Marie Prikler wrote:
> 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.
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-02 13:15 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
@ 2022-10-10 6:40 ` Andrew Tropin
2022-10-10 16:15 ` Liliana Marie Prikler
` (2 more replies)
2022-10-20 5:40 ` Declan Tsien
1 sibling, 3 replies; 102+ messages in thread
From: Andrew Tropin @ 2022-10-10 6:40 UTC (permalink / raw)
To: Taiju HIGASHI, 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler
[-- Attachment #1: Type: text/plain, Size: 6643 bytes --]
On 2022-10-02 22:15, Taiju HIGASHI wrote:
> * 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.
> +
> +(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")))
> + ((? 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.
> + "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"))))
> + "</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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-10 6:40 ` Andrew Tropin
@ 2022-10-10 16:15 ` Liliana Marie Prikler
2022-10-12 6:05 ` Andrew Tropin
2022-10-11 3:54 ` Taiju HIGASHI
2022-10-13 12:37 ` Ludovic Courtès
2 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-10 16:15 UTC (permalink / raw)
To: Andrew Tropin, Taiju HIGASHI, 57963; +Cc: ludo
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.
Cheers
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-10 6:40 ` Andrew Tropin
2022-10-10 16:15 ` Liliana Marie Prikler
@ 2022-10-11 3:54 ` Taiju HIGASHI
2022-10-11 4:21 ` Liliana Marie Prikler
2022-10-12 6:43 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Andrew Tropin
2022-10-13 12:37 ` Ludovic Courtès
2 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-11 3:54 UTC (permalink / raw)
To: Andrew Tropin; +Cc: ludo, 57963, liliana.prikler
Hi Andrew,
Thank you for your review!
>> +(define (string-list? value)
>> + (and (pair? value) (every string? value)))
>
> Better to use list? here and in the other places, at least for the
> consistency, but also for semantic meaning.
OK. I'll rewrite it to below.
--8<---------------cut here---------------start------------->8---
(define (string-list? value)
(and (list? value) (every string? value)))
--8<---------------cut here---------------end--------------->8---
>> +
>> +(define (serialize-string-list field-name value)
>> + (sxml->xml-string
>> + (map
>> + (lambda (path) `(dir ,path))
>> + (if (member guix-home-font-dir value)
>> + value
>> + (append (list guix-home-font-dir) value)))))
>> +
>> +(define (serialize-string field-name value)
>> + (define (serialize type value)
>> + (sxml->xml-string
>> + `(alias
>> + (family ,type)
>> + (prefer
>> + (family ,value)))))
>> + (match (list field-name value)
>> + (('default-font-serif-family family)
>> + (serialize 'serif family))
>> + (('default-font-sans-serif-family family)
>> + (serialize 'sans-serif family))
>> + (('default-font-monospace-family family)
>> + (serialize 'monospace family))))
>> +
>> +(define-maybe string)
>> +
>> +(define extra-config-list? list?)
>> +
>> +(define-maybe extra-config-list)
>> +
>> +(define (serialize-extra-config-list field-name value)
>> + (sxml->xml-string
>> + (map (match-lambda
>> + ((? pair? sxml) sxml)
>
> Other branches would never be visited because it will fail earlier by
> define-configuration predicate check for extra-config-list? (which is
> basically list?).
We can specify invalid value such as (list "foo" '(foo bar) 123).
> Also, making multi-type fields is debatable, but isn't great IMO.
I see. If we had to choose one or the other, I would prefer the
string-type field.
> If serialization would support G-exps, we could write
>
> (list #~"RAW_XML_HERE")
>
> or even something like this:
>
> (list #~(READ-THE-WHOLE-FILE #$(local-file "our-old.xml")))
Does it mean that the specification does not allow it now? Or does it
mean that it is not possible with my implementation?
>> + ((? string? xml) (xml->sxml xml))
>> + (else
>> + (raise (formatted-message
>> + (G_ "'extra-config' type must be xml string or sxml list, was
>> given: ~a")
>> + value))))
>> + value)))
>> +
>> +(define-configuration home-fontconfig-configuration
>> + (font-directories
>> + (string-list (list guix-home-font-dir))
>
> It's not a generic string-list, but a specific font-directories-list
> with extra logic inside.
>
> Also, because guix-home-font-dir always added to the list, the default
> value should '() and field should be called additional-font-directories
> instead. Otherwise it will be confusing, why guix-home-font-dir is not
> removed from the final configuration, when this field is set to a
> different value.
>
> I skimmed previous messages, but sorry, if I missed any already
> mentioned points.
Sure, It is more appropriate that the field type is to
font-directories-list field name is to additional-font-directories.
>> + "The directory list that provides fonts.")
>> + (default-font-serif-family
>> + maybe-string
>> + "The preffered default fonts of serif.")
>> + (default-font-sans-serif-family
>> + maybe-string
>> + "The preffered default fonts of sans-serif.")
>> + (default-font-monospace-family
>> + maybe-string
>> + "The preffered default fonts of monospace.")
>> + (extra-config
>> + maybe-extra-config-list
>> + "Extra configuration values to append to the fonts.conf."))
>> +
>> +(define (add-fontconfig-config-file user-config)
>> `(("fontconfig/fonts.conf"
>> ,(mixed-text-file
>> "fonts.conf"
>> "<?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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-11 3:54 ` Taiju HIGASHI
@ 2022-10-11 4:21 ` Liliana Marie Prikler
2022-10-11 8:09 ` Taiju HIGASHI
2022-10-12 7:07 ` [bug#57963] Almost plain SXML serializer Andrew Tropin
2022-10-12 6:43 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Andrew Tropin
1 sibling, 2 replies; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-11 4:21 UTC (permalink / raw)
To: Taiju HIGASHI, Andrew Tropin; +Cc: ludo, 57963
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.
> > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-11 4:21 ` Liliana Marie Prikler
@ 2022-10-11 8:09 ` Taiju HIGASHI
2022-10-11 18:24 ` Liliana Marie Prikler
2022-10-12 7:07 ` [bug#57963] Almost plain SXML serializer Andrew Tropin
1 sibling, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-11 8:09 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: ludo, 57963, Andrew Tropin
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?
>> > 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.
>> > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-11 8:09 ` Taiju HIGASHI
@ 2022-10-11 18:24 ` Liliana Marie Prikler
2022-10-12 3:59 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-11 18:24 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, Andrew Tropin
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.
> > > > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-11 18:24 ` Liliana Marie Prikler
@ 2022-10-12 3:59 ` Taiju HIGASHI
2022-10-12 4:21 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-12 3:59 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: ludo, 57963, Andrew Tropin
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.
>> > > > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-12 3:59 ` Taiju HIGASHI
@ 2022-10-12 4:21 ` Liliana Marie Prikler
0 siblings, 0 replies; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-12 4:21 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, Andrew Tropin
Am Mittwoch, dem 12.10.2022 um 12:59 +0900 schrieb Taiju HIGASHI:
> 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?
> > > > > > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-10 16:15 ` Liliana Marie Prikler
@ 2022-10-12 6:05 ` Andrew Tropin
0 siblings, 0 replies; 102+ messages in thread
From: Andrew Tropin @ 2022-10-12 6:05 UTC (permalink / raw)
To: Liliana Marie Prikler, Taiju HIGASHI, 57963; +Cc: ludo
[-- Attachment #1: Type: text/plain, Size: 763 bytes --]
On 2022-10-10 18:15, Liliana Marie Prikler wrote:
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-11 3:54 ` Taiju HIGASHI
2022-10-11 4:21 ` Liliana Marie Prikler
@ 2022-10-12 6:43 ` Andrew Tropin
2022-10-12 11:38 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Andrew Tropin @ 2022-10-12 6:43 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, liliana.prikler
[-- Attachment #1: Type: text/plain, Size: 5597 bytes --]
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.
>
> 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.
>>> + ((? 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.
>>> + "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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Almost plain SXML serializer
2022-10-11 4:21 ` Liliana Marie Prikler
2022-10-11 8:09 ` Taiju HIGASHI
@ 2022-10-12 7:07 ` Andrew Tropin
2022-10-12 11:42 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Andrew Tropin @ 2022-10-12 7:07 UTC (permalink / raw)
To: Liliana Marie Prikler, Taiju HIGASHI; +Cc: ludo, 57963
[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]
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:
--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")
(empty)))
"<another-tag>Maybe some other part of raw XML</another-tag>")
--8<---------------cut here---------------end--------------->8---
This way we can combine SXML with already existing raw XML.
Am I right?
>> > 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-12 6:43 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Andrew Tropin
@ 2022-10-12 11:38 ` Taiju HIGASHI
2022-10-12 12:41 ` Andrew Tropin
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-12 11:38 UTC (permalink / raw)
To: Andrew Tropin; +Cc: ludo, 57963, liliana.prikler
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?
>> 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 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Almost plain SXML serializer
2022-10-12 7:07 ` [bug#57963] Almost plain SXML serializer Andrew Tropin
@ 2022-10-12 11:42 ` Taiju HIGASHI
2022-10-12 13:03 ` Andrew Tropin
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-12 11:42 UTC (permalink / raw)
To: Andrew Tropin; +Cc: ludo, 57963, Liliana Marie Prikler
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.
>>> > 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-12 11:38 ` Taiju HIGASHI
@ 2022-10-12 12:41 ` Andrew Tropin
0 siblings, 0 replies; 102+ messages in thread
From: Andrew Tropin @ 2022-10-12 12:41 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, liliana.prikler
[-- Attachment #1: Type: text/plain, Size: 6947 bytes --]
On 2022-10-12 20:38, Taiju HIGASHI wrote:
> 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.
>>> 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.
--8<---------------cut here---------------start------------->8---
+ (if (member guix-home-font-dir value)
+ value
+ (append (list guix-home-font-dir) value))
--8<---------------cut here---------------end--------------->8---
>>>>> + "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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Almost plain SXML serializer
2022-10-12 11:42 ` Taiju HIGASHI
@ 2022-10-12 13:03 ` Andrew Tropin
2022-10-12 18:23 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Andrew Tropin @ 2022-10-12 13:03 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: ludo, 57963, Liliana Marie Prikler
[-- Attachment #1: Type: text/plain, Size: 3257 bytes --]
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?
>>>> > 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Almost plain SXML serializer
2022-10-12 13:03 ` Andrew Tropin
@ 2022-10-12 18:23 ` Liliana Marie Prikler
2022-10-13 3:51 ` Andrew Tropin
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-12 18:23 UTC (permalink / raw)
To: Andrew Tropin, Taiju HIGASHI; +Cc: ludo, 57963
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. 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] Almost plain SXML serializer
2022-10-12 18:23 ` Liliana Marie Prikler
@ 2022-10-13 3:51 ` Andrew Tropin
0 siblings, 0 replies; 102+ messages in thread
From: Andrew Tropin @ 2022-10-13 3:51 UTC (permalink / raw)
To: Liliana Marie Prikler, Taiju HIGASHI; +Cc: ludo, 57963
[-- Attachment #1: Type: text/plain, Size: 4424 bytes --]
On 2022-10-12 20:23, Liliana Marie Prikler wrote:
> 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:
--8<---------------cut here---------------start------------->8---
<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>
--8<---------------cut here---------------end--------------->8---
Hope it helps, let me know if you want me to rephrase or clarify
something.
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-10 6:40 ` Andrew Tropin
2022-10-10 16:15 ` Liliana Marie Prikler
2022-10-11 3:54 ` Taiju HIGASHI
@ 2022-10-13 12:37 ` Ludovic Courtès
2022-10-14 5:06 ` Andrew Tropin
2 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-10-13 12:37 UTC (permalink / raw)
To: Andrew Tropin; +Cc: 57963, Taiju HIGASHI, liliana.prikler
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? :-)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-13 12:37 ` Ludovic Courtès
@ 2022-10-14 5:06 ` Andrew Tropin
2022-10-15 11:13 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Andrew Tropin @ 2022-10-14 5:06 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, Taiju HIGASHI, liliana.prikler
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
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.
2. Use full path to gnu store of file-like objects.
--
Best regards,
Andrew Tropin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-14 5:06 ` Andrew Tropin
@ 2022-10-15 11:13 ` Taiju HIGASHI
2022-10-17 16:28 ` Ludovic Courtès
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-15 11:13 UTC (permalink / raw)
To: Andrew Tropin; +Cc: Ludovic Courtès, 57963, liliana.prikler
Andrew Tropin <andrew@trop.in> writes:
> 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.
> 2. Use full path to gnu store of file-like objects.
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-15 11:13 ` Taiju HIGASHI
@ 2022-10-17 16:28 ` Ludovic Courtès
2022-10-18 12:41 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Ludovic Courtès @ 2022-10-17 16:28 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, Andrew Tropin
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.)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-17 16:28 ` Ludovic Courtès
@ 2022-10-18 12:41 ` Taiju HIGASHI
2022-10-19 21:42 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-18 12:41 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, Andrew Tropin
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,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-18 12:41 ` Taiju HIGASHI
@ 2022-10-19 21:42 ` Taiju HIGASHI
2022-10-20 1:23 ` [bug#57963] [PATCH 0/1] Support user's fontconfig Declan Tsien
2022-10-27 4:00 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
0 siblings, 2 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-19 21:42 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, Andrew Tropin
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?
--8<---------------cut here---------------start------------->8---
(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))))
--8<---------------cut here---------------end--------------->8---
It is assumed that configurations can be specified in one of the
following ways.
* fontconfig-configuration:
--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
(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"))))))))
--8<---------------cut here---------------end--------------->8---
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:
--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 => (local-file "/path/to/your/fonts.conf"))))))
--8<---------------cut here---------------end--------------->8---
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-19 21:42 ` Taiju HIGASHI
@ 2022-10-20 1:23 ` Declan Tsien
2022-10-20 1:37 ` Taiju HIGASHI
2022-10-27 4:00 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-20 1:23 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, Andrew Tropin
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-20 1:23 ` [bug#57963] [PATCH 0/1] Support user's fontconfig Declan Tsien
@ 2022-10-20 1:37 ` Taiju HIGASHI
2022-10-20 2:03 ` Declan Tsien
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-20 1:37 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963, liliana.prikler, Andrew Tropin
Hi Declan,
Declan Tsien <declantsien@riseup.net> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-20 1:37 ` Taiju HIGASHI
@ 2022-10-20 2:03 ` Declan Tsien
2022-10-20 3:44 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-20 2:03 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, Andrew Tropin
[-- Attachment #1: Type: text/plain, Size: 698 bytes --]
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?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-20 2:03 ` Declan Tsien
@ 2022-10-20 3:44 ` Taiju HIGASHI
2022-10-20 5:06 ` Declan Tsien
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-20 3:44 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963, liliana.prikler, Andrew Tropin
Declan Tsien <declantsien@riseup.net> writes:
> 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,
--8<---------------cut here---------------start------------->8---
(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"))
--8<---------------cut here---------------end--------------->8---
The current implementation serializes below.
--8<---------------cut here---------------start------------->8---
<!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>
--8<---------------cut here---------------end--------------->8---
Since the binding attribute is omitted, it would be interpreted as the
default weak.
ref: https://github.com/behdad/fontconfig/blob/5b41ded2b0ddb98a07ac86264b94403cb7a0fd82/fonts.dtd#L127-L128
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.
--8<---------------cut here---------------start------------->8---
(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"))))))
--8<---------------cut here---------------end--------------->8---
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-20 3:44 ` Taiju HIGASHI
@ 2022-10-20 5:06 ` Declan Tsien
2022-10-21 1:02 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-20 5:06 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, Andrew Tropin
[-- Attachment #1: Type: text/plain, Size: 624 bytes --]
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.
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-02 13:15 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
2022-10-10 6:40 ` Andrew Tropin
@ 2022-10-20 5:40 ` Declan Tsien
2022-10-21 4:03 ` Taiju HIGASHI
1 sibling, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-20 5:40 UTC (permalink / raw)
To: 57963; +Cc: ludo, Taiju HIGASHI, liliana.prikler, andrew
[-- Attachment #1: Type: text/plain, Size: 780 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH 0/1] Support user's fontconfig.
2022-10-20 5:06 ` Declan Tsien
@ 2022-10-21 1:02 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-21 1:02 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963, liliana.prikler, Andrew Tropin
Declan Tsien <declantsien@riseup.net> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-20 5:40 ` Declan Tsien
@ 2022-10-21 4:03 ` Taiju HIGASHI
2022-10-21 5:02 ` Declan Tsien
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-21 4:03 UTC (permalink / raw)
To: Declan Tsien; +Cc: ludo, 57963, liliana.prikler, andrew
Declan Tsien <declantsien@riseup.net> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-21 4:03 ` Taiju HIGASHI
@ 2022-10-21 5:02 ` Declan Tsien
2022-10-21 8:01 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-21 5:02 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963, liliana.prikler, Andrew Tropin
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-21 5:02 ` Declan Tsien
@ 2022-10-21 8:01 ` Taiju HIGASHI
2022-10-21 9:15 ` Declan Tsien
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-21 8:01 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963, liliana.prikler, Andrew Tropin
Declan Tsien <declantsien@riseup.net> writes:
> 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.
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?
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-21 8:01 ` Taiju HIGASHI
@ 2022-10-21 9:15 ` Declan Tsien
2022-10-23 6:32 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-21 9:15 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963
[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]
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.
----
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-21 9:15 ` Declan Tsien
@ 2022-10-23 6:32 ` Taiju HIGASHI
2022-10-23 7:33 ` Declan Tsien
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-23 6:32 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963
Declan Tsien <declantsien@riseup.net> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-23 6:32 ` Taiju HIGASHI
@ 2022-10-23 7:33 ` Declan Tsien
2022-10-23 11:40 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Declan Tsien @ 2022-10-23 7:33 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: 57963
[-- Attachment #1: Type: text/plain, Size: 499 bytes --]
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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-23 7:33 ` Declan Tsien
@ 2022-10-23 11:40 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-23 11:40 UTC (permalink / raw)
To: Declan Tsien; +Cc: 57963
Declan Tsien <declantsien@riseup.net> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-19 21:42 ` Taiju HIGASHI
2022-10-20 1:23 ` [bug#57963] [PATCH 0/1] Support user's fontconfig Declan Tsien
@ 2022-10-27 4:00 ` Taiju HIGASHI
2022-10-27 5:18 ` Liliana Marie Prikler
1 sibling, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-27 4:00 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 57963, liliana.prikler, Andrew Tropin
Hi,
Taiju HIGASHI <higashi@taiju.info> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-27 4:00 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
@ 2022-10-27 5:18 ` Liliana Marie Prikler
2022-10-27 5:31 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-27 5:18 UTC (permalink / raw)
To: Taiju HIGASHI, Ludovic Courtès; +Cc: 57963, Andrew Tropin
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-27 5:18 ` Liliana Marie Prikler
@ 2022-10-27 5:31 ` Taiju HIGASHI
2022-10-27 6:36 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-10-27 5:31 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-27 5:31 ` Taiju HIGASHI
@ 2022-10-27 6:36 ` Liliana Marie Prikler
2022-11-02 1:43 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-10-27 6:36 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-10-27 6:36 ` Liliana Marie Prikler
@ 2022-11-02 1:43 ` Taiju HIGASHI
2022-11-02 6:45 ` Liliana Marie Prikler
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-11-02 1:43 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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---
Thanks,
--
Taiju
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-11-02 1:43 ` Taiju HIGASHI
@ 2022-11-02 6:45 ` Liliana Marie Prikler
2022-11-04 8:46 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: Liliana Marie Prikler @ 2022-11-02 6:45 UTC (permalink / raw)
To: Taiju HIGASHI; +Cc: Ludovic Courtès, 57963, Andrew Tropin
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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-11-02 6:45 ` Liliana Marie Prikler
@ 2022-11-04 8:46 ` Taiju HIGASHI
2022-11-04 16:29 ` ( via Guix-patches via
0 siblings, 1 reply; 102+ messages in thread
From: Taiju HIGASHI @ 2022-11-04 8:46 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 57963, Andrew Tropin
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-11-04 8:46 ` Taiju HIGASHI
@ 2022-11-04 16:29 ` ( via Guix-patches via
2022-11-06 13:24 ` Taiju HIGASHI
0 siblings, 1 reply; 102+ messages in thread
From: ( via Guix-patches via @ 2022-11-04 16:29 UTC (permalink / raw)
To: Taiju HIGASHI, Liliana Marie Prikler
Cc: Ludovic Courtès, 57963, Andrew Tropin
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.)
-- (
^ permalink raw reply [flat|nested] 102+ messages in thread
* [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.
2022-11-04 16:29 ` ( via Guix-patches via
@ 2022-11-06 13:24 ` Taiju HIGASHI
0 siblings, 0 replies; 102+ messages in thread
From: Taiju HIGASHI @ 2022-11-06 13:24 UTC (permalink / raw)
To: (; +Cc: Ludovic Courtès, 57963, Liliana Marie Prikler, Andrew Tropin
"(" <paren@disroot.org> writes:
> 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
^ permalink raw reply [flat|nested] 102+ messages in thread
end of thread, other threads:[~2022-11-06 13:26 UTC | newest]
Thread overview: 102+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-21 0:27 [bug#57963] [PATCH 0/1] Support user's fontconfig Taiju HIGASHI
2022-09-21 0:29 ` [bug#57963] [PATCH 1/1] home: fontutils: " Taiju HIGASHI
2022-09-21 8:54 ` Liliana Marie Prikler
2022-09-21 9:59 ` Taiju HIGASHI
2022-09-21 11:40 ` Liliana Marie Prikler
2022-09-22 1:27 ` Taiju HIGASHI
2022-09-23 7:20 ` Liliana Marie Prikler
2022-09-22 1:20 ` [bug#57963] [PATCH v2] " Taiju HIGASHI
2022-09-22 6:14 ` Andrew Tropin
2022-09-22 8:53 ` Ludovic Courtès
2022-09-22 9:50 ` Taiju HIGASHI
2022-09-24 15:52 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
2022-09-24 22:58 ` Taiju HIGASHI
2022-09-25 6:25 ` Liliana Marie Prikler
2022-09-25 7:29 ` Taiju HIGASHI
2022-09-25 7:34 ` Taiju HIGASHI
2022-09-25 15:50 ` Liliana Marie Prikler
2022-09-26 1:43 ` Taiju HIGASHI
2022-09-26 18:19 ` Liliana Marie Prikler
2022-09-27 9:55 ` [bug#57963] [PATCH v3] home: fontutils: " Taiju HIGASHI
2022-09-27 10:10 ` Taiju HIGASHI
2022-09-28 21:15 ` [bug#57963] [PATCH 0/1] " Ludovic Courtès
2022-09-29 1:01 ` Taiju HIGASHI
2022-09-29 14:28 ` Ludovic Courtès
2022-09-29 14:51 ` Taiju HIGASHI
2022-09-29 16:02 ` ( via Guix-patches via
2022-09-30 0:12 ` Taiju HIGASHI
2022-09-30 18:30 ` liliana.prikler
2022-10-01 11:11 ` Taiju HIGASHI
2022-09-28 19:11 ` [bug#57963] [PATCH v3] home: fontutils: " Liliana Marie Prikler
2022-09-29 0:31 ` Taiju HIGASHI
2022-09-29 14:46 ` Taiju HIGASHI
2022-09-29 14:36 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Taiju HIGASHI
2022-09-29 14:36 ` [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig Taiju HIGASHI
2022-09-29 14:55 ` Taiju HIGASHI
2022-09-30 18:34 ` liliana.prikler
2022-10-01 11:19 ` Taiju HIGASHI
2022-10-01 16:14 ` liliana.prikler
2022-10-02 13:22 ` Taiju HIGASHI
2022-10-01 21:57 ` Ludovic Courtès
2022-10-02 13:38 ` Taiju HIGASHI
2022-09-29 14:43 ` [bug#57963] [PATCH v4 1/2] home-services: Add base Liliana Marie Prikler
2022-09-29 15:09 ` Taiju HIGASHI
2022-09-30 18:21 ` liliana.prikler
2022-10-01 11:08 ` Taiju HIGASHI
2022-10-01 21:47 ` Ludovic Courtès
2022-10-02 13:45 ` Taiju HIGASHI
2022-10-02 14:59 ` Liliana Marie Prikler
2022-10-03 23:27 ` Taiju HIGASHI
2022-10-10 5:50 ` Andrew Tropin
2022-10-02 13:12 ` [bug#57963] [PATCH v5 1/2] home: services: " Taiju HIGASHI
2022-10-02 13:20 ` Taiju HIGASHI
2022-10-02 13:15 ` Taiju HIGASHI
2022-10-02 13:15 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
2022-10-10 6:40 ` Andrew Tropin
2022-10-10 16:15 ` Liliana Marie Prikler
2022-10-12 6:05 ` Andrew Tropin
2022-10-11 3:54 ` Taiju HIGASHI
2022-10-11 4:21 ` Liliana Marie Prikler
2022-10-11 8:09 ` Taiju HIGASHI
2022-10-11 18:24 ` Liliana Marie Prikler
2022-10-12 3:59 ` Taiju HIGASHI
2022-10-12 4:21 ` Liliana Marie Prikler
2022-10-12 7:07 ` [bug#57963] Almost plain SXML serializer Andrew Tropin
2022-10-12 11:42 ` Taiju HIGASHI
2022-10-12 13:03 ` Andrew Tropin
2022-10-12 18:23 ` Liliana Marie Prikler
2022-10-13 3:51 ` Andrew Tropin
2022-10-12 6:43 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Andrew Tropin
2022-10-12 11:38 ` Taiju HIGASHI
2022-10-12 12:41 ` Andrew Tropin
2022-10-13 12:37 ` Ludovic Courtès
2022-10-14 5:06 ` Andrew Tropin
2022-10-15 11:13 ` Taiju HIGASHI
2022-10-17 16:28 ` Ludovic Courtès
2022-10-18 12:41 ` Taiju HIGASHI
2022-10-19 21:42 ` Taiju HIGASHI
2022-10-20 1:23 ` [bug#57963] [PATCH 0/1] Support user's fontconfig Declan Tsien
2022-10-20 1:37 ` Taiju HIGASHI
2022-10-20 2:03 ` Declan Tsien
2022-10-20 3:44 ` Taiju HIGASHI
2022-10-20 5:06 ` Declan Tsien
2022-10-21 1:02 ` Taiju HIGASHI
2022-10-27 4:00 ` [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration Taiju HIGASHI
2022-10-27 5:18 ` Liliana Marie Prikler
2022-10-27 5:31 ` Taiju HIGASHI
2022-10-27 6:36 ` Liliana Marie Prikler
2022-11-02 1:43 ` Taiju HIGASHI
2022-11-02 6:45 ` Liliana Marie Prikler
2022-11-04 8:46 ` Taiju HIGASHI
2022-11-04 16:29 ` ( via Guix-patches via
2022-11-06 13:24 ` Taiju HIGASHI
2022-10-20 5:40 ` Declan Tsien
2022-10-21 4:03 ` Taiju HIGASHI
2022-10-21 5:02 ` Declan Tsien
2022-10-21 8:01 ` Taiju HIGASHI
2022-10-21 9:15 ` Declan Tsien
2022-10-23 6:32 ` Taiju HIGASHI
2022-10-23 7:33 ` Declan Tsien
2022-10-23 11:40 ` Taiju HIGASHI
2022-10-07 5:20 ` [bug#57963] Next steps for this issue Taiju HIGASHI
2022-10-07 5:44 ` Taiju HIGASHI
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).