Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Nerd fonts will probably not be usable anymore after nixpkgs 25.11 #6160

Open
2 tasks done
gautaz opened this issue Dec 1, 2024 · 4 comments
Open
2 tasks done
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@gautaz
Copy link

gautaz commented Dec 1, 2024

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

Hello,

I am using home-manager with nixpkgs in a flake, both on master.
Lately a modification occurred on nixpkgs on how the nerdfonts are packaged (see NixOS/nixpkgs@de4dbc5).
Since this modification, alacritty seems unable to load the fonts.

Following are my findings while looking at the issue.

Here are the Alacritty logs:

alacritty -vvv
Created log file at "/tmp/Alacritty-362931.log"
[0.000005494s] [INFO ] [alacritty] Welcome to Alacritty
[0.000146170s] [INFO ] [alacritty] Version 0.14.0
[0.000172330s] [INFO ] [alacritty] Running on X11
[0.000465610s] [INFO ] [alacritty] Configuration files loaded from:
                                     "/home/del/.config/alacritty/alacritty.toml"
[0.014992067s] [INFO ] [alacritty] Using GLX 1.4
[0.036289958s] [DEBUG] [alacritty] Picked GL Config:
                                     buffer_type: Some(Rgb { r_size: 8, g_size: 8, b_size: 8 })
                                     alpha_size: 8
                                     num_samples: 0
                                     hardware_accelerated: true
                                     supports_transparency: Some(true)
                                     config_api: Api(OPENGL | GLES1 | GLES2)
                                     srgb_capable: false
[0.037263012s] [INFO ] [alacritty] Window scale factor: 1.5
[0.039188894s] [DEBUG] [alacritty] Loading "UbuntuMono Nerd Font" font
[0.043615403s] [TRACE] [crossfont] Number of fonts is 18
[0.043643459s] [TRACE] [crossfont] Got font path="/home/del/.nix-profile/share/fonts/truetype/NerdFonts/UbuntuMonoNerdFont-Regular.ttf", index=0
[0.043661603s] [ERROR] [alacritty] Cannot open resource

The font path used by alacritty is the one listed by fc-list:

fc-list | grep UbuntuMonoNerdFont-Regular.ttf
/home/del/.nix-profile/share/fonts/truetype/NerdFonts/UbuntuMonoNerdFont-Regular.ttf: UbuntuMono Nerd Font:style=Regular
/nix/store/g2q1gshfnqdnbidgp1my1iwm5747iqng-home-manager-path/share/fonts/truetype/NerdFonts/UbuntuMono/UbuntuMonoNerdFont-Regular.ttf: UbuntuMono Nerd Font:style=Regular

But the path is obviously not the right one:

ls /home/del/.nix-profile/share/fonts/truetype/NerdFonts/UbuntuMonoNerdFont-Regular.ttf
ls: cannot access '/home/del/.nix-profile/share/fonts/truetype/NerdFonts/UbuntuMonoNerdFont-Regular.ttf': No such file or directory

The fonts are in fact located here:

ls /home/del/.nix-profile/share/fonts/truetype/NerdFonts/UbuntuMono/
UbuntuMonoNerdFont-BoldItalic.ttf  UbuntuMonoNerdFontMono-BoldItalic.ttf  UbuntuMonoNerdFontMono-Regular.ttf      UbuntuMonoNerdFontPropo-Italic.ttf
UbuntuMonoNerdFont-Bold.ttf        UbuntuMonoNerdFontMono-Bold.ttf        UbuntuMonoNerdFontPropo-BoldItalic.ttf  UbuntuMonoNerdFontPropo-Regular.ttf
UbuntuMonoNerdFont-Italic.ttf      UbuntuMonoNerdFontMono-Italic.ttf      UbuntuMonoNerdFontPropo-Bold.ttf        UbuntuMonoNerdFont-Regular.ttf

If anyone has an idea of how to fix/workaround this, I will be happy to try 🙂.

Maintainer CC

@rycee

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.6.63, NixOS, 25.05 (Warbler), 25.05.20241128.d584552`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.10`
 - nixpkgs: `/etc/nixpkgs/channels/nixpkgs`
@gautaz gautaz added bug triage Issues or feature request that have not been triaged yet labels Dec 1, 2024
@poopsicles
Copy link

poopsicles commented Dec 1, 2024

Not really sure if this is what you're asking for, but since they moved the Nerd Fonts to a new package, I recently had to update my home.nix:

  • First, change your font packages to pkgs.nerd-fonts.font-name.
    So my config changed:

    home.packages = [
      ...
    - (pkgs.nerdfonts.override {
    -    fonts = ["CodeNewRoman" "FiraCode"];
    - })
    + pkgs.nerd-fonts.fira-code
    + pkgs.nerd-fonts.code-new-roman
    ]
  • Switch to the latest generation (I'm using flakes, so home-manager switch --flake .)

  • Even after doing this, GNOME Fonts was showing blank box characters for the fonts1, and kitty was failing to open with this message "Failed to convert descriptor to face for medium font" because it was, like you said, looking in the older NerdFonts/ directory for font.ttf instead of digging into NerdFonts/Family/font.ttf.

    I restarted a couple of times, but after looking through fc-list and noticing there was an entry to the old version, rebuilding the font cache with fc-cache -rv worked (-r means "really force". v means verbose) fixed things; Fonts displays them well now, kitty runs fine.

I'm surprised home-manager switch doesn't reload the font cache, because I thought it does (maybe it does lol but not with the "yes force everything" option.

Footnotes

  1. image

@cloudlena
Copy link
Contributor

cloudlena commented Dec 1, 2024

Thanks, @poopsicles! Running fc-cache -rv fixed it for me 😊

@poopsicles
Copy link

poopsicles commented Dec 1, 2024

I'm surprised home-manager switch doesn't reload the font cache, because I thought it does (maybe it does lol but not with the "yes force everything" option.

Looked around and found #520, which linked to #682 which added in this file:

${getBin pkgs.fontconfig}/bin/fc-cache -f
rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG
rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig/cache
rm "$FONTCONFIG_FILE"
unset FONTCONFIG_FILE

So it does refresh the cache, but with -f over r, the differences between them which are:

$ fc-cache -h
...
-f, --force                 scan directories with apparently valid caches
-r, --really-force       erase all existing caches, then rescan
...

I'm not sure if that needs to be switched to -r, especially since they seem to be removing the cache directory afterwards anyways (maybe $out is actually the flake or something...Nix confuses me)

But anyways, tl;dr is to force the cache to actually get cleared first if any font problems occur (though that's probably unlikely...in this case the folder structure of the fonts was changed).

@gautaz
Copy link
Author

gautaz commented Dec 1, 2024

Hello @poopsicles,

Thanks for your fix!

First, change your font packages to pkgs.nerd-fonts.font-name.

Yes, this one was already done.

rebuilding the font cache with fc-cache -rv worked

This is what was missing 🙂.

My assumption was that home-manager was already doing this, but seems it is not, good catch 👍.

Looking back at #682, it is in fact:

${getBin pkgs.fontconfig}/bin/fc-cache -f

Perhaps @rycee has more insight on this matter.

waldirborbajr added a commit to waldirborbajr/cavelab that referenced this issue Dec 2, 2024
@teto teto changed the title bug: Nerd fonts will probably not be usable anymore after nixpkgs 25.05 bug: Nerd fonts will probably not be usable anymore after nixpkgs 25.11 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

6 participants