nerd font

This commit is contained in:
Aleksandr Lebedev 2025-11-25 13:04:19 +01:00
parent c4fa7b115f
commit b2858a2261
3 changed files with 159 additions and 6 deletions

View file

@ -272,6 +272,7 @@ layout {
// See the binds section below for more spawn examples.
spawn-sh-at-startup "emacs --daemon"
spawn-sh-at-startup "dms run -c $DMSDEFAULTCONFIG"
spawn-at-startup "secretsd"
spawn-at-startup "birdtray"
spawn-at-startup "icedove"

View file

@ -1,5 +1,6 @@
(define-module (guix-config home workstation)
#:use-module (gnu home)
#:use-module (guix)
#:use-module (gnu packages emacs)
#:use-module (gnu packages glib)
#:use-module (gnu packages shellutils)
@ -17,6 +18,7 @@
#:use-module (gnu packages linux)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages rust-apps)
#:use-module (gnu packages password-utils)
#:use-module (gnu packages qt)
#:use-module (gnu packages version-control)
#:use-module (gnu packages librewolf)
@ -35,6 +37,7 @@
#:use-module (gnu home services sound)
#:use-module (gnu home services desktop)
#:use-module (guix-config packages emacs)
#:use-module (guix-config packages fonts)
#:use-module (guix-config home services emacs)
#:use-module (guix-config home services flatpak)
#:use-module (guix-config home services secretsd)
@ -43,7 +46,7 @@
#:use-module (guix packages)
#:use-module (gnu packages gimp)
#:use-module (gnu packages inkscape)
#:use-module (gnu home services dankmaterialshell)
#:use-module (gnu packages wm)
)
(define tune
@ -60,6 +63,7 @@
icecat
vlc
font-google-noto-emoji
font-nerd-fonts-symbols-mono
font-openmoji
direnv
(package
@ -74,17 +78,21 @@
inkscape
icedove
nautilus
dankmaterialshell
secretsd
xournalpp))
;; Below is the list of Home services. To search for available
;; services, run 'guix home search KEYWORD' in a terminal.
(services
(append (list (service home-dankmaterialshell-service-type
(home-dankmaterialshell-configuration
(launch-command (file-append niri "/bin/niri msg action spawn-sh --"))))
(service home-niri-service-type)
(append (list ;(service home-dankmaterialshell-service-type
; (home-dankmaterialshell-configuration
; (launch-command (file-append niri "/bin/niri msg action spawn-sh --"))))
(service home-niri-service-type
(niri-configuration
(environment-variables (list (string-append "DMSDEFAULTCONFIG=" (package-output (open-connection) dankmaterialshell) "/share/quickshell")))))
(service home-pipewire-service-type)
(service home-wayland-service-type)
;(service home-wayland-service-type)
(service home-dbus-service-type)
(service home-bash-service-type
(home-bash-configuration

View file

@ -0,0 +1,144 @@
(define-module (guix-config packages fonts)
#:use-module (ice-9 regex)
#:use-module (guix utils)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix build-system font)
#:use-module (guix build-system gnu)
#:use-module (guix build-system meson)
#:use-module (guix build-system trivial)
#:use-module (guix build-system copy)
#:use-module (gnu packages)
#:use-module (gnu packages c)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gd)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gtk)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-compression)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages sdl)
#:use-module (gnu packages xorg)
#:export (font-nerd-fonts-symbols-mono))
(define-public font-nerd-fonts-symbols-mono
(package
(name "font-nerd-fonts-symbols-mono")
(version "3.3.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/ryanoasis/nerd-fonts")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"0qlj9lgc0qlgqk716136p1f3c2kvzphkm4q0iy4isj0gz76iqrx0"))
(modules '((guix build utils)))
(snippet
#~(begin
;; Remove large patched-fonts directory to save space and build time
(delete-file-recursively "patched-fonts")))))
(build-system gnu-build-system)
(arguments
(list
#:tests? #f ; No test suite
#:phases
#~(modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(font-dir (string-append out "/share/fonts/truetype"))
(blank-font "src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsNerdFontBlank.sfd"))
;; Ensure output directory exists
(mkdir-p font-dir)
;; Set HOME to avoid fontforge warnings
(setenv "HOME" (getcwd))
;; Patch the blank font to create Symbols Only Mono
;; --complete: Include all icon sets
;; --mono: Create monospaced glyphs (fixed width)
;; --ext ttf: Generate TrueType font
;; --no-progressbars: Disable progress bars for clean build output
(invoke "fontforge" "-script" "font-patcher"
"--complete"
"--mono"
"--ext" "ttf"
"--no-progressbars"
"--outputdir" font-dir
blank-font))))
(add-after 'install 'check-font
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(font-dir (string-append out "/share/fonts/truetype"))
(font-file (string-append font-dir "/SymbolsNerdFontMono-Regular.ttf")))
;; Verify the font file exists
(unless (file-exists? font-file)
(error "Font file was not generated!"))
;; Use Python script with fontforge to validate the font
(invoke "python3" "-c"
(string-append
"import fontforge\n"
"font = fontforge.open('" font-file "')\n"
"glyph_count = len([g for g in font.glyphs() if g.unicode > 0])\n"
"print(f'Font has {glyph_count} glyphs with Unicode mapping')\n"
"if glyph_count < 8000:\n"
" raise ValueError(f'Font has too few glyphs: {glyph_count}')\n"
"print('✓ Font validation passed')\n"
"font.close()\n"))
(format #t "✓ Font validation successful: ~a~%" font-file)))))))
(native-inputs
(list fontforge python))
(home-page "https://www.nerdfonts.com/")
(synopsis "Monospaced symbol font containing Nerd Fonts icon glyphs")
(description
"This package provides the Nerd Fonts Symbols Only font in monospaced
variant, built from source using the Nerd Fonts patcher. It contains only the
icon glyphs from Nerd Fonts without any base font, making it suitable for use
as a fallback font for icon display in terminals and text editors such as Kitty.
The font includes glyphs from multiple icon sets:
@itemize
@item Powerline with Extra Symbols
@item Font Awesome and Font Awesome Extension
@item Material Design Icons
@item Weather Icons
@item Devicons
@item Octicons
@item Font Logos (formerly Font Linux)
@item Pomicons
@item Codeicons
@end itemize
The monospaced variant ensures all glyphs have uniform width, which is
essential for terminal emulators that require consistent character spacing.
@strong{Licensing:} This package combines glyphs from multiple sources:
@itemize
@item MIT: Nerd Fonts patcher and scripts
@item SIL OFL-1.1: Various font glyphs (Powerline, Devicons, Octicons, etc.)
@item Apache-2.0: Codicons, Material Design Icons
@item CC-BY-4.0: Font Awesome icons
@end itemize")
(license (list license:expat
license:silofl1.1
license:asl2.0
license:cc-by4.0))))