Home

Awesome

Monomer Flatpak Example

A demonstration of the Monomer framework running inside Flatpak.

Flatpak provides a relatively easy way to deploy apps on Linux, using a standard package format that works on any supported Linux distrubution. It has runtime sandboxing and a "portals" system for access to the underlying operating system: this promises to be particularly useful for Monomer, because it provides things like file choosers that Monomer does not have natively.

The Flatpak manifest generated for this app builds everything from source. This is necessary to distribute the app on Flathub. If you don't care about Flathub and just want to distribute a standalone Flatpak with a binary executable inside it, then a Flatpak app bundle might be easier.

Screenshot

Current Status

The basic app is working as a Flatpak and has also been published onto Flathub. The app includes a basic portals demo.

How It Works

Portals

The XDG Desktop Portals APIs allow reading/writing files, accessing microphones/webcams, opening URIs, printing, etc. This app includes some buttons to demonstrate basic portal functionality (provided via the desktop-portal library).

Building a Flatpak bundle locally

It can sometimes be useful to build a Flatpak bundle locally, without first publishing to Hackage. This is possible without too many hacks, by building a regular executable and bundling that straight into a Flatpak, along with the assets. It does require an extra manifest though.

For example, to build and run this project locally:

# compile the executable and assets into files that can be injected into the flatpak bundle
stack clean --full
stack --local-bin-path flatpak/binary install
tar -cf flatpak/binary/assets.tar assets/*

# build a manifest that refers to the executable and assets, rather than the source code
flatpak-builder --user --install --force-clean flatpak/binary/build flatpak/io.github.Dretch.MonomerFlatpakExample.binary.yml

# run the app
flatpak run io.github.Dretch.MonomerFlatpakExample.binary

FAQs

Gotchas

Development Guide

To format the source code

# Should use Ormolu 0.7.3.0
ormolu --mode inplace $(find app -name '*.hs')