From e9e1d145f6e6da36d743619704aa8e1eed14704b Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 20 Dec 2024 15:47:57 -0800 Subject: [PATCH] nixos/fontdir: fix X11-fonts cross compilation --- nixos/modules/config/fonts/fontdir.nix | 42 ++++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/nixos/modules/config/fonts/fontdir.nix b/nixos/modules/config/fonts/fontdir.nix index 1d47970d131d9..c0ca9d1b537a3 100644 --- a/nixos/modules/config/fonts/fontdir.nix +++ b/nixos/modules/config/fonts/fontdir.nix @@ -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