nixpkgs/pkgs/development/libraries/fontconfig/make-fonts-cache.nix
Eyal Kalderon a95e0ac8e4 makeFontsCache: Fix cross-compiling, missing fc-cache
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
```
2019-11-13 16:32:30 +01:00

34 lines
877 B
Nix

{ runCommand, lib, fontconfig, fontDirectories }:
runCommand "fc-cache"
{
nativeBuildInputs = [ fontconfig.bin ];
preferLocalBuild = true;
allowSubstitutes = false;
passAsFile = [ "fontDirs" ];
fontDirs = ''
<!-- Font directories -->
${lib.concatStringsSep "\n" (map (font: "<dir>${font}</dir>") fontDirectories)}
'';
}
''
export FONTCONFIG_FILE=$(pwd)/fonts.conf
cat > fonts.conf << EOF
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<include>${fontconfig.out}/etc/fonts/fonts.conf</include>
<cachedir>$out</cachedir>
EOF
cat "$fontDirsPath" >> fonts.conf
echo "</fontconfig>" >> fonts.conf
mkdir -p $out
fc-cache -sv
# This is not a cache dir in the normal sense -- it won't be automatically
# recreated.
rm -f "$out/CACHEDIR.TAG"
''