diff options
Diffstat (limited to 'pkgs/development/libraries/fontconfig')
6 files changed, 164 insertions, 27 deletions
diff --git a/pkgs/development/libraries/fontconfig/2.10.nix b/pkgs/development/libraries/fontconfig/2.10.nix new file mode 100644 index 00000000000..2951dbb44d4 --- /dev/null +++ b/pkgs/development/libraries/fontconfig/2.10.nix @@ -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 ]; + }; +} diff --git a/pkgs/development/libraries/fontconfig/builder.sh b/pkgs/development/libraries/fontconfig/builder.sh deleted file mode 100644 index d755bca64e3..00000000000 --- a/pkgs/development/libraries/fontconfig/builder.sh +++ /dev/null @@ -1,5 +0,0 @@ -source $stdenv/setup - -configureFlags="--with-confdir=$out/etc/fonts --disable-docs" - -genericBuild diff --git a/pkgs/development/libraries/fontconfig/config-compat.patch b/pkgs/development/libraries/fontconfig/config-compat.patch new file mode 100644 index 00000000000..e86f08fb553 --- /dev/null +++ b/pkgs/development/libraries/fontconfig/config-compat.patch @@ -0,0 +1,28 @@ +commit 05c6adf8104b4321d3a3716a7b9feb6bf223ed0c (HEAD, nixpkgs) +Author: Vladimír Čunát <vcunat@gmail.com> +Date: Tue Nov 4 12:24:25 2014 +0100 + + add check for /etc/fonts/@configVersion@/fonts.conf + + It's checked between FONTCONFIG_FILE and the usual /etc/fonts/fonts.conf. + Also, hardcode /etc/fonts/fonts.conf to prevent accidental override. + +diff --git a/src/fccfg.c b/src/fccfg.c +index 6377fd7..e9eb10a 100644 +--- a/src/fccfg.c ++++ b/src/fccfg.c +@@ -2070,8 +2070,13 @@ FcConfigFilename (const FcChar8 *url) + if (!url || !*url) + { + url = (FcChar8 *) getenv ("FONTCONFIG_FILE"); ++ if (!url) { ++ static const FcChar8 *cfPath = "/etc/fonts/@configVersion@/fonts.conf"; ++ if (access (cfPath, R_OK) == 0) ++ url = cfPath; ++ } + if (!url) +- url = (FcChar8 *) FONTCONFIG_FILE; ++ url = (FcChar8 *) "/etc/fonts/fonts.conf"; + } + file = 0; + diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index f0c4da75567..b03528de2d5 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -1,29 +1,49 @@ -{ stdenv, fetchurl, pkgconfig, freetype, expat }: +{ stdenv, fetchurl, fetchpatch, pkgconfig, freetype, expat, libxslt, fontbhttf +, substituteAll }: +/** Font configuration scheme + - ./config-compat.patch makes fontconfig try the following root configs, in order: + $FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, /etc/fonts/fonts.conf + This is done not to override config of pre-2.11 versions (which just blow up) + and still use *global* font configuration at both NixOS or non-NixOS. + - NixOS creates /etc/fonts/${configVersion}/fonts.conf link to $out/etc/fonts/fonts.conf, + and other modifications should go to /etc/fonts/${configVersion}/conf.d + - See ./make-fonts-conf.xsl for config details. + +*/ + +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 = - let subvers = "1"; - in fetchurl { - url = http://www.infinality.net/fedora/linux/zips/fontconfig-infinality-1-20130104_1.tar.bz2; - sha256 = "1fm5xx0mx2243jrq5rxk4v0ajw2nawpj23399h710bx6hd1rviq7"; + patches = [ + (fetchpatch ({ + url = "http://cgit.freedesktop.org/fontconfig/patch/?id=f44157c809d280e2a0ce87fb078fc4b278d24a67"; + sha256 = "19s5irclg4irj2yxd7xw9yikbazs9263px8qbv4r21asw06nfalv"; + name = "fc-cache-bug-77252.patch"; } - ; + )) + (substituteAll { + src = ./config-compat.patch; + inherit configVersion; + }) + ]; propagatedBuildInputs = [ freetype ]; buildInputs = [ pkgconfig expat ]; configureFlags = [ - "--sysconfdir=/etc" - "--with-cache-dir=/var/cache/fontconfig" + "--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/ "--disable-docs" - "--with-default-fonts=" + # just ~1MB; this is what you get when loading config fails for some reason + "--with-default-fonts=${fontbhttf}" ]; # We should find a better way to access the arch reliably. @@ -40,12 +60,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"; postInstall = '' - cd "$out/etc/fonts" && tar xvf ${infinality_patch} + cd "$out/etc/fonts" + rm conf.d/{50-user,51-local}.conf + "${libxslt}/bin/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/; @@ -54,3 +86,4 @@ stdenv.mkDerivation rec { maintainers = [ maintainers.vcunat ]; }; } + diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix index f9cd096f559..2b02e0df7a0 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix @@ -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 diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index 59071ce9e22..1b79834c894 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -16,28 +16,46 @@ <xsl:param name="fontDirectories" /> <xsl:param name="fontconfig" /> + <xsl:param name="fontconfigConfigVersion" /> <xsl:template match="/fontconfig"> <fontconfig> - <xsl:copy-of select="child::node()[name() != 'dir' and name() != 'cachedir' and name() != 'include']" /> + <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> + <!-- 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>
</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> </xsl:template> + + <!-- New fontconfig >=2.11 doesn't like xml:space added by xsl:copy-of --> + <xsl:template match="node()|@*"> + <xsl:copy> + <xsl:apply-templates select="node()|@*[name() != 'xml:space']"/> + </xsl:copy> + </xsl:template> + </xsl:stylesheet> |