veken.io

Home

I use home-manager to install most of my programs and manage my configuration. I follow the master branch because I like to live dangerously, but it came back to bite me. When I ran home-manager switch to update my packages I ran into an error that said that I need to update my configuraton to continue using nerd fonts. (I unfortunately did not save the error.)

I updated my config from

1
2
3
home.packages = [
  (pkgs.nerdfonts.override { fonts = [ "FiraCode" ]; })
]

to

1
2
3
home.packages = [
  pkgs.nerd-fonts.fira-code
]

and ran home-manager switch again. And everything was fine, until I rebooted my laptop. The icons on waybar were gone and I was no longer able to open a terminal. I did not immediately connect these problems with the font update. I logged into a KDE session and started Konsole to see what was going on. I now realise I would’ve been able to do that in Sway as well. I used Konsole to start foot and got the following error.

err: fcft.c:607: /home/stijn/.nix-profile/share/fonts/truetype/NerdFonts/FiraCodeNerdFont-Bold.ttf: failed to create FreeType face; cannot open resource

I checked and the file was there, maybe the problem was that is was owned by root? I tried to run fc-cache but that didn’t help. Now home-manager switch complained that there is config in the way and I need to create a backup. I tried to run foot with foot -f monospace and that worked. That atleast confirms that this is an issue with the font.

Checking fc-list it doesn’t list FiraCode at all, so it doesn’t seem to exist as far as font config is concerned. After some searching I finally found this issue that let to a solution. You need to run fc-cache -r with a binary installed through nix. That makes sense since it will have knowledge about everything installed through nix. After this foot and waybar worked again.

It might be a good idea to pin nixpkgs and home-manager to the same release so I don’t get caught by suprise again like this. That will also fix the issue of running home-manager and nixpkgs on different channel version when one is ahead of the other.