Skip to content

Commit

Permalink
fontconfig: update 2.10.2 -> 2.11.1. Closes NixOS#2050
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Bruno committed Oct 19, 2014
1 parent b5fe0d3 commit 2641ee3
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 30 deletions.
27 changes: 25 additions & 2 deletions nixos/modules/config/fonts/fontconfig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ with lib;

config = mkIf config.fonts.enableFontConfig {

# Bring in the default (upstream) fontconfig configuration.
# Fontconfig 2.10 backward compatibility

# Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10
environment.etc."fonts/fonts.conf".source =
pkgs.makeFontsConf { fontDirectories = config.fonts.fonts; };
pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; };

environment.etc."fonts/conf.d/00-nixos.conf".text =
''
Expand All @@ -47,6 +49,27 @@ with lib;
</fontconfig>
'';

# Versioned fontconfig > 2.10. Only specify font directories.

environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/00-nixos.conf".text =
''
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- Set the default hinting style to "slight". -->
<match target="font">
<edit mode="assign" name="hintstyle">
<const>hintslight</const>
</edit>
</match>
<!-- Font directories -->
${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.fonts)}
</fontconfig>
'';

environment.systemPackages = [ pkgs.fontconfig ];

};
Expand Down
8 changes: 0 additions & 8 deletions nixos/modules/config/fonts/fonts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ with lib;
type = types.listOf types.path;
example = literalExample "[ pkgs.dejavu_fonts ]";
description = "List of primary font paths.";
apply = list: list ++
[ # - the user's current profile
"~/.nix-profile/lib/X11/fonts"
"~/.nix-profile/share/fonts"
# - the default profile
"/nix/var/nix/profiles/default/lib/X11/fonts"
"/nix/var/nix/profiles/default/share/fonts"
];
};

};
Expand Down
61 changes: 61 additions & 0 deletions pkgs/development/libraries/fontconfig/2.10.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{ stdenv, fetchurl, pkgconfig, freetype, expat }:

stdenv.mkDerivation rec {
name = "fontconfig-2.10.2";

src = fetchurl {
url = "http://fontconfig.org/release/${name}.tar.bz2";
sha256 = "0llraqw86jmw4vzv7inskp3xxm2gc64my08iwq5mzncgfdbfza4f";
};

infinality_patch =
let subvers = "1";
in fetchurl {
url = http://www.infinality.net/fedora/linux/zips/fontconfig-infinality-1-20130104_1.tar.bz2;
sha256 = "1fm5xx0mx2243jrq5rxk4v0ajw2nawpj23399h710bx6hd1rviq7";
}
;

propagatedBuildInputs = [ freetype ];
buildInputs = [ pkgconfig expat ];

configureFlags = [
"--sysconfdir=/etc"
"--with-cache-dir=/var/cache/fontconfig"
"--disable-docs"
"--with-default-fonts="
];

# We should find a better way to access the arch reliably.
crossArch = stdenv.cross.arch or null;

preConfigure = ''
if test -n "$crossConfig"; then
configureFlags="$configureFlags --with-arch=$crossArch";
fi
'';

enableParallelBuilding = true;

doCheck = true;

# Don't try to write to /var/cache/fontconfig at install time.
installFlags = "sysconfdir=$(out)/etc fc_cachedir=$(TMPDIR)/dummy RUN_FC_CACHE_TEST=false";

postInstall = ''
cd "$out/etc/fonts" && tar xvf ${infinality_patch}
'';

passthru = {
# Empty for backward compatibility, there was no versioning before 2.11
configVersion = "";
};

meta = with stdenv.lib; {
description = "A library for font customization and configuration";
homepage = http://fontconfig.org/;
license = licenses.bsd2; # custom but very bsd-like
platforms = platforms.all;
maintainers = [ maintainers.vcunat ];
};
}
5 changes: 0 additions & 5 deletions pkgs/development/libraries/fontconfig/builder.sh

This file was deleted.

28 changes: 21 additions & 7 deletions pkgs/development/libraries/fontconfig/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{ stdenv, fetchurl, pkgconfig, freetype, expat }:
{ stdenv, fetchurl, pkgconfig, freetype, expat, libxslt, fontbhttf }:

