Package a Rust Flatpak
This example uses the source and release asset that built Calculator 0.1.1. For your own app, choose the release tag and asset filename before writing the manifest, and keep those values the same through upload.
Create the Cargo archive
Commit Cargo.lock and run these commands from your app checkout with Cargo installed. cargo vendor fetches the locked crates and Git dependencies during preparation. Preserve all generated [source] entries, including the Git entries, and use the relative vendor directory. Merge any Cargo settings your build still needs into this config. Cargo vendor reference
scratch=$(mktemp -d)
archive="$PWD/calculator-cargo-vendor-0.1.1.tar.xz"
mkdir -p "$scratch/calculator-cargo-vendor/.cargo"
cargo vendor --locked --versioned-dirs "$scratch/calculator-cargo-vendor/vendor" \
> "$scratch/vendor-config.toml"
sed 's@^directory = .*@directory = "vendor"@' "$scratch/vendor-config.toml" \
> "$scratch/calculator-cargo-vendor/.cargo/config.toml"
tar -cJf "$archive" -C "$scratch" calculator-cargo-vendor
sha256sum "$archive"
calculator-cargo-vendor/
├── .cargo/
│ └── config.toml
└── vendor/
├── ab_glyph-0.2.32/
├── winit-0.30.13/
└── …
Flatpak extracts the archive after the Git checkout. "strip-components": 1 puts .cargo/config.toml and vendor/ next to Cargo.toml. The example uses the exact asset URL below. Use the SHA-256 of the bytes you upload for your release.
https://github.com/enz1m/calculator/releases/download/v0.1.1/calculator-cargo-vendor-0.1.1.tar.xz
Full Cargo source replacement config for Calculator
[source.crates-io]
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-accesskit.git?rev=7da7ac7b800fabf0bd2ba62eef23fa9117a684f4"]
git = "https://github.com/enz1m/enzim-accesskit.git"
rev = "7da7ac7b800fabf0bd2ba62eef23fa9117a684f4"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-cosmic-text.git?rev=ad474131e52c0fde5979f8def2889489b50a0480"]
git = "https://github.com/enz1m/enzim-cosmic-text.git"
rev = "ad474131e52c0fde5979f8def2889489b50a0480"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-cryoglyph.git?rev=0617a49e7b8a5c5c4cc572a3e98cda70ff1be89f"]
git = "https://github.com/enz1m/enzim-cryoglyph.git"
rev = "0617a49e7b8a5c5c4cc572a3e98cda70ff1be89f"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-iced.git?rev=a6483d7eb2f98bd568dfd4a6d5ab0228ace287d6"]
git = "https://github.com/enz1m/enzim-iced.git"
rev = "a6483d7eb2f98bd568dfd4a6d5ab0228ace287d6"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-wgpu.git?rev=c62972c9be1326882c4b4f1939d8a2713e42d210"]
git = "https://github.com/enz1m/enzim-wgpu.git"
rev = "c62972c9be1326882c4b4f1939d8a2713e42d210"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-winit.git?rev=40eeb41f8637ef1620afa377ba006874224b6d65"]
git = "https://github.com/enz1m/enzim-winit.git"
rev = "40eeb41f8637ef1620afa377ba006874224b6d65"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzim-zbus.git?rev=e182645b56d15e637bb6c8144f99ebfa7f900716"]
git = "https://github.com/enz1m/enzim-zbus.git"
rev = "e182645b56d15e637bb6c8144f99ebfa7f900716"
replace-with = "vendored-sources"
[source."git+https://github.com/enz1m/enzui.git?tag=v0.2.0-alpha.1"]
git = "https://github.com/enz1m/enzui.git"
tag = "v0.2.0-alpha.1"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
Commit the Flatpak manifest
Set the archive URL and the SHA-256 printed above. Use @ENZIM_SOURCE_COMMIT@ for your app's Git source. The store substitutes the commit from the GitHub release you select.
Full Calculator JSON manifest
{
"app-id": "org.enzimos.Calculator",
"branch": "stable",
"runtime": "org.freedesktop.Platform",
"runtime-version": "26.08",
"sdk": "org.freedesktop.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command": "enz-calculator",
"finish-args": [
"--socket=wayland",
"--device=dri"
],
"build-options": {
"append-path": "/usr/lib/sdk/rust-stable/bin"
},
"modules": [
{
"name": "calculator",
"buildsystem": "simple",
"build-commands": [
"cargo build --locked --offline --release --jobs \"${FLATPAK_BUILDER_N_JOBS:-2}\"",
"install -Dm755 target/release/enz-calculator /app/bin/enz-calculator",
"install -Dm644 packaging/flatpak/org.enzimos.Calculator.desktop /app/share/applications/org.enzimos.Calculator.desktop",
"install -Dm644 packaging/flatpak/org.enzimos.Calculator.metainfo.xml /app/share/metainfo/org.enzimos.Calculator.metainfo.xml",
"install -Dm644 assets/calculator.svg /app/share/icons/hicolor/scalable/apps/org.enzimos.Calculator.svg",
"install -Dm644 assets/calculator.png /app/share/icons/hicolor/512x512/apps/org.enzimos.Calculator.png",
"install -Dm644 LICENSE /app/share/licenses/org.enzimos.Calculator/LICENSE",
"install -Dm644 assets/calculator-icon.LICENSE /app/share/licenses/org.enzimos.Calculator/calculator-icon.LICENSE"
],
"sources": [
{
"type": "git",
"url": "https://github.com/enz1m/calculator.git",
"commit": "@ENZIM_SOURCE_COMMIT@",
"disable-submodules": true
},
{
"type": "archive",
"url": "https://github.com/enz1m/calculator/releases/download/v0.1.1/calculator-cargo-vendor-0.1.1.tar.xz",
"sha256": "c8ea22cfa6a0ef69f4a038e8286d995eaa29d120fbcb210d633af05902ee47a3",
"strip-components": 1
},
{
"type": "file",
"url": "https://raw.githubusercontent.com/enz1m/enzim-winit/40eeb41f8637ef1620afa377ba006874224b6d65/wayland-protocols/xdg-session-management-v1.xml",
"sha256": "3674591ca8e68f76297c535e8edd6783d84b59086c38ebe08ff5ff1f2dec5bae",
"dest": "vendor/winit-0.30.13/wayland-protocols"
}
]
}
]
}
When a vendored crate is missing a file
Check what the crate includes in its Cargo package. Calculator's pinned winit fork needs xdg-session-management-v1.xml, which is absent from the vendored crate. Its manifest restores it as a Flatpak file source after the archive. The URL points to the same Git commit as the locked winit dependency, and dest places the XML where winit expects it. When updating that dependency, update the file's commit, SHA-256 and destination together.
Test before creating the release
Use the SDK branch named in the manifest. These commands prepare the runtime and show the Rust tools provided by the Calculator example's SDK extension.
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user flathub org.freedesktop.Platform//26.08 \
org.freedesktop.Sdk//26.08 org.freedesktop.Sdk.Extension.rust-stable//26.08
flatpak run --devel --command=sh org.freedesktop.Sdk//26.08 \
-c '/usr/lib/sdk/rust-stable/bin/rustc --version && /usr/lib/sdk/rust-stable/bin/cargo --version'
The 26.08 SDK extension provided Rust 1.98.0 in this test. Calculator built with it even though its rust-toolchain.toml specified 1.99.1. The manifest puts the SDK's binaries on PATH and invokes Cargo directly. Check the compiler against your app's and dependencies' minimum Rust versions. If the SDK is too old, select a supported runtime branch with a suitable Rust extension or adjust the project's Rust requirements.
With Git, Flatpak Builder and Python 3.11 or newer installed, run this from the app checkout after committing the manifest. Use the local archive you plan to upload. The checker loads the committed manifest at HEAD, checks the local archive's name and SHA-256, then downloads remaining pinned inputs and builds offline in the Flatpak sandbox. It prints the scratch directory for inspection. Flatpak Builder reference
curl -fsS https://flatpak.enzim.dev/enzim-flatpak-check.py -o enzim-flatpak-check.py
python3 enzim-flatpak-check.py --checkout . \
--manifest packaging/flatpak/org.enzimos.Calculator.json \
--asset ./calculator-cargo-vendor-0.1.1.tar.xz
To reproduce this example, check out Calculator commit ab6be75a1281 and download the example asset above. For multiple local inputs, repeat --asset. The checker tests packaging locally. The dashboard runs its own checks after you select the release.
Publish the GitHub release
Publish the release from the commit you tested and attach the same archive bytes under the filename in the manifest. Select that GitHub release in the dashboard and run its Flatpak check.