[Top][All Lists]

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

01/07: home: services: fontutils: Add service value.

From: guix-commits
Subject: 01/07: home: services: fontutils: Add service value.
Date: Tue, 31 Jan 2023 17:58:11 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit f85865a05aa3914a478a46e6f10a5ac442d793a2
Author: Giacomo Leidi <>
AuthorDate: Mon Jan 2 18:44:51 2023 +0100

    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 <>
 doc/guix.texi                   | 30 ++++++++++++++++++++++++++++++
 gnu/home/services/fontutils.scm | 18 ++++++++++++------
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2b1ad77ba5..64873db00b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41130,6 +41130,7 @@ services)}.
 * SSH: Secure Shell.                                   Setting up the secure 
shell client.
 * Desktop: Desktop Home Services.                      Services for graphical 
 * Guix: Guix Home Services.                            Services for Guix.
+* Fonts: Fonts Home Services.                          Services for managing 
User's fonts.
 @end menu
 @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 defvar
+@node Fonts Home Services
+@subsection Fonts Home Services
+The @code{(gnu home services fontutils)} module provides services for
+user-specific Fontconfig setup.  The
+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
+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
+A typical extension for adding an additional font directory might look
+like this:
+(simple-service 'additional-fonts-service
+                home-fontconfig-service-type
+                (list "~/.nix-profile/share/fonts"))
+@end lisp
+@end defvar
 @node Invoking guix home
 @section Invoking @command{guix home}
diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm
index 6062eaed6a..3399cb7ec8 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 <>
 ;;; Copyright © 2021 Xinglu Chen <>
+;;; Copyright © 2023 Giacomo Leidi <>
 ;;; This file is part of GNU Guix.
@@ -21,6 +22,7 @@
   #: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,17 @@
 ;;; Code:
-(define (add-fontconfig-config-file he-symlink-path)
+(define (add-fontconfig-config-file directories)
-       "<?xml version='1.0'?>
+       (apply string-append
+              `("<?xml version='1.0'?>
 <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
-  <dir>~/.guix-home/profile/share/fonts</dir>
+<fontconfig>\n" ,@(map (lambda (directory)
+                         (string-append "  <dir>" directory "</dir>\n"))
+                       directories)
+                "</fontconfig>\n"))))))
 (define (regenerate-font-cache-gexp _)
@@ -59,7 +63,9 @@
                         (const (list fontconfig)))))
-                (default-value #f)
+                (compose concatenate)
+                (extend append)
+                (default-value '("~/.guix-home/profile/share/fonts"))
                  "Provides configuration file for fontconfig and make
 fc-* utilities aware of font packages installed in Guix Home's profile.")))

reply via email to

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