Hacker News new | ask | show | jobs
by kirbyfan64sos 1199 days ago
I actively use both Nix and Flatpak, and my perspective is that they're tuned for different purposes:

- Flatpak doesn't require apps to be rebuilt when the runtime changes, whereas Nix would require a rebuild. This is, of course, an intentional selling point for Nix: you don't have to worry about keeping track of ABIs and the like. This is, however, less fun when you have to update a large amount of applications for little reason. - When using flakes, it's easy to end up with a lot of extra disk usage because of a proliferation of different nixpkgs versions. Flatpak's runtimes help avoid this, since apps target a runtime version and can run under any individual commit for that version. - Flatpak has a massive amount of internal infra for sandboxing that would take a moderate effort to reproduce elsewhere. - This also means that running Flatpaks always involves new user namespaces; this can't just use environment variables like Nix does. - Flatpak's entire setup is more tuned towards GUI applications, with support for stuff like swapping out the graphics drivers. (nixOS can ofc do this, but you need nixGL otherwise.) - Flatpak has support for downloading non-redistributable files at install time and placing them in the same location as the application's main files. - Flatpak's summaries that it downloads from the server are much smaller than nixpkgs checkouts. - Flatpak dedups individual files across apps.

Really, it's just that Flatpak prefers keeping the build process and usage simpler to focus the energy on sandboxing, leading to design decisions like the more straightforward runtime/app split (easier for a user to understand / manage) and all of the built-in extras for graphical applications. Nix has a significantly more complex UX but is infinitely more flexible and also far better suited for development environments.

If your thought is "most of this isn't structural", that wouldn't be incorrect: there is no reason that:

- building flatpaks couldn't use a more nix-like model - nix couldn't add sandboxing and summary support on top

Heck, you could probably build a Flatpak from a Nix derivation, if you figured out how to separate the "runtime" and "app" parts. But at the end of the day, every tool has some limited degree of development bandwidth, and as-is, Flatpak and Nix just optimized that bandwidth for different targets.

1 comments

> Flatpak doesn't require apps to be rebuilt when the runtime changes, whereas Nix would require a rebuild. This is, of course, an intentional selling point for Nix

I doubt it's intentional. Guix has solved the problem---update the runtime without rebuilding the app---while being fairly similar to Nix's concepts in general.