Flatpak applications not using my set cursor

Good day/evening everyone,

This should (hopefully) be a simple one, despite the finicky nature of flatpaks. So, as the title states, I can not get flatpak applications to use the cursor theme that I set. Let me firstly share with you how I set said cursor theme:

  let
buuf-cursor-heart = pkgs.stdenvNoCC.mkDerivation {
    pname = "buuf-cursor-heart";
    version = "master";

    src = pkgs.fetchurl {
      url = "https://cdn.discordapp.com/attachments/156048223314640896/1217582363610189976/buuf-cursor-heart-24-a.tar.gz?ex=66048cf1&is=65f217f1&hm=c0a36941976578400cd12a7fefd4236785a94d17e19c784ee6f01d0afcb45984&";
      hash = "sha256-ZKqWw0Itro9CQIJyouLxel76C80kie8EYkmm2Kc0iJs=";
    };

    dontPatch = true;
    dontConfigure = true;
    dontBuild = true;
    dontFixup = true;

    installPhase = ''
      mkdir -p $out/share/icons/buuf-cursor-heart
      mv * $out/share/icons/buuf-cursor-heart/
    '';
  };
 in
 {

  home.packages = (with pkgs; [
    buuf-cursor-heart
  ]);

  qt = {
    enable = true;
    platformTheme = "qtct";
    style.name = "kvantum";
   };
  gtk = {
    enable = true;
    theme = {
      name = "Dracula";
      package = pkgs.dracula-theme;
    };  
    gtk3.extraConfig = {
      gtk-application-prefer-dark-theme = 1;
    };
    gtk4.extraConfig = {
      gtk-application-prefer-dark-theme = 1;
    };
    iconTheme = {
      name = "Buuf For Many Desktops";
      package = buuf-nestort;
    };  
    cursorTheme = {
      name = "buuf-cursor-heart";
      package = buuf-cursor-heart;
      size = 24;
    };
  };

   home.pointerCursor = {
     name = "buuf-cursor-heart";
     package = buuf-cursor-heart;
     size = 24;
     gtk.enable = true;
     x11.enable = true;
   };

After a lot of looking around, I found this wiki page: Fonts - NixOS Wiki. I tried out the bindfs, flatpak overriding and symlinking proposed solutions. None have made any difference at the end though. Was I supposed to, perhaps, change anything in the bindfs code block, instead of just copy pasting it into my config file?

Anything else I can do in general?

Solution: So, what I did was, I simply allowed access, to one of the flatpak applications, to the entire file system, using flatseal. The cursor was then finally fixed. It was really silly. But I had to try out a bunch of nix store paths, after listing them with a find command. At the end I was able to find the path that did the trick.

Needless to say, this solution is surely not reproducible and will break sooner or later when the path changes…

1 Like

Had the same problem. But after half a year i finally found a solution.

Setting the cursor theme

Setting the cursor theme under home-manager with home.pointerCursor should be enough:

home.pointerCursor = {
  name = "buuf-cursor-heart";
  package = buuf-cursor-heart;
  size = 24;
};

Gnome Apps under Hyprland (at least for me) need an extra kick with:

wayland.windowManager.hyprland.settings = {
  exec-once = [
    # Fixes cursor themes in gnome apps under hyprland
    "gsettings set org.gnome.desktop.interface cursor-theme '${config.home.pointerCursor.name}'"
    "gsettings set org.gnome.desktop.interface cursor-size ${toString home.pointerCursor.size}"
  ];
};

Fixing cursor themes for flatpaks

But for flatpaks you also need to make sure the xdg-desktop-portal-gtk is running, which is not automatically always the case (espacially on tiling windowManagers). So in home-manager you can set:

xdg.portal = {
  enable = true;
  extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; # Fixes OpenURI and cursor theme in flatpaks
};

This already fixes themes for most apps like gnome. But not all (e.g. Obsidian or Logseq).

And since flatpaks are sandboxed and dont have access to the nix-store you need to give them permission, since the cursors are eventually linked to /nix/store/...:

flatpak --user override --filesystem=/nix/store:ro
# OR with the https://github.com/gmodena/nix-flatpak homeManagerModule
services.flatpak = {
  enable = true;

  overrides = {
    global = {
      # [Metadata keywords](https://docs.flatpak.org/en/latest/flatpak-command-reference.html?highlight=override#flatpak-metadata)
      Context.filesystems = [
        "/nix/store:ro"
      ];
    };
  };
};

I hope this helps!