mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-11 15:08:33 +01:00
Merge pull request #95358 from jtojnar/global-fontconfig
This commit is contained in:
commit
4f0f26771e
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Configuration files are linked to /etc/fonts/${pkgs.fontconfig.configVersion}/conf.d/
|
Configuration files are linked to /etc/fonts/conf.d/
|
||||||
|
|
||||||
This module generates a package containing configuration files and link it in /etc/fonts.
|
This module generates a package containing configuration files and link it in /etc/fonts.
|
||||||
|
|
||||||
|
@ -176,15 +176,16 @@ let
|
||||||
confPkg = pkgs.runCommand "fontconfig-conf" {
|
confPkg = pkgs.runCommand "fontconfig-conf" {
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
} ''
|
} ''
|
||||||
dst=$out/etc/fonts/${pkg.configVersion}/conf.d
|
dst=$out/etc/fonts/conf.d
|
||||||
mkdir -p $dst
|
mkdir -p $dst
|
||||||
|
|
||||||
# fonts.conf
|
# fonts.conf
|
||||||
ln -s ${pkg.out}/etc/fonts/fonts.conf \
|
ln -s ${pkg.out}/etc/fonts/fonts.conf \
|
||||||
$dst/../fonts.conf
|
$dst/../fonts.conf
|
||||||
# TODO: remove this legacy symlink once people stop using packages built before #95358 was merged
|
# TODO: remove this legacy symlink once people stop using packages built before #95358 was merged
|
||||||
ln -s /etc/fonts/${pkg.configVersion}/fonts.conf \
|
mkdir -p $out/etc/fonts/2.11
|
||||||
$out/etc/fonts/fonts.conf
|
ln -s /etc/fonts/fonts.conf \
|
||||||
|
$out/etc/fonts/2.11/fonts.conf
|
||||||
|
|
||||||
# fontconfig default config files
|
# fontconfig default config files
|
||||||
ln -s ${pkg.out}/etc/fonts/conf.d/*.conf \
|
ln -s ${pkg.out}/etc/fonts/conf.d/*.conf \
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
From 2ff9b53ce755be183ef9274f7dd3f9ac537173f6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vcunat@gmail.com>
|
|
||||||
Date: Tue, 4 Nov 2014 12:24:25 +0100
|
|
||||||
Subject: [PATCH] add check for /etc/fonts/@configVersion@/fonts.conf
|
|
||||||
|
|
||||||
It's checked between FONTCONFIG_FILE and the in-package etc/fonts/fonts.conf.
|
|
||||||
The latter is used so that on non-NixOS distributions, fontconfig works at least
|
|
||||||
with upstream defaults, even when the global config is incompatible.
|
|
||||||
|
|
||||||
Co-Authored-By: Jan Tojnar <jtojnar@gmail.com>
|
|
||||||
---
|
|
||||||
src/fccfg.c | 7 ++++++-
|
|
||||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/fccfg.c b/src/fccfg.c
|
|
||||||
index 342c996..98a1324 100644
|
|
||||||
--- a/src/fccfg.c
|
|
||||||
+++ b/src/fccfg.c
|
|
||||||
@@ -2391,8 +2391,13 @@ FcConfigGetFilename (FcConfig *config,
|
|
||||||
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 *) FONTCONFIG_PATH "/" FONTCONFIG_FILE;
|
|
||||||
}
|
|
||||||
file = 0;
|
|
||||||
|
|
||||||
--
|
|
||||||
2.26.2
|
|
||||||
|
|
|
@ -11,21 +11,6 @@
|
||||||
, autoreconfHook
|
, autoreconfHook
|
||||||
}:
|
}:
|
||||||
|
|
||||||
/** Font configuration scheme
|
|
||||||
- ./config-compat.patch makes fontconfig try the following root configs, in order:
|
|
||||||
$FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, ${fontconfig.out}/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 NixOS,
|
|
||||||
falling back to upstream defaults on 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 {
|
stdenv.mkDerivation rec {
|
||||||
pname = "fontconfig";
|
pname = "fontconfig";
|
||||||
version = "2.13.92";
|
version = "2.13.92";
|
||||||
|
@ -36,11 +21,6 @@ stdenv.mkDerivation rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
(substituteAll {
|
|
||||||
src = ./config-compat.patch;
|
|
||||||
inherit configVersion;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix fonts not being loaded when missing included configs that have ignore_missing="yes".
|
# Fix fonts not being loaded when missing included configs that have ignore_missing="yes".
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1744377
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1744377
|
||||||
(fetchpatch {
|
(fetchpatch {
|
||||||
|
@ -73,6 +53,13 @@ stdenv.mkDerivation rec {
|
||||||
url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/37c7c748740bf6f2468d59e67951902710240b34.patch";
|
url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/37c7c748740bf6f2468d59e67951902710240b34.patch";
|
||||||
sha256 = "1rz5zrfwhpn9g49wrzzrmdglj78pbvpnw8ksgsw6bxq8l5d84jfr";
|
sha256 = "1rz5zrfwhpn9g49wrzzrmdglj78pbvpnw8ksgsw6bxq8l5d84jfr";
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Show warning instead of error when encountering unknown attribute in config.
|
||||||
|
# https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/111
|
||||||
|
(fetchpatch {
|
||||||
|
url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/409b37c62780728755c908991c912a6b16f2389c.patch";
|
||||||
|
sha256 = "zJFh37QErSAINPGFkFVJyhYRP27BuIN7PIgoDl/PIwI=";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config
|
outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config
|
||||||
|
@ -93,6 +80,7 @@ stdenv.mkDerivation rec {
|
||||||
];
|
];
|
||||||
|
|
||||||
configureFlags = [
|
configureFlags = [
|
||||||
|
"--sysconfdir=/etc"
|
||||||
"--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
|
"--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
|
||||||
"--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/
|
"--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/
|
||||||
"--disable-docs"
|
"--disable-docs"
|
||||||
|
@ -106,32 +94,22 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
# Don't try to write to /var/cache/fontconfig at install time.
|
installFlags = [
|
||||||
installFlags = [ "fc_cachedir=$(TMPDIR)/dummy" "RUN_FC_CACHE_TEST=false" ];
|
# Don't try to write to /var/cache/fontconfig at install time.
|
||||||
|
"fc_cachedir=$(TMPDIR)/dummy"
|
||||||
|
"RUN_FC_CACHE_TEST=false"
|
||||||
|
"sysconfdir=${placeholder "out"}/etc"
|
||||||
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
cd "$out/etc/fonts"
|
cd "$out/etc/fonts"
|
||||||
xsltproc --stringparam fontDirectories "${dejavu_fonts.minimal}" \
|
xsltproc --stringparam fontDirectories "${dejavu_fonts.minimal}" \
|
||||||
--stringparam fontconfig "$out" \
|
|
||||||
--stringparam fontconfigConfigVersion "${configVersion}" \
|
|
||||||
--path $out/share/xml/fontconfig \
|
--path $out/share/xml/fontconfig \
|
||||||
${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \
|
${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \
|
||||||
> fonts.conf.tmp
|
> fonts.conf.tmp
|
||||||
mv fonts.conf.tmp $out/etc/fonts/fonts.conf
|
mv fonts.conf.tmp $out/etc/fonts/fonts.conf
|
||||||
|
|
||||||
# Make it easier to remove user config in NixOS module.
|
|
||||||
mkdir -p $out/etc/fonts/conf.d.bak
|
|
||||||
mv $out/etc/fonts/conf.d/50-user.conf $out/etc/fonts/conf.d.bak
|
|
||||||
|
|
||||||
# update latest 51-local.conf path to look at the latest local.conf
|
|
||||||
substituteInPlace $out/etc/fonts/conf.d/51-local.conf \
|
|
||||||
--replace local.conf /etc/fonts/${configVersion}/local.conf
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit configVersion;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "A library for font customization and configuration";
|
description = "A library for font customization and configuration";
|
||||||
homepage = "http://fontconfig.org/";
|
homepage = "http://fontconfig.org/";
|
||||||
|
|
|
@ -9,8 +9,6 @@ runCommand "fonts.conf"
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
xsltproc --stringparam fontDirectories "$fontDirectories" \
|
xsltproc --stringparam fontDirectories "$fontDirectories" \
|
||||||
--stringparam fontconfig "${fontconfig.out}" \
|
|
||||||
--stringparam fontconfigConfigVersion "${fontconfig.configVersion}" \
|
|
||||||
--path ${fontconfig.out}/share/xml/fontconfig \
|
--path ${fontconfig.out}/share/xml/fontconfig \
|
||||||
${./make-fonts-conf.xsl} ${fontconfig.out}/etc/fonts/fonts.conf \
|
${./make-fonts-conf.xsl} ${fontconfig.out}/etc/fonts/fonts.conf \
|
||||||
> $out
|
> $out
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
<xsl:output method='xml' encoding="UTF-8" doctype-system="urn:fontconfig:fonts.dtd" />
|
<xsl:output method='xml' encoding="UTF-8" doctype-system="urn:fontconfig:fonts.dtd" />
|
||||||
|
|
||||||
<xsl:param name="fontDirectories" />
|
<xsl:param name="fontDirectories" />
|
||||||
<xsl:param name="fontconfig" />
|
|
||||||
<xsl:param name="fontconfigConfigVersion" />
|
|
||||||
|
|
||||||
<xsl:template match="/fontconfig">
|
<xsl:template match="/fontconfig">
|
||||||
|
|
||||||
|
@ -28,11 +26,8 @@
|
||||||
<!-- /var/cache/fontconfig is useful for non-nixos systems -->
|
<!-- /var/cache/fontconfig is useful for non-nixos systems -->
|
||||||
<cachedir>/var/cache/fontconfig</cachedir>
|
<cachedir>/var/cache/fontconfig</cachedir>
|
||||||
|
|
||||||
<!-- versioned system-wide config -->
|
<!-- system-wide config -->
|
||||||
<include ignore_missing="yes">/etc/fonts/<xsl:value-of select="$fontconfigConfigVersion" />/conf.d</include>
|
<include ignore_missing="yes">/etc/fonts/conf.d</include>
|
||||||
|
|
||||||
<!-- upstream config -->
|
|
||||||
<include><xsl:value-of select="$fontconfig" />/etc/fonts/conf.d</include>
|
|
||||||
|
|
||||||
<dir prefix="xdg">fonts</dir>
|
<dir prefix="xdg">fonts</dir>
|
||||||
<xsl:for-each select="str:tokenize($fontDirectories)">
|
<xsl:for-each select="str:tokenize($fontDirectories)">
|
||||||
|
|
Loading…
Reference in a new issue