config.fonts.fontdir: use runCommand instead of builderDefs

The primary motivation here is to get rid of builderDefs, but now the
resulting font directory is also linked into /run/current-system/sw,
which fixes #15194.

+13 -41
+13 -41
nixos/modules/config/fonts/fontdir.nix
··· 4 4 5 5 let 6 6 7 - fontDirs = config.fonts.fonts; 8 - 9 - localDefs = with pkgs.builderDefs; pkgs.builderDefs.passthru.function rec { 10 - src = "";/* put a fetchurl here */ 11 - buildInputs = [pkgs.xorg.mkfontdir pkgs.xorg.mkfontscale]; 12 - inherit fontDirs; 13 - installPhase = fullDepEntry (" 14 - list=''; 15 - for i in ${toString fontDirs} ; do 16 - if [ -d \$i/ ]; then 17 - list=\"\$list \$i\"; 18 - fi; 19 - done 20 - list=\$(find \$list -name fonts.dir -o -name '*.ttf' -o -name '*.otf'); 21 - fontDirs=''; 22 - for i in \$list ; do 23 - fontDirs=\"\$fontDirs \$(dirname \$i)\"; 24 - done; 25 - mkdir -p \$out/share/X11-fonts/; 26 - find \$fontDirs -type f -o -type l | while read i; do 27 - j=\"\${i##*/}\" 28 - if ! test -e \"\$out/share/X11-fonts/\${j}\"; then 29 - ln -s \"\$i\" \"\$out/share/X11-fonts/\${j}\"; 30 - fi; 31 - done; 32 - cd \$out/share/X11-fonts/ 33 - rm fonts.dir 34 - rm fonts.scale 35 - rm fonts.alias 36 - mkfontdir 37 - mkfontscale 38 - cat \$( find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias 39 - ") ["minInit" "addInputs"]; 40 - }; 41 - 42 - x11Fonts = with localDefs; stdenv.mkDerivation rec { 43 - name = "X11-fonts"; 44 - builder = writeScript (name + "-builder") 45 - (textClosure localDefs 46 - [installPhase doForceShare doPropagate]); 47 - }; 7 + x11Fonts = pkgs.runCommand "X11-fonts" { } '' 8 + mkdir -p "$out/share/X11-fonts" 9 + find ${toString config.fonts.fonts} \ 10 + \( -name fonts.dir -o -name '*.ttf' -o -name '*.otf' \) \ 11 + -exec ln -sf -t "$out/share/X11-fonts" '{}' \; 12 + cd "$out/share/X11-fonts" 13 + rm -f fonts.dir fonts.scale fonts.alias 14 + ${pkgs.xorg.mkfontdir}/bin/mkfontdir 15 + ${pkgs.xorg.mkfontscale}/bin/mkfontscale 16 + cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias 17 + ''; 48 18 49 19 in 50 20 ··· 69 39 config = mkIf config.fonts.enableFontDir { 70 40 71 41 environment.systemPackages = [ x11Fonts ]; 42 + 43 + environment.pathsToLink = [ "/share/X11-fonts" ]; 72 44 73 45 }; 74 46