Skip to content

feat: build flatpak from source - #608

Open
yofukashino wants to merge 19 commits into
Kopuz-org:masterfrom
yofukashino:flatpak
Open

feat: build flatpak from source #608
yofukashino wants to merge 19 commits into
Kopuz-org:masterfrom
yofukashino:flatpak

Conversation

@yofukashino

@yofukashino yofukashino commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Updated the flatpak manifest so it builds from source as such is a requirement for flathub AND the current flatpak versions available are broken, so this fixes that too.

Updated the flatpak id from com.temidaradev.kopuz to moe.kopuz.kopuz to comply with flathub requirements for verification.

Also tthere is a script to update the static sources for flatpak builder. To be ran incase Cargo.lock or package-lock.json is updated

Fixes: #609

Sanity Checking

  • I have read and followed the contribution guidelines.
  • My commits follow Kopuz's scoped commit convention and history hygiene
    rules.
  • I have disclosed any AI assistance as required by the AI policy in the
    contribution guidelines, or this pull request did not use AI assistance.
  • I have tested and self-reviewed my changes.

Style and Consistency

  • My changes are consistent with the existing crate boundaries and Dioxus
    style.
  • I ran cargo fmt --all --check or cargo fmt --all as appropriate.
  • I ran cargo clippy --workspace --all-targets -- -D warnings, or
    explained why it could not be run.
  • I kept generated assets, translations, and packaging files in sync when
    this change depends on them.

Testing

  • I ran the smallest relevant verifier for this change.
  • I documented any platform or verifier that I could not run.

Tested on platform(s):

  • x86_64-linux
  • aarch64-linux
  • x86_64-darwin
  • aarch64-darwin
  • Windows
  • Android
  • iOS

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Flatpak packaging flow now uses moe.kopuz.kopuz. It adds generated offline Cargo and pnpm sources, native modules, architecture-specific binaries, and a new application manifest. Build scripts and packaging metadata use the new application ID.

Changes

Flatpak packaging

