Can a desktop run inside of a Flatpak?

Is it possible to run an entire desktop inside of Flatpak? I know it would be tricky due to permissions and the sandbox but if the desktop could execute commands outside of the sandbox it could work. This might be totally out of the realm of possibility. I just thought it would be interesting.

I was thinking about this because I was pondering what it would take to make a Linux system that is TV friendly. We already have Kodi but it is dated and not as great of an experience as Google TV. I have no intentions of actually making anything for TV but I was just thinking about it for fun.

I think one of the biggest benefits of Android/AOSP is the fact that almost all the apps are shipped as apps and not a part of the core OS. You can install alternate launchers and apps are sandboxed.

Not really. Your desktops environment is what includes the portals that are needed for Flatpaks to work and communicate with the outside of the sandbox. Those can not run inside a Flatpak sandbox.

You can run a desktop environment from a container however: Issue #299: Containerized Fedora KDE - SIG - Pagure.io

In that metaphor, an Android launcher would also not be a separate desktop but just a part of it.

I assume making a different launcher as a Flatpak would work fine

The equivalent to switching launchers on Android for the Linux desktops would be switching the desktop layout in Plasma, not switching from KDE to GNOME.