lol
1{ stdenv
2, lib
3, fetchurl
4, fetchpatch2
5, pkg-config
6, python3
7, freetype
8, expat
9, libxslt
10, gperf
11, dejavu_fonts
12, autoreconfHook
13, CoreFoundation
14}:
15
16stdenv.mkDerivation rec {
17 pname = "fontconfig";
18 version = "2.14.2";
19
20 outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config
21
22 src = fetchurl {
23 url = "https://www.freedesktop.org/software/fontconfig/release/${pname}-${version}.tar.xz";
24 hash = "sha256-26aVtXvOFQI9LO7e+CBiwrkl5R9dTMSu9zbPE/YKRos=";
25 };
26
27 patches = [
28 # Provide 11-lcdfilter-none.conf for NixOS module
29 # https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/268
30 (fetchpatch2 {
31 name = "add-optional-11-lcdfilter-none-configuration.patch";
32 url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/c2666a6d9a6ed18b1bfcef8176e25f62993e24db.patch";
33 hash = "sha256-UBzkxy3uxFO+g0aQtPnBZv7OncgQdinwzNwWS8ngjcE=";
34 })
35 ];
36
37 nativeBuildInputs = [
38 autoreconfHook
39 gperf
40 libxslt
41 pkg-config
42 python3
43 ];
44
45 buildInputs = [
46 expat
47 ] ++ lib.optional stdenv.isDarwin CoreFoundation;
48
49 propagatedBuildInputs = [
50 freetype
51 ];
52
53 postPatch = ''
54 # Requires networking.
55 sed -i '/check_PROGRAMS += test-crbug1004254/d' test/Makefile.am
56 '';
57
58 configureFlags = [
59 "--sysconfdir=/etc"
60 "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
61 "--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/
62 # just <1MB; this is what you get when loading config fails for some reason
63 "--with-default-fonts=${dejavu_fonts.minimal}"
64 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
65 "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
66 ];
67
68 enableParallelBuilding = true;
69
70 doCheck = true;
71
72 installFlags = [
73 # Don't try to write to /var/cache/fontconfig at install time.
74 "fc_cachedir=$(TMPDIR)/dummy"
75 "RUN_FC_CACHE_TEST=false"
76 "sysconfdir=${placeholder "out"}/etc"
77 ];
78
79 postInstall = ''
80 cd "$out/etc/fonts"
81 xsltproc --stringparam fontDirectories "${dejavu_fonts.minimal}" \
82 --path $out/share/xml/fontconfig \
83 ${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \
84 > fonts.conf.tmp
85 mv fonts.conf.tmp $out/etc/fonts/fonts.conf
86 # We don't keep section 3 of the manpages, as they are quite large and
87 # probably not so useful.
88 rm -r $bin/share/man/man3
89 '';
90
91 meta = with lib; {
92 description = "A library for font customization and configuration";
93 homepage = "http://fontconfig.org/";
94 license = licenses.bsd2; # custom but very bsd-like
95 platforms = platforms.all;
96 maintainers = with maintainers; teams.freedesktop.members ++ [ ];
97 };
98}