Should I give up on flatpak?

Apologies in advance for a noob-ish question, but I am new to flatpak and having trouble.

Long time user of Kodi media player here, which I run on an Ubuntu 24.04.2 LTS server. It’s a standalone setup, with no keyboard, mouse, and no windowing system. Kodi switched from PPA to flatpak and a number of ppl (including me) have had problems upgrading.

It’s starting to feel too arcane, too fragile, and I’m seriously wondering if I should continue or just give up on flatpak and take a different approach.

I’ve gotten the flatpak installed and Kodi will launch, but some things aren’t working and I guess I’m not setting up the sandboxing correctly. I’ve done sudo flatpak update and flatpak update tv.kodi.Kodi. “Nothing to do.”

Some Kodi users suggest that my /etc/systemd/system/kodi.service file should look like this:

[Unit]
Description = Kodi Media Center

After = systemd-user-sessions.service network.target sound.target network-online.target

[Service]
User = kodi
Group = kodi
Type = simple
ExecStart = /usr/bin/flatpak run --filesystem=/run/udev:ro --filesystem=home:ro tv.kodi.Kodi --standalone --windowing=gbm
ExecStop = /usr/bin/flatpak kill tv.kodi.Kodi
Restart = always
RestartSec = 5

[Install]
WantedBy = multi-user.target

I’ve tried this but there are still issues. It seems Kodi wants access to /usr and all the music and movie files are in /media, and so I had to issue an override, but I’m guessing probably I should do everything in the ExecStart line.

Basically, I don’t understand the --filesystem directives (i.e., why do I need /run/udev? Why home:ro and not /home:rw? How are /usr and /media accessed?), or what I should put here to make Kodi work as expected.

I have looked at the Flatpak documentation, in particular Sandbox Permissions, and maybe(?) host is what I want but there are no examples to illustrate its usage and the whole discussion is pretty much above my pay grade.

How should I proceed?

Well, first of all:
Flatpak is primarily designed to be used on a desktop with desktop applications, so this use-case is a bit outside of the design.

Anyway, I can’t help much about Kodi itself or how you intend to use it, but I can point a few things out about the filesystem.

Flatpak uses a sandbox, so it normally will not be able to access files on the host system, only the files it was packaged with and its own configuration data.
You can use the filesystem argument to add access to certain folders.

Now, about the filesystems specifically:

  • filesystem=/run/udev:ro and filesystem=home:ro seem to be changes made by the user who recommended this SystemD file. Normally, Kodi seems to be configured for read and write on these folders, so this seems to narrow the permission down.
  • /media should be able to be accessed, as Kodi sets this permission.
  • The /usr of the host is not accessible, as it is provided by the runtime Kodi is using. There exists the option host-os, in which case the host /usr is mounted in the sandbox to /run/host/usr.

Thanks for your message.

This is helpful, especially knowing that running an application as a standalone service is not considered an ordinary use case for flatpak.

I’m still unclear how to troubleshoot what I’m seeing and the Kodi community isn’t really answering questions about flatpak, so I’m now looking at simply wiping my Ubuntu server and starting over with LibreElec, which is a minimal Linux that runs Kodi standalone.

Never run flatpak with sudo - there is like one command that I’m aware of, that actually needs that.

You might want to list, what actually isn’t working. Why do you think kodi wants /usr access?