Workstations should pull a signed archive-z2 remote
A raw Flathub mirror and an unsigned folder export both fail the moment you ship a second internal patch. Workstations that install an ad-hoc single-file bundle or pull from an unsigned directory tree have no cryptographic continuity across commits, so the client refuses to authenticate or apply binary deltas when the follow-up build arrives. Keeping later builds installable requires a dedicated signing key paired with a published archive-z2 OSTree repository.
I evaluate an internal Flatpak remote against three strict checks before rolling it out to desktop fleets:
- Repository storage mode: The URL that workstation clients pull from must expose an OSTree repository initialized in
archive-z2mode. - Cryptographic lockstep: Every application commit and the top-level repository summary file must carry signatures generated by the exact GPG key the remote was added with.
- Raw byte transport: NGINX must return all repository paths as unmodified binary streams without on-the-fly compression or text MIME mangling.
Meeting those three criteria dictates a clean architectural split on your infrastructure. A bare repository stays strictly on the build host for local filesystem checkout and post-build inspection, while only the signed archive-z2 copy sits under the web root that NGINX publishes. Because Flatpak's alternative OCI registry backend relies on container image manifests instead of an OSTree archive-z2 tree and summary.sig, this static HTTP layout applies strictly to native OSTree remotes.
Keep a bare repo for checkout and archive-z2 for publish
A bare OSTree repository stores unpacked file objects with intact ownership and executable permissions so the host kernel can perform instant hardlink extractions. Pointing NGINX directly at that directory does not give Flatpak clients a pullable remote. Static HTTP transport requires packed file content and metadata stored as gzip-compressed .filez streams, which eliminates the ability to run direct hardlink checkouts on the host filesystem.
To keep local validation fast without breaking network delivery, initialize two separate repositories on the build host. First, create the local inspection repository in your builder workspace:
mkdir -p /var/lib/flatpak-build/bare-repo
ostree --repo=/var/lib/flatpak-build/bare-repo init --mode=bare
When a build finishes and exports into this working path, you can extract the target branch onto the local disk to audit the compiled binary tree, verify bundled libraries, or run desktop linter checks before any workstation sees the update:
ostree --repo=/var/lib/flatpak-build/bare-repo checkout \
app/com.internal.Viewer/x86_64/stable \
/var/lib/flatpak-build/inspect-tree
Next, initialize the public distribution directory separately. The upstream documentation on hosting a repository specifies that a Flatpak remote served over HTTP is initialized with ostree init --mode=archive-z2 and refreshed with flatpak build-update-repo:
mkdir -p /srv/flatpak/repo
ostree --repo=/srv/flatpak/repo init --mode=archive-z2
Repository Mode Lock-In
OSTree fixes the object storage layout at initialization time. You cannot convert an existing
barerepository in place by editing itsconfigfile to saymode=archive-z2. If you accidentally initialize/srv/flatpak/repoinbaremode, delete the directory and recreate it from scratch.
Once populated, the two trees look visibly different on disk. Running ostree checkout against the bare repository produces a readable application directory tree, whereas /srv/flatpak/repo/objects populates with two-character hexadecimal subdirectories containing .filez payload streams and .commit metadata objects.
Sign commits and the summary with one build-host key
A workstation that registers your remote with a pinned public key will immediately reject a later repository summary that is unsigned or signed by a different key. Developers frequently break internal remotes by signing a hotfix commit with a personal GPG key from their local keyring, or by regenerating the repository summary index without passing a signing flag. Either mistake causes flatpak update to abort with a signature verification error across every client machine.
Generate a dedicated, sign-only GPG key on the build host so repository continuity never depends on an individual administrator's workstation keyring. Use an isolated GPG home directory for the builder service account:
install -d -m 0700 /var/lib/flatpak-build/gnupg
gpg --homedir /var/lib/flatpak-build/gnupg \
--quick-generate-key "Flatpak Build Host <[email protected]>" \
ed25519 sign 0
Retrieve the full fingerprint or long key identifier and export the public portion to a standalone binary key file. You will embed this exported key into the .flatpakrepo definition that workstations import:
gpg --homedir /var/lib/flatpak-build/gnupg --list-secret-keys --keyid-format=long
# Record the 16-character KEYID from the 'sec' line, e.g., 8F4B9A2C1D3E5F70
gpg --homedir /var/lib/flatpak-build/gnupg \
--export 8F4B9A2C1D3E5F70 > /srv/flatpak/build-host.gpg
Automate your post-build wrapper script so that it never runs an export or a summary refresh manually. Hardcode the service account's GPG home directory and key ID into the pipeline variables, and pass --gpg-sign to both flatpak build-export and flatpak build-update-repo:
#!/usr/bin/env bash
set -euo pipefail
GPG_HOME="/var/lib/flatpak-build/gnupg"
KEYID="8F4B9A2C1D3E5F70"
PUBLISH_REPO="/srv/flatpak/repo"
BUILD_DIR="$1"
flatpak build-export \
--gpg-homedir="${GPG_HOME}" \
--gpg-sign="${KEYID}" \
"${PUBLISH_REPO}" "${BUILD_DIR}" stable
flatpak build-update-repo \
--gpg-homedir="${GPG_HOME}" \
--gpg-sign="${KEYID}" \
--generate-static-deltas \
"${PUBLISH_REPO}"
Keeping those two commands paired guarantees that the commit object and the top-level summary.sig file stay in lockstep. You can verify the signature chain on the server at any time by running ostree --repo=/srv/flatpak/repo show app/com.internal.Viewer/x86_64/stable to confirm the GPG signature block matches your KEYID, and by checking that /srv/flatpak/repo/summary.sig updates its modification timestamp alongside /srv/flatpak/repo/summary.
Serve only the archive-z2 tree from NGINX
Default web server MIME types and automatic HTTP compression will corrupt Flatpak pulls even when summary, refs, and objects sit properly signed on disk. Many OSTree object files lack standard file extensions, and archive-z2 payloads are already compressed. If NGINX falls back to a text MIME type or leaves gzip on, the server may alter character sets or double-compress the stream, breaking client checksum validation mid-download.
Configure a dedicated location block or server root in NGINX that maps directly to /srv/flatpak/repo. The base remote URL must expose the summary, refs, and objects directories in the exact layout OSTree wrote them, while forcing binary stream headers:
server {
listen 443 ssl http2;
server_name flatpak.internal.lan;
ssl_certificate /etc/ssl/certs/flatpak.internal.lan.crt;
ssl_certificate_key /etc/ssl/private/flatpak.internal.lan.key;
location /repo/ {
alias /srv/flatpak/repo/;
default_type application/octet-stream;
gzip off;
autoindex off;
sendfile on;
tcp_nopush on;
}
}
Setting default_type application/octet-stream; ensures extensionless metadata files and delta parts travel as raw bytes. Disabling gzip prevents redundant CPU overhead on the host and protects pre-compressed .filez objects from transport mutation, while autoindex off; keeps directory listings unbrowsable while allowing direct path fetches.
Verify Raw Byte Headers
Before configuring any client workstation, test your NGINX endpoint with
curl -I https://flatpak.internal.lan/repo/summaryand a real object path under/repo/objects/. Both requests must return HTTP status200withContent-Type: application/octet-streamand noContent-Encoding: gzipheader.
Publish one patched app and install it on a workstation
To put the entire architecture through a real initial deployment and patch cycle, use the paths and identifiers established above: the local inspection repository at /var/lib/flatpak-build/bare-repo, the NGINX-backed publish tree at /srv/flatpak/repo, the signing key 8F4B9A2C1D3E5F70, and an existing application manifest named com.internal.Viewer.json.
1. Build, inspect, and publish the initial release
On the build host, compile your manifest into a temporary build directory and export it directly into the local bare repository first so you can inspect the unpacked filesystem tree:
flatpak-builder --force-clean /var/lib/flatpak-build/build-dir \
com.internal.Viewer.json
flatpak build-export \
--gpg-homedir=/var/lib/flatpak-build/gnupg \
--gpg-sign=8F4B9A2C1D3E5F70 \
/var/lib/flatpak-build/bare-repo \
/var/lib/flatpak-build/build-dir stable
rm -rf /var/lib/flatpak-build/inspect-tree
ostree --repo=/var/lib/flatpak-build/bare-repo checkout \
app/com.internal.Viewer/x86_64/stable \
/var/lib/flatpak-build/inspect-tree
Once you verify the contents under /var/lib/flatpak-build/inspect-tree/files/bin, transfer the signed commit from your local bare repository into the published archive-z2 repository using ostree pull-local, then sign the public summary file:
ostree --repo=/srv/flatpak/repo pull-local \
/var/lib/flatpak-build/bare-repo \
app/com.internal.Viewer/x86_64/stable
flatpak build-update-repo \
--gpg-homedir=/var/lib/flatpak-build/gnupg \
--gpg-sign=8F4B9A2C1D3E5F70 \
--generate-static-deltas \
/srv/flatpak/repo
Run the NGINX header check immediately after the summary update completes:
curl -I https://flatpak.internal.lan/repo/summary
2. Package the client.flatpakrepo file
Workstations need a single configuration file that pairs the repository URL with your base64-encoded public GPG key. Encode /srv/flatpak/build-host.gpg without line breaks and write /srv/flatpak/repo/internal.flatpakrepo so NGINX serves it right alongside the repository:
B64_KEY=$(base64 -w 0 < /srv/flatpak/build-host.gpg)
cat <<EOF > /srv/flatpak/repo/internal.flatpakrepo
[Flatpak Repo]
Title=Internal Workstation Apps
Url=https://flatpak.internal.lan/repo/
Comment=Signed internal Flatpak builds
Description=Self-hosted archive-z2 repository for internal desktop tools
GPGKey=${B64_KEY}
EOF
3. Install and patch on the workstation
On a target Linux workstation, register the remote and install com.internal.Viewer:
flatpak remote-add --if-not-exists internal-apps \
https://flatpak.internal.lan/repo/internal.flatpakrepo
flatpak install -y internal-apps com.internal.Viewer
Now verify that your pipeline survives the second patch. Back on the build host, apply a code change to your application source, re-run flatpak-builder, and export the updated build directly into /srv/flatpak/repo (or repeat the bare checkout and pull-local sequence) using the same key ID:
flatpak-builder --force-clean /var/lib/flatpak-build/build-dir \
com.internal.Viewer.json
flatpak build-export \
--gpg-homedir=/var/lib/flatpak-build/gnupg \
--gpg-sign=8F4B9A2C1D3E5F70 \
/srv/flatpak/repo \
/var/lib/flatpak-build/build-dir stable
flatpak build-update-repo \
--gpg-homedir=/var/lib/flatpak-build/gnupg \
--gpg-sign=8F4B9A2C1D3E5F70 \
--generate-static-deltas \
/srv/flatpak/repo
Return to the workstation and pull the update:
flatpak update -y com.internal.Viewer
The client fetches the refreshed summary and summary.sig over HTTPS, validates the signature against the pinned 8F4B9A2C1D3E5F70 public key, resolves the new commit hash, downloads only the changed binary delta objects as raw application/octet-stream payloads, and switches the active deployment cleanly without throwing a GPG verification error.