2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
cfg = config.fonts.fontDir;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
|
2020-10-07 09:15:18 +00:00
|
|
|
mkdir -p "$out/share/X11/fonts"
|
|
|
|
font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
|
|
|
find ${toString config.fonts.fonts} -regex "$font_regexp" \
|
|
|
|
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
|
|
|
|
cd "$out/share/X11/fonts"
|
|
|
|
${optionalString cfg.decompressFonts ''
|
|
|
|
${pkgs.gzip}/bin/gunzip -f *.gz
|
|
|
|
''}
|
2020-04-24 23:36:52 +00:00
|
|
|
${pkgs.xorg.mkfontscale}/bin/mkfontscale
|
2020-10-07 09:15:18 +00:00
|
|
|
${pkgs.xorg.mkfontdir}/bin/mkfontdir
|
2020-04-24 23:36:52 +00:00
|
|
|
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
2020-10-07 09:15:18 +00:00
|
|
|
fonts.fontDir = {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
enable = mkOption {
|
2020-05-03 17:38:23 +00:00
|
|
|
type = types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to create a directory with links to all fonts in
|
2020-10-07 09:15:18 +00:00
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
decompressFonts = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = config.programs.xwayland.enable;
|
|
|
|
description = ''
|
|
|
|
Whether to decompress fonts in
|
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
config = mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
# This is enough to make a symlink because the xserver
|
|
|
|
# module already links all /share/X11 paths.
|
2020-04-24 23:36:52 +00:00
|
|
|
environment.systemPackages = [ x11Fonts ];
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
services.xserver.filesSection = ''
|
|
|
|
FontPath "${x11Fonts}/share/X11/fonts"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|