lol
1<?xml version="1.0"?>
2
3<!--
4 This script copies the original fonts.conf from the fontconfig
5 distribution, but replaces all <dir> entries with the directories
6 specified in the $fontDirectories parameter.
7-->
8
9<xsl:stylesheet version="1.0"
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:str="http://exslt.org/strings"
12 extension-element-prefixes="str"
13 >
14
15 <xsl:output method='xml' encoding="UTF-8" doctype-system="fonts.dtd" />
16
17 <xsl:param name="fontDirectories" />
18 <xsl:param name="fontconfig" />
19 <xsl:param name="fontconfigConfigVersion" />
20
21 <xsl:template match="/fontconfig">
22
23 <fontconfig>
24 <xsl:apply-templates select="child::node()[name() != 'dir' and name() != 'cachedir' and name() != 'include']" />
25
26 <!-- the first cachedir will be used to store the cache -->
27 <cachedir prefix="xdg">fontconfig</cachedir>
28 <!-- /var/cache/fontconfig is useful for non-nixos systems -->
29 <cachedir>/var/cache/fontconfig</cachedir>
30
31 <!-- fontconfig distribution conf.d -->
32 <include><xsl:value-of select="$fontconfig" />/etc/fonts/conf.d</include>
33 <!-- versioned system-wide config -->
34 <include ignore_missing="yes">/etc/fonts/<xsl:value-of select="$fontconfigConfigVersion" />/conf.d</include>
35
36 <dir prefix="xdg">fonts</dir>
37 <xsl:for-each select="str:tokenize($fontDirectories)">
38 <dir><xsl:value-of select="." /></dir>
39 <xsl:text>
</xsl:text>
40 </xsl:for-each>
41
42 <!-- nix user profile -->
43 <dir>~/.nix-profile/lib/X11/fonts</dir>
44 <dir>~/.nix-profile/share/fonts</dir>
45 <!-- nix default profile -->
46 <dir>/nix/var/nix/profiles/default/lib/X11/fonts</dir>
47 <dir>/nix/var/nix/profiles/default/share/fonts</dir>
48
49 </fontconfig>
50
51 </xsl:template>
52
53
54 <!-- New fontconfig >=2.11 doesn't like xml:space added by xsl:copy-of -->
55 <xsl:template match="node()|@*">
56 <xsl:copy>
57 <xsl:apply-templates select="node()|@*[name() != 'xml:space']"/>
58 </xsl:copy>
59 </xsl:template>
60
61</xsl:stylesheet>