music-assistant / companion

Music Assistant Companion App
https://music-assistant.io/companion-app/
Apache License 2.0
28 stars 4 forks source link

[Linux] Add flatpak #7

Open arctixdev opened 10 months ago

arctixdev commented 10 months ago

A flatpak file for installation would be extremely nice since we could add it to FlatHub which would make the app way more accessible for Linux users (Since appimages are kinda annoying to run). RPM would be nice as well

Tauri dosn't currently support bundling to a flatpak though... See https://github.com/tauri-apps/tauri/issues/3619

freundTech commented 1 month ago

There is a working tauri app on flathub here: https://github.com/flathub/in.cinny.Cinny I've looked into how their build works and am currently trying to build MA Companion this way.

EDIT: I got basic functionality working, but there are some problems to be worked out before submitting to flathub. Code is here: https://github.com/freundTech/flathub/tree/add-music-assistant-companion

arctixdev commented 1 month ago

That is super cool! If you need any help or have questions feel free to reach out! Either here or on the Discord

freundTech commented 1 month ago

To be published on flathub music-assistant will need an appstream metainfo file. That file includes all the information that will be shown on flathub.org and your distro's software manager, such an name, description, icon, screenshots, ...

While it's possible to keep the appstream metadata with the flatpak build manifest, it is preferred to keep it upstream, so in this repository.

I can also create the file once I have the packaging working, but it would probably be better if someone with more experience with music-assistant would create the file and commit it upstream.

https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/

freundTech commented 1 month ago

Also music-assistant-companion contains a self-updater, which should be disabled when installing from flathub. I can just patch that out, but it would be easier if it were exposed as a cargo feature.

arctixdev commented 1 month ago

Hey @freundTech, I created the metainfo file now! Again, thanks a bunch for creating the flatpak! About the updater, I am quite new to rust so you probably know more than me on the topic. But I think it a cargo feature already https://github.com/music-assistant/companion/blob/main/src-tauri/Cargo.toml#L17

freundTech commented 1 month ago

Thanks. I'll integrate the metainfo into the build.

The tauri updater itself is an optional feature of the tauri crate, however MA Companion adds some UI on top (At least the update button in the system menu and the check for updates button in the setting panel). It would be great to have those hidden behind a feature on the music-assistant-companion crate. The tauri feature can then be set to be a dependency of the music-assistant-companion feature.

I'm not that experience with rust myself, so I would have to look up the details for how to do this myself. For now I'm just using a patch in the flatpak build: https://github.com/freundTech/flathub/blob/add-music-assistant-companion/0001-disable-tauri-updater.patch

fabsau commented 1 month ago

I don't want to create a separate issue for that, but how about adding it to Homebrew (for Mac Users) and Chocolatey/WinGet for Windows users?

arctixdev commented 1 month ago

Yeah, I dont really have much experience with that myself. But I did try creating a homebrew package, but i dont know if it works. Right now I am trying to publish the app to the app store for mac.

arctixdev commented 1 month ago

Hey @freundTech, how is it going with the flatpak bundle? Please don't hesitate to reach out if you need any help :slightly_smiling_face:

freundTech commented 1 month ago

I was busy with exams last week. Have some more time now. The main problem is that mDNS currently doesn't work in flatpak (there is an upstream issue for this).

I think that I might be able to hack around it using LD_PRELOAD. If not we would need to patch in a notice that using homeassistant.local doesn't work and that you need to use the IP address instead.

arctixdev commented 1 month ago

Ah, cool! Yeah I'm also busy with exams at the moment 😄 Don't stress it if you don't have the time!

I don't have experience with flatpak or xdg, if you dont get mDNS to work, that's totally fine. We can just add a notice as you suggested.

arctixdev commented 3 weeks ago

FYI i switched the companion app to the 2.0 beta, meaning some stuff probably changed. But there seems to be a simple guide to creating the flatpak for v2 https://deploy-preview-1760--tauri-v2.netlify.app/guides/distribute/flatpak/ Though it hasnt been merged yet

freundTech commented 3 weeks ago

I took a quick look at that page and the template they offer. The main problem I see with it is that they don't build in a flatpak sandbox, but build on the host and then just copy the binary to the flatpak sandbox. This might be fine if you want to distribute the flat pack directly, but isn't going to get you onto flathub (which requires all flatpaks to be built in their CI without internet access at built time).

Building outside the sandbox could also potentially lead to linking against wrong versions of system libraries.

Also you would need to adjust their template to also copy squeezelite over (which my WIP build script builds from source)

arctixdev commented 3 weeks ago

Yeah, that was also the impression, I got. If you need any help, just reach out