NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.86k stars 13.93k forks source link

fontconfig ignoring fonts installed with nix-env #8318

Open kirelagin opened 9 years ago

kirelagin commented 9 years ago

(Not on NixOS.)

I’m not really sure why but, well, fontconfig ignores my ~/.nix-profile/share/fonts.

› /nix/store/bc3sk492zcv744qfj8nnrlbw9yl6gmnk-fontconfig-2.11.1/bin/fc-cache -v | grep nix-profile
›

even though its config tells it to look there:

› cat /nix/store/bc3sk492zcv744qfj8nnrlbw9yl6gmnk-fontconfig-2.11.1/etc/fonts/fonts.conf | grep nix-profile                                                                               <1>
<dir>~/.nix-profile/lib/X11/fonts</dir><dir>~/.nix-profile/share/fonts</dir><dir>/nix/var/nix/profiles/default/lib/X11/fonts</dir><dir>/nix/var/nix/profiles/default/share/fonts</dir></fontconfig>

Any ideas?

kirelagin commented 9 years ago

By the way, my system fontconfig (which includes ~/.config/fontconfig/fonts.conf and is told there to check the ~/.nix-profile/share/fonts directory) works fine:

› fc-cache -v | grep nix-profile
/home/kirrun/.nix-profile/share/fonts: skipping, existing cache is valid: 0 fonts, 1 dirs
/home/kirrun/.nix-profile/share/fonts/opentype: skipping, existing cache is valid: 7 fonts, 0 dirs
Re-scanning /home/kirrun/.nix-profile/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
lucabrunox commented 9 years ago

@kirelagin I haven't understood the difference between the first comment and the second.

kirelagin commented 9 years ago

@lethalman The first one uses fc-cache from the nix store, the second one uses the system fc-cache (this is not NixOS). I’m just trying to say that the directory is there and the fonts are visible. I don’t understand why fontconfig from the store doesn’t even try to read the directory, since it’s clearly told to do so in its config.

kirelagin commented 9 years ago

Ok, I got it. The problem is fontconfig being horribly inconsistent. It reads my system fonts.conf but assumes that the config directory is in $out, so when it sees <include ignore_missing="yes">conf.d</include> in my system config it goes to $out/etc/fonts/conf.d and reads configs from there.

Since here on Gentoo user config is included from /etc/fonts/conf.d/50-user.conf, my user config is actually never getting included.

It should definitely be reading files only from one source. As far as I can tell, by default it would be reading everything (including fonts.conf) from $out/etc/fonts/ and this does make sense in my opinion, but this patch breaks this. @vcunat

kirelagin commented 9 years ago

If the intention was to let NixOS have its completely separate fonts configuration, then, keeping in mind the fact that we definitely want working fontconfig on non-NixOS, it might be better to:

edolstra commented 9 years ago

We don't want NixOS to have separate fonts configuration. The only reason for those patches is to work around fontconfig version incompatibilities (requiring us to have different config files for 2.10 and 2.11, IIRC).

I guess we just need to build Fontconfig with --sysconfdir=/etc to ensure <include ignore_missing="yes">conf.d</include> is resolved properly on Gentoo.

lucabrunox commented 9 years ago

@edolstra yes that should be sufficient. We use absolute paths in our fonts.conf so it won't be a problem.

kirelagin commented 9 years ago

This probably means that fontconfig in nixpkgs shouldn’t ship any kind of fonts.conf. On other distros the config will be already present in /etc and on NixOS the fontconfig module will generate one.

jagajaga commented 8 years ago

Ping all.

kirelagin commented 8 years ago

So, what this all fontconfig 2.10 thing is about? I don’t see it being used anywhere in nixpkgs. Can’t we just drop this backward compatibility, the patch and forget about the issue? @edolstra @lethalman

vcunat commented 8 years ago

That should be unrelated to the problems described in the title. It's to support running stuff built previously against fontconfig 2.10.

SevereOverfl0w commented 8 years ago

Just as a tide-over for others experiencing this, I modified my /etc/fonts/fonts.conf, to use the absolute path to the conf.d folder, it isn't a great fix, but it saves me from experiencing Oswalds Font everywhere!

johan-boule commented 7 years ago

@SevereOverfl0w : Thank you for the workaround, it worked for me too.

knedlsepp commented 6 years ago

I'm non-root on a non-NixOS system trying to view pdfs that stem from Microsoft office. I could finally properly view the pdfs via:

nix-env -iA nixpkgs.corefonts

and symlinking the fonts to ~/.local/share/fonts via:

ln -sf ~/.nix-profile/share/fonts/ ~/.local/share/fonts/nix-fonts
doronbehar commented 5 years ago

It's too bad this issue is still open, I'll confirm though that @knedlsepp's workaround is working so thanks!

knedlsepp commented 5 years ago

I guess https://github.com/rycee/home-manager might also be a viable Option.

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.