9 cfg = config.fonts.fontDir;
11 x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
12 mkdir -p "$out/share/X11/fonts"
13 font_regexp='.*\.\(ttf\|ttc\|otb\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
14 find ${toString config.fonts.packages} -regex "$font_regexp" \
15 -exec ln -sf -t "$out/share/X11/fonts" '{}' \;
16 cd "$out/share/X11/fonts"
17 ${lib.optionalString cfg.decompressFonts ''
18 ${pkgs.gzip}/bin/gunzip -f *.gz
20 ${pkgs.xorg.mkfontscale}/bin/mkfontscale
21 ${pkgs.xorg.mkfontdir}/bin/mkfontdir
22 cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
32 enable = lib.mkOption {
33 type = lib.types.bool;
36 Whether to create a directory with links to all fonts in
37 {file}`/run/current-system/sw/share/X11/fonts`.
41 decompressFonts = lib.mkOption {
42 type = lib.types.bool;
43 default = config.programs.xwayland.enable;
44 defaultText = lib.literalExpression "config.programs.xwayland.enable";
46 Whether to decompress fonts in
47 {file}`/run/current-system/sw/share/X11/fonts`.
54 config = lib.mkIf cfg.enable {
56 environment.systemPackages = [ x11Fonts ];
57 environment.pathsToLink = [ "/share/X11/fonts" ];
59 services.xserver.filesSection = ''
60 FontPath "${x11Fonts}/share/X11/fonts"
66 (lib.mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])