2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
runCommand,
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
libxslt,
|
|
|
|
fontconfig,
|
|
|
|
dejavu_fonts,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
let
|
|
|
|
fontconfig_ = fontconfig;
|
|
|
|
in
|
2024-05-02 00:46:19 +00:00
|
|
|
{
|
2024-06-30 08:16:52 +00:00
|
|
|
fontconfig ? fontconfig_,
|
2024-05-02 00:46:19 +00:00
|
|
|
# an array of fonts, e.g. `[ pkgs.dejavu_fonts.minimal ]`
|
2024-06-30 08:16:52 +00:00
|
|
|
fontDirectories,
|
|
|
|
impureFontDirectories ?
|
|
|
|
[
|
|
|
|
# nix user profile
|
|
|
|
"~/.nix-profile/lib/X11/fonts"
|
|
|
|
"~/.nix-profile/share/fonts"
|
|
|
|
]
|
|
|
|
++ lib.optional stdenv.isDarwin "~/Library/Fonts"
|
|
|
|
++ [
|
|
|
|
# FHS paths for non-NixOS platforms
|
|
|
|
"/usr/share/fonts"
|
|
|
|
"/usr/local/share/fonts"
|
|
|
|
]
|
|
|
|
# darwin paths
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
"/Library/Fonts"
|
|
|
|
"/System/Library/Fonts"
|
|
|
|
]
|
|
|
|
# nix default profile
|
|
|
|
++ [
|
|
|
|
"/nix/var/nix/profiles/default/lib/X11/fonts"
|
|
|
|
"/nix/var/nix/profiles/default/share/fonts"
|
|
|
|
],
|
2024-05-02 00:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
runCommand "fonts.conf"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ libxslt ];
|
|
|
|
buildInputs = [ fontconfig ];
|
|
|
|
inherit fontDirectories;
|
|
|
|
# Add a default font for non-nixos systems, <1MB and in nixos defaults.
|
|
|
|
impureFontDirectories = impureFontDirectories ++ [ dejavu_fonts.minimal ];
|
|
|
|
}
|
|
|
|
''
|
|
|
|
xsltproc --stringparam fontDirectories "$fontDirectories" \
|
|
|
|
--stringparam impureFontDirectories "$impureFontDirectories" \
|
|
|
|
--path ${fontconfig.out}/share/xml/fontconfig \
|
|
|
|
${./make-fonts-conf.xsl} ${fontconfig.out}/etc/fonts/fonts.conf \
|
|
|
|
> $out
|
|
|
|
''
|