Skip to content

Flatpak support#54

Merged
Hyperchaotic merged 14 commits intocosmic-utils:mainfrom
CarsonBurke:flatpak
Jun 14, 2025
Merged

Flatpak support#54
Hyperchaotic merged 14 commits intocosmic-utils:mainfrom
CarsonBurke:flatpak

Conversation

@CarsonBurke
Copy link
Copy Markdown
Contributor

Currently using the build command:

flatpak-builder \                                                                                                                                                                          
      --force-clean \
      --verbose \
      --ccache \
      --user --install \
      --install-deps-from=flathub \
      --repo=repo \
      flatpak-out \
      io.cosmicUtils.cosmicAppletMinimon.

I used official Flatpak documentation, as well as Tweaks and web apps as reference.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

Currently is not building correctly. Getting the following build error:

Running: cargo --offline build --release --verbose
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/cosmic-applet-minimon --nofilesystem=host:reset --filesystem=/home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/build/cosmic-applet-minimon-5 --bind-mount=/run/build/cosmic-applet-minimon=/home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/build/cosmic-applet-minimon-5 --build-dir=/run/build/cosmic-applet-minimon --bind-mount=/run/ccache=/home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1749769163 '--env=CFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=CXXFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' '--env=CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold' --env=CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang '--env=CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold' --env=CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang --env=CARGO_HOME=/run/build/cosmic-applet-minimon/cargo --env=CCACHE_DIR=/run/ccache --env=PATH=/run/ccache/bin:/app/bin:/usr/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=16 /home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/rofiles/rofiles-6kzaUW /bin/sh -c 'cargo --offline build --release --verbose'
error: could not find `Cargo.toml` in `/run/build/cosmic-applet-minimon` or any parent directory
Error: module cosmic-applet-minimon: Child process exited with code 101
FB: Unmounting read-only fs: fusermount -uz /home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/rofiles/rofiles-6kzaUW

I'll keep experimenting to figure it out. It seems like there may need to be a cargo-sources.json file, might be related.

@CarsonBurke CarsonBurke mentioned this pull request Jun 12, 2025
@CarsonBurke
Copy link
Copy Markdown
Contributor Author

just flatpak-install now successfully generates a flatpak.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

Stuck on dependencies now when running the flatpak builder. Getting a warning that doesn't make much sense, but more notably a dependency error that I haven't been able to resolve.

