Generate a Flatpak manifest from a Cabal package description
  • Haskell 96.9%
  • Just 3.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-27 14:15:12 +01:00
assets Remove --destination and add --local for (you guessed it) local dev 2026-11-12 18:15:56 +01:00
src In Setup mode, do not emit cabal-install sources in the yaml 2026-11-27 12:56:20 +01:00
vendor/cabal-plan Use vendored cabal-plan (based on fgaz/cabal-plan) to read the plan file 2026-11-18 17:09:12 +01:00
.gitignore Remove --destination and add --local for (you guessed it) local dev 2026-11-12 18:15:56 +01:00
cabal-flatpak.cabal Reduce the description, there's already a README 2026-11-27 14:15:12 +01:00
cabal.project Add a cabal.project file and commit the freeze file for reproducibility 2026-11-11 22:33:34 +01:00
cabal.project.freeze Use vendored cabal-plan (based on fgaz/cabal-plan) to read the plan file 2026-11-18 17:09:12 +01:00
CHANGELOG.md Use vendored cabal-plan (based on fgaz/cabal-plan) to read the plan file 2026-11-18 17:09:12 +01:00
fourmolu.yaml Use fourmolu to style the codebaseq 2026-11-11 23:20:32 +01:00
justfile Switch to yamlet syntax tree for building the YAML 2026-11-12 18:26:12 +01:00
LICENSE initial version: list transitive dependencies using cabal-plan 2019-07-22 19:38:01 +00:00
README.md In Setup mode, do not emit cabal-install sources in the yaml 2026-11-27 12:56:20 +01:00

cabal-flatpak

cabal-flatpak generates the files necessary for packaging a Haskell application with Flatpak. All the dependencies are explicitly pinned, in order to ensure reproducible builds.

Usage

Generate the files

You need cabal-install 3.18.1.0 or later.

Run the command in your project:

$ cd /path/to/my-package
$ cabal build --dry-run --disable-tests --disable-benchmarks
$ cabal-flatpak generate --arch x86_64 --arch aarch64

The command reads the build plan that cabal computes (dist-newstyle/cache/plan.json) and the .cabal file of your package.

The following files are then written in the project's root:

  • haskell-sources.yaml: Flatpak modules that build GHC and all dependencies of your package (and cabal-install, with --cabal-install).
  • <id>.yaml: a stub manifest for your application.
  • <id>.metainfo.xml: a stub MetaInfo file for Flathub.
  • <id>.desktop: a stub desktop entry.

The application ID <id> comes from the homepage field of the .cabal file. For example, https://codeberg.org/haskell/cabal-flatpak becomes page.codeberg.haskell.cabal-flatpak. This works for GitHub, GitLab, Codeberg, Framagit and SourceForge. For any other host, the ID is the reversed domain plus the package name (https://xmonad.org becomes org.xmonad.<package>), and the stub files have a FIXME comment. Without a homepage, the ID is com.example.<package>.

Options

Files written

By default, both the stub manifest files and the dependencies file are written. You should only need to generate the manifest once, only re-generate the dependencies.

  • --dependencies: write haskell-sources.yaml only.
  • --manifest: write the stub files only.
  • --force: overwrite existing files. Without it, the command skips them and prints a message.
  • --directory DIR: where the search for the project root starts. The default is the current directory.
  • --local: build the application from the project directory. The default is its Git repository. The manifest gets a dir source with path: ., which skips dist-newstyle and .flatpak-builder. All generated files have .local before their extension, for example haskell-sources.local.yaml and <id>.local.yaml. Add *.local.* to .gitignore.
  • --icon FILE: the SVG or PNG icon that the manifest installs, relative to the project root. Without it, the manifest installs <id>.svg and has a FIXME comment.
  • --arch ARCH: an architecture to build for. Repeatable. Usually only the ghc and cabal-install binaries depend on it.
  • --cabal-install: build all dependencies with cabal-install in one module, haskell-deps (see below).

Each module builds its package with runhaskell Setup build --jobs=$FLATPAK_BUILDER_N_JOBS.

Build the dependencies with cabal-install

By default each dependency is one Flatpak module, and flatpak-builder builds them one after the other. With --cabal-install the dependencies are in one module, and cabal-install builds them in parallel. Your package is built with cabal install.

$ cabal build --dry-run --disable-tests --disable-benchmarks
$ cabal-flatpak generate --cabal-install --dependencies --force

The haskell-deps module stores the build in /app/lib/cabal-store. The stub manifest removes the store and the repository /app/lib/haskell-repo from the final application:

cleanup:
  - /lib/haskell-repo
  - /lib/cabal-store/*/package.db
  - /lib/cabal-store/*/*/lib
  - /lib/cabal-store/*/*/bin

allow-newer and allow-older from cabal.project and cabal.project.local go into the freeze file.

Version bound relaxations inside import: or if are not read yet, you will have to add them by hand.

If one dependency changes, flatpak-builder will rebuild all of them, because they are in one module.

Build the Flatpak package

Install the Flatpak runtime and its SDK:

$ sudo flatpak install org.freedesktop.Platform org.freedesktop.Sdk

Then build:

$ flatpak-builder --force-clean --repo=$FLATPAK/repository --state-dir=$FLATPAK/builder/ $FLATPAK/build/my-package <id>.yaml

Flatpak uses a lot of storage, so you may want $FLATPAK on a separate partition.

  • --repo is your Flatpak repository, where flatpak-builder stores the result. It holds all versions of all your Flatpak packages. Anyone with access to it can install and update them.
  • --state-dir caches all downloads and build artifacts. Projects can share it.
  • The DIRECTORY argument is where Flatpak builds your project. Projects cannot share it. You can delete it after a build. --force-clean deletes it at the start of the next build.

--state-dir and DIRECTORY must be on the same file system.

You can also export one version of your package to a single file, for a one-time install (However, users of the bundle do not get updates).

$ flatpak build-bundle $FLATPAK/repository \
    my-package-0.1.2.flatpak com.my_domain.my-package \
    --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo

Known issues

Cabal revisions

For reproducible builds, every module pins the revision of its Haskell dependency, read from the pkg-revision field of plan.json.

For this reason, cabal-install 3.18.1.0 or later is required.

Dependencies outside Hackage

Only Hackage dependencies are supported for now.

Contributions that add support for source-repository-package, local tarball or remote tarball packages are welcome.

C dependencies

cabal-flatpak does not generate build instructions for C dependencies. Write them yourself. flatpak-builder accepts a path to a module file as an entry of modules.