Latest update breaks nerdfonts declared in home-manager

Hi there,
I used to declare the jetbrains mono nerd font in home manager like this:

  home.packages = with pkgs; [
    (nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
  ];
  fonts.fontconfig.enable = true;

Recently I’ve updated my flake and nixos-rebuild informed me of the new syntax of nerd-fonts, so now I have:

...
  nerd-fonts.jetbrains-mono
...

However it doesn’t work and apps can’t find the font. This is the error from kitty for example:

fast_data_types.FreeTypeError: Failed to load face from path: /home/me/.nix-profile/share/fonts/truetype/NerdFonts/JetBrainsMonoNerdFont-SemiBold.ttf with error: cannot open resource
[0.072] Failed to convert descriptor to face for bold font

I’ve examined this path and it turns out all jetbrainsmono fonts are now placed under NerdFonts/JetBrainsMono while kitty is looking for it one directory higher.

At the same time setting this font in nixos configuration works just fine.

How do I fix it?

The PR that is affecting you is nerdfonts: separate into individual font packages, 3.2.1 -> 3.3.0 by rc-zb · Pull Request #354543 · NixOS/nixpkgs · GitHub and as improvement for the error message nerd-fonts: improve alias throw to give example migration by anund · Pull Request #362769 · NixOS/nixpkgs · GitHub

According the migration content in the pr you want to switch to

 home.packages = with pkgs; [
    nerd-fonts.jetbrains-mono
];

Which should be equivalent to your old declaration as far as i can see.

edit: nvm, saw that you tried that out

edit2:
You might want to double check your kitty config if that is refering the path somewhere.
What i actually see is that there is a change in the path from share/fonts/truetype/NerdFonts/JetBrainsMonoNerdFont-SemiBold.ttf to share/fonts/truetype/NerdFonts/JetBrainsMono/JetBrainsMonoNerdFont-SemiBold.ttf , so either the config or some font cache might refer to the old/wrong font location

2 Likes

That helped!! Thank you! fc-cache -f fixed the issue. It also explains why the same configuration didn’t produce any problems on my other machine.

Now the question is why should I use an imperative command? Seems like a bug.

edit: this problem is discussed in this github issue

1 Like

Weird, I’m seeing that fc-cache -r (you need -r not just -f) is working for everything except kitty. I literally even uninstalled and re-installed all of nix in my non-NixOS system and still kitty (built from nix) is looking in the non-existent location that has never existed or had fonts in it as long as kitty has been present.
I’m also seeing numerous other people reporting the same thing, specifically with kitty.

What did you do to get kitty to look in the new locations? I’ve updated my flakes to get the latest kitty from nix-unstable, I don’t see anything hardcoded in the kitty derivation that would explain the paths that don’t exist, and I’ve verified repeatedly that fc-list and sudo fc-list don’t list anything that’s directly in the NerdFonts folder.

I had the same issue with waybar as well, not just kitty.

But fc-cache -f (I didn’t even need -r) fixed it for both of them

1 Like