Skip to content

Commit

Permalink
nixos/fontdir: fix X11-fonts cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Dec 20, 2024
1 parent d184f19 commit e9e1d14
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions nixos/modules/config/fonts/fontdir.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,35 @@ let

cfg = config.fonts.fontDir;

x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
mkdir -p "$out/share/X11/fonts"
font_regexp='.*\.\(ttf\|ttc\|otb\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
find ${toString config.fonts.packages} -regex "$font_regexp" \
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
cd "$out/share/X11/fonts"
${lib.optionalString cfg.decompressFonts ''
${pkgs.gzip}/bin/gunzip -f *.gz
''}
${pkgs.xorg.mkfontscale}/bin/mkfontscale
${pkgs.xorg.mkfontdir}/bin/mkfontdir
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
'';
x11Fonts = pkgs.callPackage (
{
runCommand,
gzip,
xorg,
}:
runCommand "X11-fonts"
{
preferLocalBuild = true;
nativeBuildInputs = [
gzip
xorg.mkfontscale
xorg.mkfontdir
];
}
''
mkdir -p "$out/share/X11/fonts"
font_regexp='.*\.\(ttf\|ttc\|otb\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
find ${toString config.fonts.packages} -regex "$font_regexp" \
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
cd "$out/share/X11/fonts"
${lib.optionalString cfg.decompressFonts ''
gunzip -f *.gz
''}
mkfontscale
mkfontdir
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
''
) { };

in

Expand Down

0 comments on commit e9e1d14

Please sign in to comment.