home: services: fontutils: Add service value.

* gnu/home/services/fontutils.scm (add-fontconfig-config-file): Add
support for multiple paths;
(home-fontconfig-service-type): Honor it;
* doc/guix.texi (Fonts Services): Document it.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Giacomo Leidi 2023-01-02 18:44:51 +01:00 committed by Ludovic Courtès
parent aed385e18e
commit f85865a05a
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 42 additions and 6 deletions

View file

@ -41130,6 +41130,7 @@ services)}.
* SSH: Secure Shell. Setting up the secure shell client. * SSH: Secure Shell. Setting up the secure shell client.
* Desktop: Desktop Home Services. Services for graphical environments. * Desktop: Desktop Home Services. Services for graphical environments.
* Guix: Guix Home Services. Services for Guix. * Guix: Guix Home Services. Services for Guix.
* Fonts: Fonts Home Services. Services for managing User's fonts.
@end menu @end menu
@c In addition to that Home Services can provide @c In addition to that Home Services can provide
@ -42014,6 +42015,35 @@ A typical extension for adding a channel might look like this:
@end lisp @end lisp
@end defvar @end defvar
@node Fonts Home Services
@subsection Fonts Home Services
The @code{(gnu home services fontutils)} module provides services for
user-specific Fontconfig setup. The
@uref{https://www.freedesktop.org/wiki/Software/fontconfig,Fontconfig}
library is used by many applications to access fonts on the system.
@defvar home-fontconfig-service-type
This is the service type for generating configurations for Fontconfig.
Its associated value is a list of strings (or gexps) pointing to fonts
locations.
Generally, it is better to extend this service than to directly
configure it, as its default value is the default Guix Home's profile
font installation path (@file{~/.guix-home/profile/share/fonts}). If
you configure this service directly, be sure to include the above
directory.
A typical extension for adding an additional font directory might look
like this:
@lisp
(simple-service 'additional-fonts-service
home-fontconfig-service-type
(list "~/.nix-profile/share/fonts"))
@end lisp
@end defvar
@node Invoking guix home @node Invoking guix home
@section Invoking @command{guix home} @section Invoking @command{guix home}

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; 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 home services)
#:use-module (gnu packages fontutils) #:use-module (gnu packages fontutils)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:export (home-fontconfig-service-type)) #:export (home-fontconfig-service-type))
@ -33,15 +35,17 @@ (define-module (gnu home services fontutils)
;;; ;;;
;;; Code: ;;; Code:
(define (add-fontconfig-config-file he-symlink-path) (define (add-fontconfig-config-file directories)
`(("fontconfig/fonts.conf" `(("fontconfig/fonts.conf"
,(mixed-text-file ,(mixed-text-file
"fonts.conf" "fonts.conf"
"<?xml version='1.0'?> (apply string-append
`("<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig> <fontconfig>\n" ,@(map (lambda (directory)
<dir>~/.guix-home/profile/share/fonts</dir> (string-append " <dir>" directory "</dir>\n"))
</fontconfig>")))) directories)
"</fontconfig>\n"))))))
(define (regenerate-font-cache-gexp _) (define (regenerate-font-cache-gexp _)
`(("profile/share/fonts" `(("profile/share/fonts"
@ -59,7 +63,9 @@ (define home-fontconfig-service-type
(service-extension (service-extension
home-profile-service-type home-profile-service-type
(const (list fontconfig))))) (const (list fontconfig)))))
(default-value #f) (compose concatenate)
(extend append)
(default-value '("~/.guix-home/profile/share/fonts"))
(description (description
"Provides configuration file for fontconfig and make "Provides configuration file for fontconfig and make
fc-* utilities aware of font packages installed in Guix Home's profile."))) fc-* utilities aware of font packages installed in Guix Home's profile.")))