warning: `/run/build/cosmic-applet-minimon/cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
error: failed to select a version for the requirement `windows-link = "^0.1"` (locked to 0.1.3)
candidate versions found which didn't match: 0.1.1
location searched: directory source `/run/build/cosmic-applet-minimon/cargo/vendor` (which is replacing registry `crates-io`)
required by package `chrono v0.4.41`
    ... which satisfies dependency `chrono = "^0.4"` (locked to 0.4.41) of package `cosmic-applet-minimon v0.5.2 (/run/build/cosmic-applet-minimon)`
perhaps a crate was updated and forgotten to be re-vendored?
Error: module cosmic-applet-minimon: Child process exited with code 101
FB: Unmounting read-only fs: fusermount -uz /home/marvin/Documents/GitHub/minimon-applet/.flatpak-builder/rofiles/rofiles-6kzaUW

I'm able to build and do everything fine, the flatpak builder is the only one having this dependency issue.

@Hyperchaotic
Copy link
Copy Markdown
Collaborator

Hyperchaotic commented Jun 13, 2025

Great work! I was worried about nvml_wrapper loading libnvidia-ml.so but it might work automagically because of how Flatpak handles Nvidia dependencies and you have added “—device=all” (crossing fingers, suppressing quaking fear). When testing we’ll see if we’ve included enough sysfs stuff for other sensors, sysfs can have links, so we’ll see how that goes… also I added systemd journal logging in release builds, hope that works through Flatpak.

Thoughts: In the future we could consider whether there’s an xdg-portals pop-up thing where the user gives permission to sysfs access (et al) upon installation, or if not to begin with maybe explain why it’s required (on the Flathub page)? I haven’t looked into what’s recommended.

How does COSMIC handle Flatpak applets, so they appear in Settings? Is it sorted yet? Edit2: I realized last night it'll probably just work but it'll need its own .desktop file that launches with "flatpak run".

I’ll work on a logo/icon, I don’t have a single creative cell in my body, if I come up with something terrifying we’ll look for help..

I’ll look at that error tomorrow if I can, I just run the command in first comment? EDIT: Oh there’s a just command to create a Flatpak.

<caption>A styled instance of the applet with with the window view open.</caption>
</screenshot>
</screenshots>
<provides>
Copy link
Copy Markdown
Contributor

@jackpot51 jackpot51 Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add <id>com.system76.CosmicApplet</id> here? See https://github.com/cosmic-utils/tasks/blob/main/res/dev.edfloreshz.Tasks.metainfo.xml#L113C1-L113C44 for a reference

@Hyperchaotic
Copy link
Copy Markdown
Collaborator

just flatpak-builder seems to complete for me now. It seems to both build and install.
fp-build.txt

I can run it manually with flatpak run io.cosmicUtils.cosmicAppletMinimon, sensors seems to work, even Nvidia and journalctl SYSLOG_IDENTIFIER=cosmic-applet-minimon shows log output.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

CarsonBurke commented Jun 13, 2025

Strange. I'm still having the smithay dependency error at the vendorer stage of flatpak-builder

error: checksum for `smithay-client-toolkit v0.19.2` could not be calculated, but a checksum is listed in the existing lock file

this could be indicative of a few possible situations:

    * the source `registry `crates-io`` supports checksums,
      but was replaced with one that doesn't
    * the lock file is corrupt

unable to verify that `smithay-client-toolkit v0.19.2` is the same as when the lockfile was generated

If it's working for you though I figure something's just wrong with my setup. I guess we can make a PR to add it to Flathub now?

@Hyperchaotic
Copy link
Copy Markdown
Collaborator

Strange, I cloned a new copy of Minimon, fetched and checked out your pr and built it. I'm not sure if there's a Flatpak bundle file somewhere.

It still needs a different .desktop file for identifying/launching the Flatpak (it won't show up in COSMIC Settings without it) and that icon for Flathub.

But I could merge this PR as a first step, then we can move on from there. Perhaps if we do that it'll start working for you.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

Yeah idk, I cloned a new copy and checked out the pr and got the same error :/

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

CarsonBurke commented Jun 13, 2025

Building successfully on nightly. Are you also getting the filter-but-no-output error?

Composing metadata...
Run failed, some data was ignored.
Errors were raised during this compose run:
general
  E: filters-but-no-output

io.github.cosmicUtils.cosmicAppletMinimon
  E: icon-not-found
Refer to the generated issue report data for details on the individual problems.
Error: ERROR: appstreamcli compose failed: Child process exited with code 1

I think this can be merged, then we add an icon, then we adjust the source to git. Then we can make the Flathub PR.

@CarsonBurke CarsonBurke marked this pull request as ready for review June 13, 2025 20:39
@Hyperchaotic
Copy link
Copy Markdown
Collaborator

Yeah now I get this error.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

I suspect that would be because it's properly referencing the .metainfo.xml and .desktop files correctly now? Seems like it's still not correctly finding the metainfo.xml though, but I don't see where it's wrong. flatpak-metainfo-dst seems correct.

@wash2
Copy link
Copy Markdown

wash2 commented Jun 13, 2025

To test installation with this PR, and have the icons and desktop file exported properly, I had to adjust the Id to all match io.cosmicUtils.cosmicAppletMinimon. Or have I missed something?

In addition, I'm not sure it makes a lot of sense to add the %F in the Exec for an applet?

Lastly in the justfile, the flatpak icons destination is missing the last component
flatpak-icons-dst := flatpak-base-dir / 'share' / 'icons' / 'hicolor' / 'scalable'.

There might be more issues still to work out, but this gets it started via the panel on https://github.com/pop-os/cosmic-panel/tree/flatpak. I still need to fix the way that it is started so that the WAYLAND_SOCKET is used by the app though.

@wash2
Copy link
Copy Markdown

wash2 commented Jun 13, 2025

Seems like it's still not correctly finding the metainfo.xml though, but I don't see where it's wrong. flatpak-metainfo-dst seems correct.

I believe this is the same issue as I mention in my previous comment. The ID doesn't match.

@CarsonBurke
Copy link
Copy Markdown
Contributor Author

CarsonBurke commented Jun 14, 2025

Thanks Wash! I included .github in the id, but otherwise your id recommendation and icon-dst change was very helpful. I've also removed the %F though @Hyperchaotic interested why this was included and if it should be kept (put back in)? I was able to successfully build and run the flatpak. And it's even working on KDE Plasma as expected on Cosmic

image

I think it's fully ready to merge now.

@Hyperchaotic
Copy link
Copy Markdown
Collaborator

Spectacular, thank you for your time everyone! It's very cool to see a COSMIC Flatpak applet!

The %F was probably a copy/paste thing from when I created the project.

@Hyperchaotic Hyperchaotic merged commit 5dea183 into cosmic-utils:main Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants