fontutils.scm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
  3. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (gnu home services fontutils)
  20. #:use-module (gnu home services)
  21. #:use-module (gnu packages fontutils)
  22. #:use-module (guix gexp)
  23. #:export (home-fontconfig-service-type))
  24. ;;; Commentary:
  25. ;;;
  26. ;;; Services related to fonts. home-fontconfig service provides
  27. ;;; fontconfig configuration, which allows fc-* utilities to find
  28. ;;; fonts in Guix Home's profile and regenerates font cache on
  29. ;;; activation.
  30. ;;;
  31. ;;; Code:
  32. (define (add-fontconfig-config-file he-symlink-path)
  33. `(("config/fontconfig/fonts.conf"
  34. ,(mixed-text-file
  35. "fonts.conf"
  36. "<?xml version='1.0'?>
  37. <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
  38. <fontconfig>
  39. <dir>~/.guix-home/profile/share/fonts</dir>
  40. </fontconfig>"))))
  41. (define (regenerate-font-cache-gexp _)
  42. `(("profile/share/fonts"
  43. ,#~(system* #$(file-append fontconfig "/bin/fc-cache") "-fv"))))
  44. (define home-fontconfig-service-type
  45. (service-type (name 'home-fontconfig)
  46. (extensions
  47. (list (service-extension
  48. home-files-service-type
  49. add-fontconfig-config-file)
  50. (service-extension
  51. home-run-on-change-service-type
  52. regenerate-font-cache-gexp)
  53. (service-extension
  54. home-profile-service-type
  55. (const (list fontconfig)))))
  56. (default-value #f)
  57. (description
  58. "Provides configuration file for fontconfig and make
  59. fc-* utilities aware of font packages installed in Guix Home's profile.")))