let
configVersion = "2.11"; # bump whenever fontconfig breaks compatibility with older configurations
in
stdenv.mkDerivation rec {
name = "fontconfig-2.10.2";
name = "fontconfig-2.11.1";

src = fetchurl {
url = "http://fontconfig.org/release/${name}.tar.bz2";
sha256 = "0llraqw86jmw4vzv7inskp3xxm2gc64my08iwq5mzncgfdbfza4f";
sha256 = "16baa4g5lswkyjlyf1h5lwc0zjap7c4d8grw79349a5w6dsl8qnw";
};

infinality_patch =
Expand All @@ -17,13 +20,12 @@ stdenv.mkDerivation rec {
;

propagatedBuildInputs = [ freetype ];
buildInputs = [ pkgconfig expat ];
buildInputs = [ pkgconfig libxslt expat ];

configureFlags = [
"--sysconfdir=/etc"
"--with-cache-dir=/var/cache/fontconfig"
"--disable-docs"
"--with-default-fonts="
"--with-default-fonts=${fontbhttf}"
];

# We should find a better way to access the arch reliably.
Expand All @@ -40,12 +42,24 @@ stdenv.mkDerivation rec {
doCheck = true;

# Don't try to write to /var/cache/fontconfig at install time.
installFlags = "sysconfdir=$(out)/etc fc_cachedir=$(TMPDIR)/dummy RUN_FC_CACHE_TEST=false";
installFlags = "fc_cachedir=$(TMPDIR)/dummy RUN_FC_CACHE_TEST=false";

# Add a default font for non-nixos systems. fontbhttf is only about 1mb.
postInstall = ''
cd "$out/etc/fonts" && tar xvf ${infinality_patch}
xsltproc --stringparam fontDirectories "${fontbhttf}" \
--stringparam fontconfig "$out" \
--stringparam fontconfigConfigVersion "${configVersion}" \
--path $out/share/xml/fontconfig \
${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \
> fonts.conf.tmp
mv fonts.conf.tmp $out/etc/fonts/fonts.conf
'';

passthru = {
inherit configVersion;
};

meta = with stdenv.lib; {
description = "A library for font customization and configuration";
homepage = http://fontconfig.org/;
Expand Down
6 changes: 4 additions & 2 deletions pkgs/development/libraries/fontconfig/make-fonts-conf.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{ runCommand, libxslt, fontconfig, fontDirectories }:
{ runCommand, libxslt, fontconfig, fontbhttf, fontDirectories }:

runCommand "fonts.conf"
{
buildInputs = [ libxslt fontconfig ];
inherit fontDirectories;
# Add a default font for non-nixos systems. fontbhttf is only about 1mb.
fontDirectories = fontDirectories ++ [ fontbhttf ];
}
''
xsltproc --stringparam fontDirectories "$fontDirectories" \
--stringparam fontconfig "${fontconfig}" \
--stringparam fontconfigConfigVersion "${fontconfig.configVersion}" \
--path ${fontconfig}/share/xml/fontconfig \
${./make-fonts-conf.xsl} ${fontconfig}/etc/fonts/fonts.conf \
> $out
Expand Down
24 changes: 18 additions & 6 deletions pkgs/development/libraries/fontconfig/make-fonts-conf.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,37 @@

<xsl:param name="fontDirectories" />
<xsl:param name="fontconfig" />
<xsl:param name="fontconfigConfigVersion" />

<xsl:template match="/fontconfig">

<fontconfig>
<xsl:apply-templates select="child::node()[name() != 'dir' and name() != 'cachedir' and name() != 'include']" />

<include ignore_missing="yes">/etc/fonts/conf.d</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>
<!-- look into user config -->
<include prefix="xdg" ignore_missing="yes">fontconfig/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>
<cachedir>~/.fontconfig</cachedir>

<dir prefix="xdg">fonts</dir>
<xsl:for-each select="str:tokenize($fontDirectories)">
<dir><xsl:value-of select="." /></dir>
<xsl:text>&#0010;</xsl:text>
</xsl:for-each>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>

<!-- nix user profile -->
<dir>~/.nix-profile/lib/X11/fonts</dir>
<dir>~/.nix-profile/share/fonts</dir>
<!-- nix default profile -->
<dir>/nix/var/nix/profiles/default/lib/X11/fonts</dir>
<dir>/nix/var/nix/profiles/default/share/fonts</dir>

</fontconfig>

Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,8 @@ let

cfitsio = callPackage ../development/libraries/cfitsio { };

fontconfig_210 = callPackage ../development/libraries/fontconfig/2.10.nix { };

fontconfig = callPackage ../development/libraries/fontconfig { };

makeFontsConf = let fontconfig_ = fontconfig; in {fontconfig ? fontconfig_, fontDirectories}:
Expand Down

0 comments on commit 2641ee3

Please sign in to comment.