nixos/fontdir: add the directory to the xserver font paths

This commit is contained in:
rnhmjoj 2020-09-01 10:38:59 +02:00 committed by Emilio Perez
parent 1fdd3921a2
commit eda7e23ea4
2 changed files with 10 additions and 6 deletions

View file

@ -5,11 +5,11 @@ with lib;
let let
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } '' x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
mkdir -p "$out/share/X11-fonts" mkdir -p "$out/share/X11/fonts"
font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?' font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
find ${toString config.fonts.fonts} -regex "$font_regexp" \ find ${toString config.fonts.fonts} -regex "$font_regexp" \
-exec ln -sf -t "$out/share/X11-fonts" '{}' \; -exec ln -sf -t "$out/share/X11/fonts" '{}' \;
cd "$out/share/X11-fonts" cd "$out/share/X11/fonts"
${pkgs.xorg.mkfontscale}/bin/mkfontscale ${pkgs.xorg.mkfontscale}/bin/mkfontscale
${pkgs.xorg.mkfontdir}/bin/mkfontdir ${pkgs.xorg.mkfontdir}/bin/mkfontdir
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
@ -28,7 +28,7 @@ in
default = false; default = false;
description = '' description = ''
Whether to create a directory with links to all fonts in Whether to create a directory with links to all fonts in
<filename>/run/current-system/sw/share/X11-fonts</filename>. <filename>/run/current-system/sw/share/X11/fonts</filename>.
''; '';
}; };
@ -38,9 +38,13 @@ in
config = mkIf config.fonts.enableFontDir { config = mkIf config.fonts.enableFontDir {
# This is enough to make a symlink because the xserver
# module already links all /share/X11 paths.
environment.systemPackages = [ x11Fonts ]; environment.systemPackages = [ x11Fonts ];
environment.pathsToLink = [ "/share/X11-fonts" ]; services.xserver.filesSection = ''
FontPath "${x11Fonts}/share/X11/fonts"
'';
}; };

View file

@ -371,7 +371,7 @@ in
type = types.lines; type = types.lines;
default = ""; default = "";
example = ''FontPath "/path/to/my/fonts"''; example = ''FontPath "/path/to/my/fonts"'';
description = "Contents of the first Files section of the X server configuration file."; description = "Contents of the first <literal>Files</literal> section of the X server configuration file.";
}; };
deviceSection = mkOption { deviceSection = mkOption {