-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flatpak can't access system fonts and icons #119433
Comments
Relevant source code: The directory can be overridden using a configure flag: |
This probably won't help without some option to copy all the fonts to one directory... There's fonts.fontDir.enable, but it links fonts, so flatpak apps can't access them :( |
My poor, temporary solution was to copy A proper solution might involve collecting a list of all the store paths for system fonts, and building a big list of bubblewrap
|
I hope that will be solved once, since I don't really want to copy all installed fonts to home :( |
Looks like I found a solution for myself that won't double occupied space... I copied the fontconfig module and modified it in a way so that it copies contents of all the font packages to one package and doesn't reference these original packages, so they're removed right after nix-collect-gabage. I also created a bind mount to avoid flatpak rebuild for myself. I think I will do something like this for icons as well. |
So it is: ilya-fedin/nur-repository@2aa0966 Unlike the font one, it duplicates the icons, but I have only 300 MB of them (unlike fonts), so that's acceptable for me. |
My solution: |
That's not really a great solution since it pretty much eliminates the security benefits of running proprietary apps inside flatpak containers |
I highly advise against doing that since that would defeat the purpose of using flatpak, the same can be done with the cursor, again just download the theme u use, place it into ~/.icons or ~/.local/share/icons and giving the apps access to that in both cases you can either to that on a per-app basis or just add access to those folders in the global section |
If you have home manager, you could try something like the following (untested): home.file.".local/share/flatpak/overrides/global".text = ''
[Context]
filesystems=/run/current-system/sw/share/X11/fonts:ro;/nix/store:ro
''; Or just add those in Flatseal. Or edit the |
Using |
Doing this causes a lot of applications to break. Some apps such as Pika Backup and Clapper won't launch at all. For example, NewsFlash complains about the following:
It seems the only reliable solution is copying the fonts / icons to my |
In my case, icons are taking up way more space than fonts, so those modules don't really help much unfortunately. |
Just in case it can be of use to anyone, I made a workaround for this issue using { config, pkgs, ... }:
{
system.fsPackages = [ pkgs.bindfs ];
fileSystems = let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.fonts;
pathsToLink = [ "/share/fonts" ];
};
in {
# Create an FHS mount to support flatpak host icons/fonts
"/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
"/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
};
} The main trick here is that |
This works for me. Thank you very much!!! |
Hope someone fixes this in nixos itself so we don't need the workarounds |
One possible solution to this issue is to remove x11 fonts.This issue occurs mostly in Debian and openSUSE based distros with x11 fonts installed. Fedora and RHEL-based distros are usually not affected by default. Other distros may be affected if they have x11 fonts installed. The issue happens due to the following:
For example, in a Wikipedia webpage, the title of the topic uses 'Linux Libertine', 'Georgia', 'Times', serif; in that order. In default Debian and openSUSE installation Linux Libertine and Georgia are not installed. The next candidate is Times which is provided by an old x11 bitmap font. In Fedora, Times as x11 font is not present, therefore it fallbacks to serif which the flatpak runtime environment provides as TeX Gyre Termes. What we need is to remove x11 fonts so we can have that fallback mechanism just like with other distros. In Debian remove x11 fonts using:
In openSUSE based distros, use this code:
|
The name of the issue implies flatpak can't access host fonts at all, including x11 fonts |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-use-fix-for-flatpak-apps-cursor-theme/30893/1 |
Any updates? |
Works perfectly for me! Is it possible to make it also work with fontconfig? AFAIK fontconfig have the same issue with flatpaks right now. |
This seems to trigger an infinite recursion with the mountpoint valid path check and (Not sure if this is an issue with NixOS or with the shared code (or something I messed up)... I could open a separate issue if it's the former.) Edit: I'm failing to make a properly shareable minimal example, sorry for that - so it's more likely that it's my fault than otherwise. But, in case anyone else stumbles upon this, setting the filesystem name to a known working name - such as Full stack trace
|
Hmm, today I got the same error while rebuilding my system, thought the issue was on my side since I changed a lot of stuff in my config. |
That's not a good idea. Those configs are incompatible between fontconfig versions. |
@PgBiel I'm also experiencing this same issue; from what I see, this happens when the Another very ugly, impure approach is to replace |
If aggregatedIcons = pkgs.buildEnv {
name = "system-icons";
paths = config.environment.systemPackages;
pathsToLink = [ "/share/icons" ];
}; Then refer to it instead. |
After a quick search, I found this. I am not a developer, can anyone tell me can this option be used? |
Unfortunately not, you can use it to change the path bind mounted by flatpak but it won't work on NixOS because an aggregated folder is a set of symlinks and regular bind mounting won't resolve them automatically |
This also does not work, at least from what I can see. Infinite recursion error remains. |
This is the best I could come up with as someone hitting the infinite recursion issue. I have replaced the This works for the Firefox Flatpak, but the VSCodium Flatpak does not use the cursor icons for some reason. Anyway, hope this helps someone. Really looking forward to seeing if someone can crack the case on that infinite recursion error, to remove this package hardcoding workaround from this Flatpak workaround! {
system.fsPackages = [ pkgs.bindfs ];
fileSystems = let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
};
aggregatedIcons = pkgs.buildEnv {
name = "system-icons";
paths = with pkgs; [
#libsForQt5.breeze-qt5 # for plasma
gnome.gnome-themes-extra
];
pathsToLink = [ "/share/icons" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.packages;
pathsToLink = [ "/share/fonts" ];
};
in {
"/usr/share/icons" = mkRoSymBind "${aggregatedIcons}/share/icons";
"/usr/local/share/fonts" = mkRoSymBind "${aggregatedFonts}/share/fonts";
};
fonts = {
fontDir.enable = true;
packages = with pkgs; [
noto-fonts
noto-fonts-emoji
noto-fonts-cjk
];
};
} |
PR with fix: #262462 (posting here to notify issue subscribers) |
I've been having this issue with flatpak element. the cursor is the default wayland cursor instead of the gnome one. |
hopefully this gets fixed soon |
{ config, pkgs, ... }:
let
home-path = ''${config.home-manager.users.your_user_name.home.path}'';
home-files = ''${config.home-manager.users.your_user_name.home-files}'';
icon_theme_name = ''${config.home-manager.users.your_user_name.gtk.iconTheme.name}'';
theme_name = ''${config.home-manager.users.your_user_name.gtk.theme.name}'';
cursor_theme_name= ''${config.home-manager.users.your_user_name.gtk.cursorTheme.name}'';
in
let
gawk=''${pkgs.gawk}/bin/gawk'';
flatpak=''${pkgs.flatpak}/bin/flatpak'';
su=''${pkgs.su}/bin/su'';
cursor_theme_path=''${home-files}/.local/share/icons/${cursor_theme_name}'';
icon_theme_path=''${home-files}/.local/share/icons/${icon_theme_name}'';
theme_path=''${home-files}/.local/share/themes/${theme_name}'';
icon_theme_path_1=''${home-path}/share/icons/${icon_theme_name}'';
theme_path_1=''${home-path}/share/themes/${theme_name}'';
in
let
workaround =
''
${gawk} -i inplace '{gsub(/\/nix\/store[^;]*;|!\/nix\/store[^;]*;/,""); print}' /var/lib/flatpak/overrides/global
${gawk} -i inplace '{gsub(/filesystems=/,"filesystems=${icon_theme_path};${theme_path};${cursor_theme_path};"); print}' /var/lib/flatpak/overrides/global
${gawk} -i inplace '{gsub(/\/nix\/store[^;]*;|!\/nix\/store[^;]*;/,""); print}' /home/your_user_name/.local/share/flatpak/overrides/global
${gawk} -i inplace '{gsub(/filesystems=/,"filesystems=${icon_theme_path};${theme_path};${cursor_theme_path};"); print}' /home/your_user_name/.local/share/flatpak/overrides/global
${flatpak} override --env=GTK_THEME=${theme_name}
${su} your_user_name -c '${flatpak} override --user --env=GTK_THEME=${theme_name}'
'';
in
{
services = {
flatpak = {
enable = true;
};
};
##workaround for themes and icons
systemd.services.workaround-for-theme-and-icons = {
wantedBy = ["multi-user.target"];
after = ["systemd-user-sessions.service"] ;
before = ["getty.target"] ;
script = workaround;
};
home-manager.users.your_user_name.home.file = {
".local/share/icons/${icon_theme_name}".source = config.home-manager.users.your_user_name.lib.file.mkOutOfStoreSymlink "${icon_theme_path_1}";
".local/share/themes/${theme_name}".source = config.home-manager.users.your_user_name.lib.file.mkOutOfStoreSymlink "${theme_path_1}";
};
} since soon isn't coming anytime soon it seems here's my temporary fix |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Describe the bug
Flatpak mounts /usr/share/icons and /usr/share/fonts to /run/host/share/icons and /run/host/fonts respectively. However, this doesn't work on NixOS since all fonts/icons are in their own directories in /nix/store. While the lack of icon theme in flatpak apps is not so a big problem, the lack of system fonts leads to inability to read text written in some languages. The font for Latin characters is Deja Vu is that case that is too bold and has bad readability (at least for me). I'm suffering from this issue for a long time and thought that at some point someone raise this or this will be fixed at some time by someone, but I can't take it anymore :(
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Flatpak is patched so that it can read fonts and icons. Or some option that enables centralized storage of fonts/icons and Flatpak uses it.
Screenshots
How it looks like outside of flatpak:
Notify maintainers
@jtojnar
Metadata
Maintainer information:
The text was updated successfully, but these errors were encountered: