How to increase the file descriptor limit (NOFILE/ulimit -n) for a Flatpak app? VKD3D shader cache issue

Hello,

I’m facing a problem with the Heroic Games Launcher (com.heroicgameslauncher.hgl) and a game (Horizon Forbidden West) running via Wine/Proton. The game uses VKD3D-Proton to cache DX12 shaders.

The Problem:
Every time I exit the game, the shader cache merge process (from vkd3d-proton.cache.write to vkd3d-proton.cache) seems to fail. I suspect this is because the file descriptor limit (ulimit -n) inside the Flatpak sandbox is only 1024. The process likely needs to open thousands of files to merge the cache and hits this limit.

  • Proof: flatpak run --command=sh com.heroicgameslauncher.hgl -c "ulimit -n" returns 1024.

  • Result: The .write file is left behind, the main .cache doesn’t update, and the game recompiles all shaders from scratch on every launch (taking several minutes).

My Question:
Is there an official or recommended way to increase this RLIMIT_NOFILE for a specific Flatpak application?

What I’ve tried (unsuccessfully):

  1. Creating a systemd user override for the app’s scope (e.g., app-flatpak-com.heroicgameslauncher.hgl-*.scope). This didn’t work because the limit seems to be enforced earlier by the sandbox (bwrap).

  2. Setting the WINE_FD_LIMIT=1048576 environment variable inside the sandbox. This does not affect the actual OS-level limit.

Is this the right approach?
Would a flatpak override command like the one below work? If so, is there a specific parameter that directly controls the file descriptor limit for the sandboxed process?

flatpak override --user com.heroicgameslauncher.hgl --env=WINE_FD_LIMIT=1048576 # (plus other necessary permissions)

Or is there another mechanism I should use? If possible, could you provide an example of a working configuration?

System Information:

  • Distribution: Fedora Linux 42 (Rawhide)

  • Flatpak version: flatpak --version1.16.2

  • Affected application: com.heroicgameslauncher.hgl

Any guidance would be greatly appreciated. This issue severely impacts the usability of demanding DX12 games through Flatpak.

Thank you for your help!