forked from mirrors/nixpkgs
Merge branch 'fontconfig-caches' into staging
Closes #12668, fixes #12648
This commit is contained in:
commit
53e0f8b1cd
|
@ -129,6 +129,14 @@ with lib;
|
|||
|
||||
};
|
||||
|
||||
cache32Bit = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Generate system fonts cache for 32-bit applications.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -231,12 +239,19 @@ with lib;
|
|||
"${pkgs.fontconfig}/etc/fonts/fonts.conf";
|
||||
|
||||
environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/00-nixos.conf".text =
|
||||
''
|
||||
let
|
||||
cache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; };
|
||||
in ''
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
||||
<fontconfig>
|
||||
<!-- Font directories -->
|
||||
${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.fonts)}
|
||||
<!-- Pre-generated font caches -->
|
||||
<cachedir>${cache pkgs.fontconfig}</cachedir>
|
||||
${optionalString (pkgs.stdenv.isx86_64 && config.fonts.fontconfig.cache32Bit) ''
|
||||
<cachedir>${cache pkgs.pkgsi686Linux.fontconfig}</cachedir>
|
||||
''}
|
||||
</fontconfig>
|
||||
'';
|
||||
|
||||
|
|
27
pkgs/development/libraries/fontconfig/make-fonts-cache.nix
Normal file
27
pkgs/development/libraries/fontconfig/make-fonts-cache.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ runCommand, lib, writeText, fontconfig, fontbhttf, fontDirectories }:
|
||||
|
||||
runCommand "fc-cache"
|
||||
rec {
|
||||
buildInputs = [ fontconfig ];
|
||||
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}/etc/fonts/fonts.conf</include>
|
||||
<cachedir>$out</cachedir>
|
||||
EOF
|
||||
cat "$fontDirsPath" >> fonts.conf
|
||||
echo "</fontconfig>" >> fonts.conf
|
||||
|
||||
mkdir -p $out
|
||||
fc-cache -sv
|
||||
''
|
|
@ -23,16 +23,16 @@
|
|||
<fontconfig>
|
||||
<xsl:apply-templates select="child::node()[name() != 'dir' and name() != 'cachedir' and name() != 'include']" />
|
||||
|
||||
<!-- fontconfig distribution conf.d -->
|
||||
<include><xsl:value-of select="$fontconfig" />/etc/fonts/conf.d</include>
|
||||
<!-- versioned system-wide config -->
|
||||
<include ignore_missing="yes">/etc/fonts/<xsl:value-of select="$fontconfigConfigVersion" />/conf.d</include>
|
||||
|
||||
<!-- the first cachedir will be used to store the cache -->
|
||||
<cachedir prefix="xdg">fontconfig</cachedir>
|
||||
<!-- /var/cache/fontconfig is useful for non-nixos systems -->
|
||||
<cachedir>/var/cache/fontconfig</cachedir>
|
||||
|
||||
<!-- fontconfig distribution conf.d -->
|
||||
<include><xsl:value-of select="$fontconfig" />/etc/fonts/conf.d</include>
|
||||
<!-- versioned system-wide config -->
|
||||
<include ignore_missing="yes">/etc/fonts/<xsl:value-of select="$fontconfigConfigVersion" />/conf.d</include>
|
||||
|
||||
<dir prefix="xdg">fonts</dir>
|
||||
<xsl:for-each select="str:tokenize($fontDirectories)">
|
||||
<dir><xsl:value-of select="." /></dir>
|
||||
|
|
|
@ -6520,6 +6520,11 @@ let
|
|||
inherit fontconfig fontDirectories;
|
||||
};
|
||||
|
||||
makeFontsCache = let fontconfig_ = fontconfig; in {fontconfig ? fontconfig_, fontDirectories}:
|
||||
callPackage ../development/libraries/fontconfig/make-fonts-cache.nix {
|
||||
inherit fontconfig fontDirectories;
|
||||
};
|
||||
|
||||
freealut = callPackage ../development/libraries/freealut { };
|
||||
|
||||
freeglut = callPackage ../development/libraries/freeglut { };
|
||||
|
|
Loading…
Reference in a new issue