Flatpak Distribution on Linux

Following the Slack Flatpak manifest as an example, I think I’ve gotten to a pretty good place with this. I copied the Mailspring .desktop, appdata.xml, and icon png files to the root flatpak directory I made, then changed the Flatpak yml file to look like this:

app-id: com.getmailspring.Mailspring
runtime: org.freedesktop.Platform
sdk: org.freedesktop.Sdk
runtime-version: '20.08'
base: org.electronjs.Electron2.BaseApp
base-version: '20.08'
sdk-extensions:
  - org.freedesktop.Sdk.Extension.node14
separate-locales: false
command: mailspring
finish-args:
  - --share=ipc
  - --socket=x11
  - --socket=pulseaudio
  - --share=network
  - --talk-name=org.freedesktop.secrets
  - --talk-name=org.freedesktop.Notifications
  - --talk-name=org.freedesktop.Flatpak
  - --system-talk-name=org.freedesktop.login1
  - --talk-name=org.kde.StatusNotifierWatcher
  - --talk-name=com.canonical.AppMenu.Registrar
  # probably not necessary for system tray icon, at least in GNOME.
  #- --own-name=org.kde.StatusNotifierItem-3-2
build-options:
  append-path: /usr/lib/sdk/node14/bin
  cflags: -O2 -g
  cxxflags: -O2 -g
  env:
    NPM_CONFIG_LOGLEVEL: info
modules:
  - shared-modules/libsecret/libsecret.json
  - name: mailspring
    buildsystem: simple
    sources:
      - type: extra-data
        filename: mailspring.deb
        only-arches:
          - "x86_64"
        url: https://github.com/Foundry376/Mailspring/releases/download/1.9.1/mailspring-1.9.1-amd64.deb
        sha256: 99fa700d84691542c3f5387cb48e72a9be516166491daadb598a5f292dd0ea61
        size: 87784166
      - type: script
        dest-filename: apply_extra
        commands:
          - ar x mailspring.deb
          - rm -f mailspring.deb
          - tar xf data.tar.xz
          - rm -f control.tar.gz data.tar.xz debian-binary
          - mv usr/* .
          - chmod -R a-s,go+rX,go-w .
          - rmdir usr
      - type: file
        path: mailspring-16x16.png
      - type: file
        path: mailspring-32x32.png
      - type: file
        path: mailspring-64x64.png
      - type: file
        path: mailspring-128x128.png
      - type: file
        path: mailspring-256x256.png
      - type: file
        path: mailspring.appdata.xml
      - type: file
        path: mailspring.desktop
      # Wrapper to launch the app
      - type: script
        dest-filename: mailspring.sh
        commands:
          - exec env TMPDIR=$XDG_CACHE_HOME zypak-wrapper /app/extra/share/mailspring/mailspring -s $EXTRA_ARGS \"$@\"
    build-commands:
      - install apply_extra ${FLATPAK_DEST}/bin
      - install mailspring.sh ${FLATPAK_DEST}/bin/mailspring
      - install -Dm644 mailspring.appdata.xml ${FLATPAK_DEST}/share/appdata/${FLATPAK_ID}.appdata.xml
      - install -Dm644 mailspring-16x16.png ${FLATPAK_DEST}/share/icons/hicolor/16x16/apps/${FLATPAK_ID}.png
      - install -Dm644 mailspring-32x32.png ${FLATPAK_DEST}/share/icons/hicolor/32x32/apps/${FLATPAK_ID}.png
      - install -Dm644 mailspring-64x64.png ${FLATPAK_DEST}/share/icons/hicolor/64x64/apps/${FLATPAK_ID}.png
      - install -Dm644 mailspring-128x128.png ${FLATPAK_DEST}/share/icons/hicolor/128x128/apps/${FLATPAK_ID}.png
      - install -Dm644 mailspring-256x256.png ${FLATPAK_DEST}/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png
      - install -Dm644 mailspring.desktop ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
      - desktop-file-edit --set-key="Icon" --set-value="com.getmailspring.Mailspring" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
      - desktop-file-edit --set-key="Exec" --set-value="mailspring %U" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
      - desktop-file-edit --set-key="StartupWMClass" --set-value="Mailspring" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
      - desktop-file-edit --set-key="X-Flatpak-RenamedFrom" --set-value="mailspring.desktop;" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
      - install -Dm755 /usr/bin/ar -t ${FLATPAK_DEST}/bin
      - install -Dm755 /usr/lib/$(gcc -print-multiarch)/libbfd-*.so -t ${FLATPAK_DEST}/lib

Now my Linux distro picks up the .desktop file and icons (including the tray icon) automatically. :tada:

I’m actually working on a source build of mailspring for flatpaks, this would in theory allow us to support arches like armv8. There was actually already an attempt to submit a flatpak using the deb to flathub that was turned down due to the fact there is nothing preventing a source build. Could the team bump the cld version to 2.7? 2.6 can’t be built since its missing some #include <exception> in certain files.

could someone help me with building mailspring offline? I’ve gotten to past installing deps. Attempting to build the Mailspring it makes network requests which doesn’t work

Mayb we can check-in here with likes and comments to get help from flatpak “guru”?

BINGO!
It’s on flathub today!
https://flathub.org/apps/details/com.getmailspring.Mailspring
Test it!

P.S. Ok. Failed to start on Wayland. Try it on X11.

The Flatpak version complains about missing libsecret for me. The Snap version works.

Not working on Fedora 35
❯ flatpak run com.getmailspring.Mailspring
[2 preload-host-spawn-strategy] Running: /app/bin/zypak-helper child - /app/share/mailspring/mailspring --type=zygote
The futex facility returned an unexpected error code.
Failed to generate minidump.%

It’s working for me on Fedora 35.

1 Like

Should set X11 socket (not Wayland) for flatpak bundle permissions. Use Flatseal.
I use it on Fedora 35.

I created a pull request to remove the permission to wayland socket until someone make it work on wayland.

I tested with the flathub app, and removing this permission with flatseal makes it work as mentioned above.

1 Like

Note: Flatpak isn’t supported officially, So Please open issues on github repository of Mailspring’s flatpak instead.

3 Likes

I did install through Flathub—An app store and build service for Linux

I have to say, i did discover Malspring browsing FlatPak “FlatHub” !

So thanks guys for getting to FlatPak.

2 Likes

I love Mailspring and would love to see Flatpak being preferred over Snap on the downloads page.

5 Likes

Flatpak version is unofficial and unmaintained at the moment.

Still Mailspring at Flathub count about 96,964 installs. It would be interesting if the team maintain it so that it could get the verified star as well.

3 Likes

Bumping it up. In my first year with Mailspring, I had to reinstall it and set everything up from scratch THREE times due to Linux updates and how snap unreliable is. Installed via flatpak - 0 problems ever since in over a year.

3 Likes

Flatpak should have been the choice to support because of how fast the community adopted it. The markers were obvious. Hope the team will release a verified version on Flathub.

With the way things are going, I doubt they will put out an official flatpak anytime soon. You might have better luck reaching out to whomever made the unofficial flatpak instead…

There is currently no maintainer for the unofficial flatpak. The previous guy said so himself :confused:

prateekmedia commented last week

I am not actively maintaining this repository.

1 Like

With the growth of Atomic/Immutable Linux distros, an official Flatpak is becoming more important. While there often are still ways to install it, it is not efficient or ideal due to how they work. Snaps are generally not well-received outside of Ubuntu distros.

1 Like

Yes need this. It is a pain to use it on Bluefin.

1 Like