@@ -59,6 +59,7 @@
;;; Copyright © 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;; Copyright © 2023 chris <chris@bumblehead.com>
;;; Copyright © 2023 Luis Felipe López Acevedo <sirgazil@zoho.com>
+;;; Copyright © 2023 Saku Laesvuori <saku@laesvuori.fi>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -103,6 +104,56 @@ (define-module (gnu packages fonts)
#:use-module (gnu packages sdl)
#:use-module (gnu packages xorg))
+(define-public (patch-nerd-font font-package)
+ "Return a package that contains the same files as FONT-PACKAGE, except
+that all font files are Nerd Fonts patched."
+ (package
+ (name (string-append (package-name font-package) "-nerd-font"))
+ (version (package-version font-package))
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:builder
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ (define (font-file? filename)
+ ;; The regexp's are from guix/build/font-build-system.scm (install)
+ ;; woff2 is excluded because the fontforge in guix is not compiled
+ ;; with support for it
+ ((file-name-predicate "\\.(tt[fc]|ot[fc]|woff)$")
+ filename #f)) ;the 2. argument is stat but it is unused
+
+ (define (output-path source-path)
+ (let* ((name-version/path (strip-store-file-name source-path))
+ (path-pieces (string-split name-version/path
+ file-name-separator?))
+ (path-in-package (string-join (cdr path-pieces)
+ file-name-separator-string
+ 'prefix)))
+ (string-append #$output (dirname path-in-package))))
+
+ (define (install-and-patch-file file)
+ (if (font-file? file)
+ (invoke (string-append #$(this-package-native-input "nerd-font-patcher")
+ "/bin/font-patcher")
+ file "-o" (output-path file) "--complete")
+ (install-file file (output-path file))))
+
+ (for-each install-and-patch-file
+ (find-files #$(this-package-native-input
+ (package-name font-package))))))))
+ (native-inputs (list nerd-font-patcher font-package))
+ (synopsis
+ (string-append (package-synopsis font-package) " (Nerd Fonts patched)"))
+ (description
+ (string-append (package-description font-package)
+ " Nerd Fonts patching adds thousands of symbolic glyphs."))
+ (home-page (package-home-page font-package))
+ (license (package-license font-package))))
+
(define-public font-artifika
(package
(name "font-artifika")
@@ -2526,6 +2577,9 @@ (define-public font-jetbrains-mono
in small sizes, the text looks crisper.")
(license license:asl2.0)))
+(define-public font-jetbrains-mono-nerd-font
+ (patch-nerd-font font-jetbrains-mono))
+
(define-public font-juliamono
(package
(name "font-juliamono")