Enable local font access with Nix on foreign distro?

How do I enable access to my locally-installed fonts when running the Nix package manager on top of a non-Nix distro? I’m here particularly interested in getting Firefox installed via Nix to be able to access all of the fonts on my machine.

So far this is only possible in an automated fashion for single users by using home-manager.
A different option to make fonts available might be to symlink ~/.nix-profile/share/fonts/ to a directory where your linux distribution expects font to be (e.x. /usr/local/share/fonts or ~/.local/share/fonts/).

1 Like

Thanks! I’ll look at those options.

I haven’t had much luck with symlinks. I think there’s some other issue. I’ve installed the google-fonts package via Nix, and I can see that there is already a symlinked fonts directory (which contains all of the Google fonts from Nix’s google-fonts package), and none of these seem to be accessible.

I see an info page on NixOS and fonts here - Fonts - NixOS Wiki - which seems to suggest that something more needs doing to enable access to fonts, but I don’t know if that also applies to single-user Nix on a foreign distro.

The configuration Home Manager produces for this is very simple and easy to redo manually. Create a file ~/.config/fontconfig/conf.d/10-nix-profile-fonts.conf containing

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>

Afterwards I think most things should be able to see the fonts.

I’m still not having any luck after creating the .conf manually as described (even after a reboot).

it’s odd, because I can see that ~/.nix-profile/share/fonts is symlinked to /nix/store/.....google-fonts.../share/fonts, so I would think the Nix packaged Firefox should at least be able to access those fonts (i.e. the Nix package Google fonts), but no such luck.

It may be a complication deriving from the fact that the base OS is GuixSD (which is the reason I’m trying to use Nix for Firefox, because Guix doesn’t package it). It is frustrating though, and I don’t have a deep enough understanding of Nix to have any clear idea of what could be the root cause/how to fix it.