Home-manager: update to nerd fonts breaks kitty

Note: this was discussed in a different post but the solution listed there doesn’t work.

A recent update to the way nerd fonts are packaged broke my kitty config, which contains this line:

font_family      family='FiraCode Nerd Font Mono'

I’m on Ubuntu with home-manager. After updating my flake and modifying the nerd front package to match the new syntax, nerd-fonts.fira-code, kitty fails to start with this output:

fast_data_types.FreeTypeError: Failed to load face from path: /home/jordan/.nix-profile/share/fonts/truetype/NerdFonts/FiraCodeNerdFontMono-Regular.ttf with error: cannot open resource
[0.054] Failed to convert descriptor to face for medium font

Looking inside that directory, it appears that there is now a nested FiraCode directory:

❯ tree ~/.nix-profile/share/fonts/truetype/NerdFonts
/home/jordan/.nix-profile/share/fonts/truetype/NerdFonts
└── FiraCode
    ├── FiraCodeNerdFont-Bold.ttf
    ├── FiraCodeNerdFont-Light.ttf
    ├── FiraCodeNerdFont-Medium.ttf
    ├── FiraCodeNerdFontMono-Bold.ttf
    ├── FiraCodeNerdFontMono-Light.ttf
    ├── FiraCodeNerdFontMono-Medium.ttf
    ├── FiraCodeNerdFontMono-Regular.ttf
    ├── FiraCodeNerdFontMono-Retina.ttf
    ├── FiraCodeNerdFontMono-SemiBold.ttf
    ├── FiraCodeNerdFontPropo-Bold.ttf
    ├── FiraCodeNerdFontPropo-Light.ttf
    ├── FiraCodeNerdFontPropo-Medium.ttf
    ├── FiraCodeNerdFontPropo-Regular.ttf
    ├── FiraCodeNerdFontPropo-Retina.ttf
    ├── FiraCodeNerdFontPropo-SemiBold.ttf
    ├── FiraCodeNerdFont-Regular.ttf
    ├── FiraCodeNerdFont-Retina.ttf
    └── FiraCodeNerdFont-SemiBold.ttf

Any suggestions on why kitty can’t find the font now?

I have tried fc-cache -r and fc-cache -f with no success.

My kitty broke when I disabled my WM, niri. In my case it was a matter of setting

fonts.enableDefaultPackages = true;

fonts.enableDefaultPackages is a NixOS option. The problem I’m experiencing here is on non-NixOS (Ubuntu 24.04) with home-manager.

Something I noticed: If I specify the exact path in kitty.conf like this:

font_family      ~/.nix-profile/share/fonts/truetype/NerdFonts/FiraCode/FiraCodeNerdFontMono-Regular.ttf

Then kitty will open. However, this seems prone to breakage.

I “solved” the issue (more of a workaround):

In my home-manager config, I removed nerd-fonts.fira-code and added fira-code. Then, I regenerated my fontconfig cache with fc-cache -r. Finally, in kitty.conf I changed font_family to Fira Code.

Now it works as expected.