Fonts: Difference between revisions

AveryKoen (talk | contribs)
Updated information.
Ad2tba (talk | contribs)
Clarify that bindfs solution can also fix issues with missing icons/cursor themes. Simplify code example.
Line 164: Line 164:
=== Flatpak applications can't find system fonts ===
=== Flatpak applications can't find system fonts ===


First, enable <code>fontDir</code> in your NixOS configuration:
To expose available fonts under <code>/run/current-system/sw/share/X11/fonts</code>, enable <code>fontDir</code> in your NixOS configuration.
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
fonts.fontDir.enable = true;
fonts.fontDir.enable = true;
</syntaxhighlight>
</syntaxhighlight>You will then need to link/copy this folder to one of the Flatpak-supported locations - see below.


==== Best Solution: Just copy necessary fonts to <code>$HOME/.local/share/fonts</code> ====
==== Best Solution: Just copy necessary fonts to <code>$HOME/.local/share/fonts</code> ====
Line 225: Line 225:
It is important to keep in mind that some flatpak apps may refuse to launch if given certain permissions, such as the Steam flatpak.  
It is important to keep in mind that some flatpak apps may refuse to launch if given certain permissions, such as the Steam flatpak.  


=== Using bindfs for font support ===
==== Using bindfs for fonts/cursors/icons support ====
Alternatively, you can expose relevant packages directly under <code>/usr/share/...</code> paths. This will also enable Flatpak to use a custom cursor theme if you have one.<syntaxhighlight lang="nix">
  system.fsPackages = [ pkgs.bindfs ];


<syntaxhighlight lang="nix">
  system.fsPackages = [ pkgs.bindfs ];
   fileSystems = let
   fileSystems = let
     mkRoSymBind = path: {
     mkRoSymBind = path: {
Line 235: Line 235:
       options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
       options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
     };
     };
     aggregatedIcons = pkgs.buildEnv {
     aggregated = pkgs.buildEnv {
      name = "system-icons";
        name = "system-fonts-and-icons";
      paths = with pkgs; [
        paths = config.fonts.packages ++ (with pkgs; [
        #libsForQt5.breeze-qt5  # for plasma
          # Add your cursor themes and icon packages here
        gnome.gnome-themes-extra
          bibata-cursors
      ];
          gnome.gnome-themes-extra
      pathsToLink = [ "/share/icons" ];
          # etc.
    };
        ]);
    aggregatedFonts = pkgs.buildEnv {
        pathsToLink = [ "/share/fonts" "/share/icons" ];
      name = "system-fonts";
      paths = config.fonts.packages;
      pathsToLink = [ "/share/fonts" ];
     };
     };
   in {
   in {
     "/usr/share/icons" = mkRoSymBind "${aggregatedIcons}/share/icons";
     "/usr/share/fonts" = mkRoSymBind "${aggregated}/share/fonts";
     "/usr/local/share/fonts" = mkRoSymBind "${aggregatedFonts}/share/fonts";
     "/usr/share/icons" = mkRoSymBind "${aggregated}/share/icons";
   };
   };


   fonts = {
   fonts.packages = with pkgs; [
    fontDir.enable = true;
    noto-fonts
    packages = with pkgs; [
    noto-fonts-emoji
      noto-fonts
    noto-fonts-cjk
      noto-fonts-emoji
  ];
      noto-fonts-cjk
    ];
  };
</syntaxhighlight>
</syntaxhighlight>