The incompatibility does not seem to exist any more: programs linked against fc 2.12
on fc 2.14 system seem to at least display text, even while printing tons of errors
(as long as you generate fc cache manually), and same thing the other way around.
Hopefully it will not be an issue in the future.
This reverts commit edf2541f02.
Turns out lot of software (including Chromium) use bundled fontconfig
so we either need to wrap every one of those, or re-introduce the global
unversioned config. The latter is easier but weakens hermetic configs.
But perhaps those are not really worth the effort. Given that programs
linked against fc 2.12.6 on fc 2.13.92 system seem to at least display text,
even while printing tons of errors (as long as you generate fc cache manually),
and same thing the other way around, hopefully it will not be an issue in the future.
We give up on the hermetic configs in exchange for getting rid of lot of complexity.
ITS rules are used for extracting translatable strings and they have
been moved to external files in 2.13.92 so they are not needed in
the config files themselves.
Removing them also cuts down on errors/warnings produced when using
older versions of fontconfig (< 2.12.92). Now it will only complain
about the description element but that is fortunately just a warning,
not errors like the ones caused by the its attributes.
Thanks to this, we can change the config version in NixOS module
back to 2.11 allowing us to re-use the 2.13/2.14 configs for apps
built against 2.12 fontconfig.
With previous patch, we no longer load non-versioned fonts.conf file to avoid incompatibilities
but this also means fontconfig will not load system-wide installed fonts on non-NixOS systems.
As a compromise, let's hardcode the FHS font paths to the built-in config so that the system
fonts work there. Unlike with the system config we do not need to worry about compatibility as
incompatible font files will be simply ignored.
Of course there will still be disparity if the system install fonts to some other location than
these two but I am afraid this is the best we can do.
See https://github.com/NixOS/nixpkgs/pull/73795#issuecomment-635771967 for discussion.
Falling back to unversioned `/etc/fonts/conf.d` when versioned one does not exist
is problematic since it only occurs on non-NixOS systems and those are likely
to have a different version of fontconfig. When those versions use incompatible
elements in the config, apps using fontconfig will crash.
Instead, we are now falling back to the in-package `fonts.conf` file that loads
both the versioned global `conf.d` directory and the in-package `conf.d` since using
upstream settings on non-NixOS is preferable to not being able to use apps there.
In fact, we would not even need to link `fonts.conf`, as the in-package `fonts.conf`
will be always used unless someone creates the global one manually (the option is still
retained if one wants to write a custom NixOS module and to avoid unnecessary stat call on NixOS).
Additionally, since the `fonts.conf` will always load `conf.d` from the package, we no longer
need to install them to sytem `/etc` in the module. This needed some mucking with `50-user.conf`
which disables configs in user directories (a good thing IMO, NixOS module will turn it back on)
but otherwise, it is cleaner. The files are still prioritized by their name, regardless of their location.
See https://github.com/NixOS/nixpkgs/pull/73795#issuecomment-634370125 for more information.
This commit fixes missing fc-cache binary from make-fonts-cache.nix build:
```
builder for '/nix/store/az48nr8gdqrw3fliddmi82ghj2ljxrj4-fc-cache.drv' failed with exit code 127; last 1 log lines:
/nix/store/p3z1lgsi7xymvl7akg531ikwiisqs4x5-stdenv-linux/setup: line 1299: fc-cache: command not found
cannot build derivation '/nix/store/swaxvjsf8h0rsmm9kigp6j3f5q5h4nvg-fc-00-nixos-cache.conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/wiaiv0pq7w1xm2i2fqp2ngd1ljb4n6n9-fontconfig-conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/4zhiwpiyccs0rs26bs3q0w8fwaxrrgw0-fontconfig-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/xhvljdp9b00fbkapx6cbfs4sjdh49qwv-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/w63q0n0vh7vkdfrjmhb41qy1alx7qa8s-nixos-system-nixos-19.09.git.c814289.drv': 1 dependencies couldn't be built
```
The hack of using `crossConfig` to enforce stricter handling of
dependencies is replaced with a dedicated `strictDeps` for that purpose.
(Experience has shown that my punning was a terrible idea that made more
difficult and embarrising to teach teach.)
Now that is is clear, a few packages now use `strictDeps`, to fix
various bugs:
- bintools-wrapper and cc-wrapper
HFS+ (still common on macOS machines) only has a
date resolution of 1 second. This change makes sure that
`fcobjshash.h` gets a newer timestamp than `fcobjshash.gperf`.
A CACHEDIR.TAG file indicates that the contents can be automatically
re-generated. This is not really true for Nix store paths. (Well _Nix_
can recreate them, but that's different.)
I noticed this issue as I was restoring full system backup that "for
some reason" always missed /nix/store/*-fc-cache (found by `nix-store
--verify --repair`). Turns out I was excluding caches from my backup...
Commit 9b049849bf deleted the patch file
(and reference to it from fontconfig default.nix), but left the one in
2.10.nix which break evaluation.
As the package seems to build fine without the patch, just remove the
reference.
cc @ttuegel in case this was not the correct thing to do.