What would it take to package a flatpak-only and close-source application?

Is it even possible?

Sober would be a good example of this

It is a close-source application, distributed as a Flatpak only on Flathub

The only available packaging information I found about it is its manifest

Some projects seem to have wrapped it: GitHub - equinoxhq/lucem: An open-source bootstrapper for Sober, similar to Bloxstrap.
So it might be possible to package such application in nixpkgs too?

Personally, I’d just keep it in flatpak and use nix-flatpak to manage it. The sandboxing benefits of flatpak are nice. But if you want to pull it out, the .yml in that manifest repo you linked is a good guide. At the bottom it has the archive and a list of commands to install it from the archive, which are exactly what you’d need for nixpkgs. I think you’d just need to add a patchelf command to fix the library paths.

I’m currently using declarative-flatpak which I recommend over nix-flatpak (also see Flatpak - Official NixOS Wiki), a bit off-topic
But the problem I have with applications like Sober is the hard dependency on the flatpak runtime.

I actually reached out to @xTrayambak (the maintainer of GitHub - equinoxhq/lucem: An open-source bootstrapper for Sober, similar to Bloxstrap., among others) on Discord and this was his reply:

Heya, this would be fairly difficult from what I know. I am in contact with one of the Sober developers and she apparently does have a Nix build environment for Sober, but it is a source build system, not something that takes the Flatpak binary and Nixifies it.

I’m currently down with a headache, but I’d be more than happy to answer more of your questions later. :^)

Re: the hard dependency on the flatpak runtime, I assume that’s in the form of linked libraries. Have you run ldd on the binary and looked at what it requires? You should be able to use patchelf (or autoPatchelfHook) to fulfill those requirements on nix. Failing that, you could try to build a FHS environment like nixpkgs does for the Zoom binary (also closed-source and not built for nix).

1 Like