Layer / File(s) Summary
Source manifest generation
packaging/flatpak/generate-sources.sh
The script generates Cargo, pnpm, Dioxus CLI, and rusty_v8 source manifests.
Offline dependency sources
packaging/flatpak/cargo-sources.json, packaging/flatpak/pnpm-sources.json, packaging/flatpak/native-modules.json, packaging/flatpak/dioxus-cli.json, packaging/flatpak/librusty.json
The manifests provide vendored Rust crates, npm packages, xdotool, yt-dlp, Dioxus CLI archives, and rusty_v8 archives.
Kopuz application manifest
packaging/flatpak/moe.kopuz.kopuz.json
The manifest defines the runtime, permissions, offline build settings, installation steps, and pinned sources.
Build and packaging identity integration
packaging/flatpak/build-flatpak.sh, .github/workflows/release.yml, Justfile, README.md, data/*, docs/*, packaging/aur/*, packaging/nix/crane.nix
Build commands, desktop metadata, installation paths, release packaging, and documentation use moe.kopuz.kopuz.

Sequence Diagram(s)

sequenceDiagram
  participant BuildScript
  participant FlatpakManifest
  participant OfflineSources
  BuildScript->>FlatpakManifest: Build moe.kopuz.kopuz
  FlatpakManifest->>OfflineSources: Resolve Cargo, pnpm, CLI, native, and rusty_v8 sources
  OfflineSources-->>FlatpakManifest: Provide verified archives and metadata
  FlatpakManifest-->>BuildScript: Produce the Flatpak bundle
Loading

Possibly related PRs

Suggested reviewers: temidaradev

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Most changes support Flatpak source packaging, but unrelated Malayalam documentation formatting and log-table edits are included. Remove the unrelated formatting and log-table changes from docs/README-ML.md, or explain why they are required for this Flatpak change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: building the Flatpak from source.
Description check ✅ Passed The description explains the source build, Flatpak ID rename, source generation script, linked issue, and testing scope.
Linked Issues check ✅ Passed The new source-based manifest and bundled native modules address the invalid interpreter and missing libxdo.so.4 reported in issue #609.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
packaging/flatpak/generate-sources.sh (1)

12-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider cleaning up the temporary workdir and pinning tool versions.

WORKDIR is created with mktemp -d but never removed, and pip install pipx, pipx install git+..., and pip install flatpak-cargo-generator all install unpinned, latest versions of third-party tooling. This does not break functionality, but it leaves stray temp directories behind and makes source regeneration less reproducible across runs.

♻️ Suggested WORKDIR cleanup
 WORKDIR="$(mktemp -d -t kopuz-flatpak-XXXXXX)"
+trap 'rm -rf "$WORKDIR"' EXIT
 
 cd "$WORKDIR"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packaging/flatpak/generate-sources.sh` around lines 12 - 27, Update the setup
flow in generate-sources.sh to register cleanup for WORKDIR on exit, and pin
explicit versions for pipx, flatpak-builder-tools, and flatpak-cargo-generator
in their respective installation commands. Preserve the existing virtualenv
activation and source-generation behavior while making repeated runs clean and
reproducible.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packaging/flatpak/dioxus-cli.json`:
- Around line 1-16: Update both archive URLs in the Flatpak manifest to pin
Dioxus CLI version v0.7.9, matching the vendored crates and the release
workflow’s cargo install dioxus-cli@0.7.9 contract. Recalculate and replace each
corresponding sha256 checksum for the v0.7.9 x86_64 and aarch64 archives,
leaving architecture mappings unchanged.

In `@packaging/flatpak/generate-sources.sh`:
- Around line 57-92: Add a validation step in generate-sources.sh after
generating or copying the source manifests that compares the v8 crate version in
cargo-sources.json with the pinned rusty_v8 version recorded in librusty.json,
and fail with a clear error when they differ. Keep the existing pinned-source
workflow intact while ensuring future Cargo.lock updates cannot silently leave
the manifests out of sync.
- Around line 31-55: Update the release lookup in the source-generation script
so it fetches the pinned Dioxus CLI version 0.7.9, matching the version used by
the CI cargo install command and Cargo.lock, instead of resolving the GitHub
“latest” release. Preserve the existing architecture-specific asset selection,
URL extraction, digest handling, and JSON generation.

In `@packaging/flatpak/librusty.json`:
- Around line 1-16: Update the aarch64 file entry in the manifest, identified by
its aarch64 URL and only-arches value, to use SHA-256 checksum
beefe7b35abee77159f7cb55096666b07630c11047d5f3a74dd065863729915a; leave the
x86_64 checksum unchanged.

In `@packaging/flatpak/moe.kopuz.kopuz.json`:
- Around line 55-60: Update the Flatpak manifest’s desktop, metainfo, and icon
install destinations to use the moe.kopuz.kopuz IDs, and update the
corresponding source desktop and metainfo declarations and filenames to match.
Ensure all installed artifacts use moe.kopuz.kopuz.desktop,
moe.kopuz.kopuz.metainfo.xml, and moe.kopuz.kopuz.png consistently with the
manifest app-id.
- Around line 7-10: Update the Flatpak build-options configuration to match the
declared org.freedesktop.Sdk.Extension.node24 extension: change append-path to
/usr/lib/sdk/node24/bin and set npm_config_nodedir to /usr/lib/sdk/node24,
replacing the node22 references.

---

Nitpick comments:
In `@packaging/flatpak/generate-sources.sh`:
- Around line 12-27: Update the setup flow in generate-sources.sh to register
cleanup for WORKDIR on exit, and pin explicit versions for pipx,
flatpak-builder-tools, and flatpak-cargo-generator in their respective
installation commands. Preserve the existing virtualenv activation and
source-generation behavior while making repeated runs clean and reproducible.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 21bff765-11e9-420b-ad75-4849bceddbb7

📥 Commits

Reviewing files that changed from the base of the PR and between 354ac3d and 579a526.

📒 Files selected for processing (9)
  • packaging/flatpak/build-flatpak.sh
  • packaging/flatpak/cargo-sources.json
  • packaging/flatpak/com.temidaradev.kopuz.json
  • packaging/flatpak/dioxus-cli.json
  • packaging/flatpak/generate-sources.sh
  • packaging/flatpak/librusty.json
  • packaging/flatpak/moe.kopuz.kopuz.json
  • packaging/flatpak/native-modules.json
  • packaging/flatpak/pnpm-sources.json
💤 Files with no reviewable changes (1)
  • packaging/flatpak/com.temidaradev.kopuz.json

Comment thread packaging/flatpak/dioxus-cli.json
Comment thread packaging/flatpak/generate-sources.sh Outdated
Comment thread packaging/flatpak/generate-sources.sh Outdated
Comment on lines +1 to +16
[
{
"type": "file",
"url": "https://github.com/denoland/rusty_v8/releases/download/v130.0.7/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
"sha256": "a6476cb94e9b0247081c465424eb793d77732b8db80848132d78cbb50f34b75d",
"dest-filename": "librusty.a.gz",
"only-arches": ["x86_64"]
},
{
"type": "file",
"url": "https://github.com/denoland/rusty_v8/releases/download/v130.0.7/librusty_v8_release_aarch64-unknown-linux-gnu.a.gz",
"sha256": "a6476cb94e9b0247081c465424eb793d77732b8db80848132d78cbb50f34b75d",
"dest-filename": "librusty.a.gz",
"only-arches": ["aarch64"]
}
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Confirm the correct sha256 for both rusty_v8 v130.0.7 release archives.

curl -sL "https://github.com/denoland/rusty_v8/releases/download/v130.0.7/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz" | sha256sum
curl -sL "https://github.com/denoland/rusty_v8/releases/download/v130.0.7/librusty_v8_release_aarch64-unknown-linux-gnu.a.gz" | sha256sum

Repository: Kopuz-org/kopuz

Length of output: 289


Fix the aarch64 archive checksum.

The x86_64 and aarch64 downloadable files are different, but the manifest currently assigns them the same SHA-256 value. Set the aarch64 entry to beefe7b35abee77159f7cb55096666b07630c11047d5f3a74dd065863729915a so flatpak-builder can verify the archived library file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packaging/flatpak/librusty.json` around lines 1 - 16, Update the aarch64 file
entry in the manifest, identified by its aarch64 URL and only-arches value, to
use SHA-256 checksum
beefe7b35abee77159f7cb55096666b07630c11047d5f3a74dd065863729915a; leave the
x86_64 checksum unchanged.

Comment thread packaging/flatpak/moe.kopuz.kopuz.json
Comment thread packaging/flatpak/moe.kopuz.kopuz.json Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packaging/flatpak/generate-sources.sh`:
- Around line 31-55: Update the source-generation flow around the commented
Dioxus release-generation block and the later dioxus-cli.json copy so it does
not attempt to copy a file absent from WORKDIR; either restore generation of the
pinned manifest or remove that copy and preserve the checked-in
packaging/flatpak/dioxus-cli.json unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e468486d-2e33-4765-942b-dc5c3f9e9f84

📥 Commits

Reviewing files that changed from the base of the PR and between 579a526 and 4fed8fa.

📒 Files selected for processing (2)
  • packaging/flatpak/dioxus-cli.json
  • packaging/flatpak/generate-sources.sh

Comment thread packaging/flatpak/generate-sources.sh Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packaging/aur/PKGBUILD`:
- Around line 37-43: Update the pinned archive source and corresponding
sha256sums in packaging/aur/PKGBUILD and packaging/aur/PKGBUILD-bin so both use
an artifact containing the current desktop files, logo.png, and
moe.kopuz.kopuz.metainfo.xml; keep the existing install references in both
package scripts unchanged.

In `@packaging/flatpak/generate-sources.sh`:
- Line 74: Quote the workflow path argument in the grep invocation within the
Dioxus release URL construction, preserving the existing version extraction
pattern while ensuring CUR_DIR values containing spaces are passed as a single
file path.

In `@packaging/nix/crane.nix`:
- Around line 154-155: Update the install source and destination references in
packaging/nix/crane.nix lines 154-155, packaging/aur/PKGBUILD lines 45-46, and
packaging/aur/PKGBUILD-bin lines 45-46 to use moe.kopuz.kopuz.xml consistently
instead of the nonexistent .metainfo.xml filename.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f846cfb7-f53f-431f-9c9b-f31aa8baaa7f

📥 Commits

Reviewing files that changed from the base of the PR and between 970d12c and 2ec1096.

📒 Files selected for processing (14)
  • .github/workflows/release.yml
  • Justfile
  • README.md
  • data/moe.kopuz.kopuz.desktop
  • data/moe.kopuz.kopuz.xml
  • docs/README-ML.md
  • docs/README-PT-PT.md
  • docs/README-TR.md
  • packaging/aur/PKGBUILD
  • packaging/aur/PKGBUILD-bin
  • packaging/flatpak/generate-sources.sh
  • packaging/flatpak/librusty.json
  • packaging/flatpak/moe.kopuz.kopuz.json
  • packaging/nix/crane.nix
🚧 Files skipped from review as they are similar to previous changes (2)
  • packaging/flatpak/moe.kopuz.kopuz.json
  • packaging/flatpak/librusty.json

Comment thread packaging/aur/PKGBUILD
Comment thread packaging/flatpak/generate-sources.sh Outdated
"librusty.json"

make_asset_source \
"https://api.github.com/repos/DioxusLabs/dioxus/releases/tags/v$(grep -oPm1 'cargo install dioxus-cli@\K[0-9]+([\.\d]+)' $CUR_DIR/.github/workflows/release.yml)" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Quote the release workflow path.

If CUR_DIR contains spaces, shell word splitting makes grep read invalid path arguments. The version extraction then fails and the script requests an invalid Dioxus release tag.

Proposed fix
-"https://api.github.com/repos/DioxusLabs/dioxus/releases/tags/v$(grep -oPm1 'cargo install dioxus-cli@\K[0-9]+([\.\d]+)' $CUR_DIR/.github/workflows/release.yml)" \
+"https://api.github.com/repos/DioxusLabs/dioxus/releases/tags/v$(grep -oPm1 'cargo install dioxus-cli@\K[0-9]+([\.\d]+)' "$CUR_DIR/.github/workflows/release.yml")" \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"https://api.github.com/repos/DioxusLabs/dioxus/releases/tags/v$(grep -oPm1 'cargo install dioxus-cli@\K[0-9]+([\.\d]+)' $CUR_DIR/.github/workflows/release.yml)" \
"https://api.github.com/repos/DioxusLabs/dioxus/releases/tags/v$(grep -oPm1 'cargo install dioxus-cli@\K[0-9]+([\.\d]+)' "$CUR_DIR/.github/workflows/release.yml")" \
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 74-74: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packaging/flatpak/generate-sources.sh` at line 74, Quote the workflow path
argument in the grep invocation within the Dioxus release URL construction,
preserving the existing version extraction pattern while ensuring CUR_DIR values
containing spaces are passed as a single file path.

Source: Linters/SAST tools

Comment thread packaging/nix/crane.nix
@temidaradev

Copy link
Copy Markdown
Member

Uhh you can add this to kopuz-flatpal repo maybe

@yofukashino

Copy link
Copy Markdown
Contributor Author

Uhh you can add this to kopuz-flatpal repo maybe

maybe add the repo as a sub module here later then? So the files stay in sync

@yofukashino yofukashino mentioned this pull request Aug 7, 2026
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Flatpak package ships a binary with an invalid ELF interpreter

2 participants