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