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"
|
2020-11-03 02:18:15 +00:00
|
|
|
font_regexp='.*\.\(ttf\|ttc\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
2020-10-07 09:15:18 +00:00
|
|
|
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;
|
2021-12-06 16:07:01 +00:00
|
|
|
defaultText = literalExpression "config.programs.xwayland.enable";
|
2020-10-07 09:15:18 +00:00
|
|
|
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
|
|
|
|
|
|
|
environment.systemPackages = [ x11Fonts ];
|
2021-10-14 00:43:12 +00:00
|
|
|
environment.pathsToLink = [ "/share/X11/fonts" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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
|
|
|
}
|