2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
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"
|
2023-07-15 17:15:38 +00:00
|
|
|
font_regexp='.*\.\(ttf\|ttc\|otb\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
2023-08-04 22:07:22 +00:00
|
|
|
find ${toString config.fonts.packages} -regex "$font_regexp" \
|
2020-10-07 09:15:18 +00:00
|
|
|
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
|
|
|
|
cd "$out/share/X11/fonts"
|
2024-09-19 14:19:46 +00:00
|
|
|
${lib.optionalString cfg.decompressFonts ''
|
2020-10-07 09:15:18 +00:00
|
|
|
${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
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to create a directory with links to all fonts in
|
2022-08-12 12:06:08 +00:00
|
|
|
{file}`/run/current-system/sw/share/X11/fonts`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
decompressFonts = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-10-07 09:15:18 +00:00
|
|
|
default = config.programs.xwayland.enable;
|
2024-09-19 14:19:46 +00:00
|
|
|
defaultText = lib.literalExpression "config.programs.xwayland.enable";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-10-07 09:15:18 +00:00
|
|
|
Whether to decompress fonts in
|
2022-08-12 12:06:08 +00:00
|
|
|
{file}`/run/current-system/sw/share/X11/fonts`.
|
2020-10-07 09:15:18 +00:00
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.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 = [
|
2024-09-19 14:19:46 +00:00
|
|
|
(lib.mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
|
2020-10-07 09:15:18 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|