From 08b8136f686aa425a5ce0e63293d4e66cdfa79f6 Mon Sep 17 00:00:00 2001 From: Superredstone Date: Sat, 16 May 2026 10:40:41 +0200 Subject: [PATCH] fix(font): flatpak gtk application correct font rendering --- modules/nix-config/fonts.nix | 60 +++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/modules/nix-config/fonts.nix b/modules/nix-config/fonts.nix index 14e5c6f..8177abc 100644 --- a/modules/nix-config/fonts.nix +++ b/modules/nix-config/fonts.nix @@ -1,5 +1,63 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: { + system.fsPackages = [ pkgs.bindfs ]; + fileSystems = + let + mkRoSymBind = path: { + device = path; + fsType = "fuse.bindfs"; + options = [ + "ro" + "resolve-symlinks" + "x-gvfs-hide" + ]; + }; + fontsPkgs = + config.fonts.packages + ++ (with pkgs; [ + bibata-cursors + ]); + x11Fonts = + pkgs.runCommand "X11-fonts" + { + preferLocalBuild = true; + nativeBuildInputs = with pkgs; [ + gzip + mkfontscale + mkfontdir + ]; + } + ( + '' + mkdir -p "$out/share/fonts" + font_regexp='.*\.\(ttf\|ttc\|otb\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?' + '' + + (builtins.concatStringsSep "\n" ( + builtins.map (pkg: '' + find ${toString pkg} -regex "$font_regexp" \ + -exec ln -sf -t "$out/share/fonts" '{}' \; + '') fontsPkgs + )) + + '' + cd "$out/share/fonts" + mkfontscale + mkfontdir + cat $(find ${pkgs.fontalias}/ -name fonts.alias) >fonts.alias + '' + ); + aggregatedIcons = pkgs.buildEnv { + name = "system-icons"; + paths = fontsPkgs; + pathsToLink = [ + "/share/icons" + ]; + }; + in + { + "/usr/share/icons" = mkRoSymBind (aggregatedIcons + "/share/icons"); + "/usr/share/fonts" = mkRoSymBind (x11Fonts + "/share/fonts"); + }; + fonts.packages = with pkgs; [ nerd-fonts.jetbrains-mono noto-fonts