nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 50 lines 1.2 kB view raw
1{ 2 buildPackages, 3 writeText, 4 fontconfig, 5 lib, 6 runCommand, 7 stdenv, 8}: 9let 10 fontconfig' = fontconfig; 11in 12{ 13 fontconfig ? fontconfig', 14 fontDirectories, 15}: 16 17let 18 fontDirsPath = writeText "font-dirs" '' 19 <!-- Font directories --> 20 ${lib.concatStringsSep "\n" (map (font: "<dir>${font}</dir>") fontDirectories)} 21 ''; 22in 23runCommand "fc-cache" 24 { 25 preferLocalBuild = true; 26 allowSubstitutes = false; 27 } 28 '' 29 export FONTCONFIG_FILE=$(pwd)/fonts.conf 30 31 cat > fonts.conf << EOF 32 <?xml version='1.0'?> 33 <!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'> 34 <fontconfig> 35 <include>${fontconfig.out}/etc/fonts/fonts.conf</include> 36 <cachedir>$out</cachedir> 37 EOF 38 cat "${fontDirsPath}" >> fonts.conf 39 echo "</fontconfig>" >> fonts.conf 40 41 # N.B.: fc-cache keys its cache entries by architecture. 42 # We must invoke the host `fc-cache` (not the build fontconfig) if we want 43 # the cache to be usable by the host. 44 mkdir -p $out 45 ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe' fontconfig "fc-cache"} -sv 46 47 # This is not a cache dir in the normal sense -- it won't be automatically 48 # recreated. 49 rm -f "$out/CACHEDIR.TAG" 50 ''