Skip to content

build: refactor Flatpak packaging to use online builds and force X11 …#339

Open
rainxchzed wants to merge 2 commits intomainfrom
flatpak-pr
Open

build: refactor Flatpak packaging to use online builds and force X11 …#339
rainxchzed wants to merge 2 commits intomainfrom
flatpak-pr

Conversation

@rainxchzed
Copy link
Member

@rainxchzed rainxchzed commented Mar 20, 2026

…backend

  • Enable network access during the Flatpak build process to allow Gradle to download dependencies directly.
  • Remove pre-downloaded Gradle distribution and the offline flatpak-sources.json dependency list.
  • Switch the build command from packageReleaseUberJarForCurrentOS to packageUberJarForCurrentOS to avoid ProGuard duplicate jar conflicts.
  • Force GDK_BACKEND=x11 in the launch script to improve reliability for Skiko/Compose on Wayland environments.
  • Enhance disable-android-for-flatpak.sh to more aggressively strip Android-specific configuration blocks (androidMain, debugImplementation) across all project modules.
  • Refactor the RoomConventionPlugin within the Flatpak build logic to remove Android-specific KSP dependencies.
  • Update the Flatpak manifest to point to the latest commit for version 1.6.2.

Summary by CodeRabbit

  • New Features

    • Added explicit X11 fallback support for Flatpak on systems with both Wayland and X11 display servers.
    • Introduced new database persistence configuration system.
  • Chores

    • Enhanced Flatpak build workflow by enabling network-based dependency resolution instead of offline mode.
    • Simplified build configuration by removing offline restrictions and pre-generated artifacts.

…backend

- Enable network access during the Flatpak build process to allow Gradle to download dependencies directly.
- Remove pre-downloaded Gradle distribution and the offline `flatpak-sources.json` dependency list.
- Switch the build command from `packageReleaseUberJarForCurrentOS` to `packageUberJarForCurrentOS` to avoid ProGuard duplicate jar conflicts.
- Force `GDK_BACKEND=x11` in the launch script to improve reliability for Skiko/Compose on Wayland environments.
- Enhance `disable-android-for-flatpak.sh` to more aggressively strip Android-specific configuration blocks (`androidMain`, `debugImplementation`) across all project modules.
- Refactor the `RoomConventionPlugin` within the Flatpak build logic to remove Android-specific KSP dependencies.
- Update the Flatpak manifest to point to the latest commit for version 1.6.2.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

Walkthrough

This PR enhances Flatpak packaging for GitHub-Store by expanding Android removal logic in build scripts, forcing X11 backend for GTK compatibility, allowing network access during builds, and updating Gradle task references and dependency pinning in the Flatpak manifest.

Changes

Cohort / File(s) Summary
Android Removal Enhancements
packaging/flatpak/disable-android-for-flatpak.sh
Refactored module Gradle patching from hardcoded per-folder lists to repo-wide find command, extended block-stripping to remove android { }, androidMain.dependencies { }, and androidMain { } blocks, added pre-scan optimization to skip when no Android patterns exist, and incremented progress counters.
Room Convention Plugin
build-logic/convention/src/main/kotlin/RoomConventionPlugin.kt
New convention plugin applying com.google.devtools.ksp and androidx.room, configuring Room schema directory and wiring dependencies via commonMainApi and kspJvm without Android targets.
GTK/GDK Rendering Backend
packaging/flatpak/githubstore.sh
Added GDK_BACKEND=x11 environment variable export to force X11 backend invocation before JRE startup.
Flatpak Build Configuration
packaging/flatpak/zed.rainxch.githubstore.yml
Updated finish-args with --socket=fallback-x11 for X11 fallback support, added build-args: [--share=network] to allow dependency fetching, removed --offline Gradle flag, changed task from packageReleaseUberJarForCurrentOS to packageUberJarForCurrentOS, removed pre-downloaded Gradle ZIP and dependency manifest, and pinned Git source to tag: 1.6.2 with explicit commit.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 In Flatpak lands where Android roams,
We tear down walls and claim new homes,
X11 rails and networks flow,
Room conventions steal the show,
Build scripts dance with newfound grace!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main changes: refactoring Flatpak packaging to enable online builds (removing offline mode) and forcing X11 backend support, which are the primary objectives of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch flatpak-pr
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packaging/flatpak/disable-android-for-flatpak.sh (1)

256-285: Avoid forking RoomConventionPlugin.kt inside this patch script.

These lines create a second full copy of build-logic/convention/src/main/kotlin/RoomConventionPlugin.kt. Any later Room convention change will land in normal builds but be silently skipped by Flatpak builds. Prefer a targeted edit that removes only the Android-specific KSP wiring, like the smaller patches above.

Based on learnings: Use convention plugins from build-logic/convention/ for module setup: convention.kmp.library, convention.cmp.library, convention.cmp.feature, convention.cmp.application, convention.room, convention.buildkonfig

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packaging/flatpak/disable-android-for-flatpak.sh` around lines 256 - 285,
This patch currently forks RoomConventionPlugin by writing a full duplicate file
(creating RoomConventionPlugin.kt) which will diverge from
build-logic/convention; instead, change the script to perform a targeted edit on
the existing RoomConventionPlugin in build-logic/convention: remove only the
Android/KSP-specific wiring — i.e., delete or conditionalize the
apply("com.google.devtools.ksp") call and the
"kspJvm"(libs.findLibrary("androidx-room-compiler").get()) dependency while
keeping the RoomExtension.schemaDirectory and commonMainApi lines intact — so
that you do not create a second copy and Flatpak builds reuse the canonical
RoomConventionPlugin implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packaging/flatpak/githubstore.sh`:
- Around line 11-13: The script currently force-sets GDK_BACKEND to x11; change
it to only default to x11 when GDK_BACKEND is not already defined so
Wayland-only users can override it. Locate the export of GDK_BACKEND (symbol:
GDK_BACKEND) and modify the assignment to use the existing environment value if
present (i.e., leave GDK_BACKEND alone when set, otherwise set it to x11) so the
manifest's Wayland socket access can be used when desired.

In `@packaging/flatpak/zed.rainxch.githubstore.yml`:
- Around line 52-60: Remove the sed replacement that rewrites distributionUrl to
gradle-bin.zip in the build-commands (the line that runs sed on
gradle/wrapper/gradle-wrapper.properties); since --share=network is enabled the
wrapper should download the distribution from the original URL, so delete or
comment out that sed invocation and keep the remaining build-commands (including
disable-android-for-flatpak.sh and ./gradlew
:composeApp:packageUberJarForCurrentOS) intact.

---

Nitpick comments:
In `@packaging/flatpak/disable-android-for-flatpak.sh`:
- Around line 256-285: This patch currently forks RoomConventionPlugin by
writing a full duplicate file (creating RoomConventionPlugin.kt) which will
diverge from build-logic/convention; instead, change the script to perform a
targeted edit on the existing RoomConventionPlugin in build-logic/convention:
remove only the Android/KSP-specific wiring — i.e., delete or conditionalize the
apply("com.google.devtools.ksp") call and the
"kspJvm"(libs.findLibrary("androidx-room-compiler").get()) dependency while
keeping the RoomExtension.schemaDirectory and commonMainApi lines intact — so
that you do not create a second copy and Flatpak builds reuse the canonical
RoomConventionPlugin implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91ef71f0-d5fd-4ccd-b1bf-aec2f23aa629

📥 Commits

Reviewing files that changed from the base of the PR and between cc768fa and c2bfddd.

📒 Files selected for processing (4)
  • packaging/flatpak/disable-android-for-flatpak.sh
  • packaging/flatpak/flatpak-sources.json
  • packaging/flatpak/githubstore.sh
  • packaging/flatpak/zed.rainxch.githubstore.yml

Comment on lines +11 to +13
# Force X11 (via XWayland on Wayland) — Skiko/Compose doesn't yet
# reliably support native Wayland drawing surfaces with JBR.
export GDK_BACKEND=x11
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and read the relevant section
fd -t f "githubstore.sh" packaging/flatpak/ 2>/dev/null && \
  echo "=== File content (lines 1-20) ===" && \
  head -20 packaging/flatpak/githubstore.sh

Repository: OpenHub-Store/GitHub-Store

Length of output: 851


🏁 Script executed:

# Also check for the manifest file mentioned
find packaging/flatpak -type f -name "*.json" -o -name "*manifest*" -o -name "*.yml" | head -10

Repository: OpenHub-Store/GitHub-Store

Length of output: 154


🏁 Script executed:

# Look for all relevant shell scripts in the flatpak directory
ls -la packaging/flatpak/

Repository: OpenHub-Store/GitHub-Store

Length of output: 656


🏁 Script executed:

cat packaging/flatpak/zed.rainxch.githubstore.yml

Repository: OpenHub-Store/GitHub-Store

Length of output: 3463


Allow GDK_BACKEND to be overridden for Wayland-only sessions.

Line 13 hard-codes GDK_BACKEND=x11, preventing users on Wayland-only systems without XWayland from overriding it when the app fails to start. The manifest already grants Wayland socket access. While defaulting to X11 is reasonable due to current Skiko/Compose limitations, allow environment override so Wayland-only users can attempt workarounds.

Suggested change
-export GDK_BACKEND=x11
+export GDK_BACKEND="${GDK_BACKEND:-x11}"
📝 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
# Force X11 (via XWayland on Wayland) — Skiko/Compose doesn't yet
# reliably support native Wayland drawing surfaces with JBR.
export GDK_BACKEND=x11
# Force X11 (via XWayland on Wayland) — Skiko/Compose doesn't yet
# reliably support native Wayland drawing surfaces with JBR.
export GDK_BACKEND="${GDK_BACKEND:-x11}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packaging/flatpak/githubstore.sh` around lines 11 - 13, The script currently
force-sets GDK_BACKEND to x11; change it to only default to x11 when GDK_BACKEND
is not already defined so Wayland-only users can override it. Locate the export
of GDK_BACKEND (symbol: GDK_BACKEND) and modify the assignment to use the
existing environment value if present (i.e., leave GDK_BACKEND alone when set,
otherwise set it to x11) so the manifest's Wayland socket access can be used
when desired.

Comment on lines +52 to +60
build-args:
- --share=network
build-commands:
# Use local Gradle distribution (no network in sandbox)
- sed -i 's|distributionUrl=.*|distributionUrl=gradle-bin.zip|' gradle/wrapper/gradle-wrapper.properties
# Disable Android targets (no Android SDK in Flatpak sandbox)
- bash packaging/flatpak/disable-android-for-flatpak.sh
# Build uber JAR
- ./gradlew :composeApp:packageReleaseUberJarForCurrentOS
# Build uber JAR (using non-release to avoid ProGuard duplicate jar conflicts)
- ./gradlew :composeApp:packageUberJarForCurrentOS
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Confirm the manifest still rewrites the wrapper to a local ZIP.
sed -n '52,60p' packaging/flatpak/zed.rainxch.githubstore.yml

echo
# Show the wrapper URL that exists in the repository before the Flatpak patch runs.
grep -n 'distributionUrl' gradle/wrapper/gradle-wrapper.properties

echo
# If this prints nothing, the manifest is forcing a local ZIP that is no longer staged.
find . -name 'gradle-bin.zip' -print

Repository: OpenHub-Store/GitHub-Store

Length of output: 663


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check if the disable-android-for-flatpak.sh script exists
ls -la packaging/flatpak/disable-android-for-flatpak.sh

echo "---"

# Check the full sources section of the githubstore module in the manifest
# to see if gradle-bin.zip is referenced anywhere
sed -n '40,75p' packaging/flatpak/zed.rainxch.githubstore.yml

Repository: OpenHub-Store/GitHub-Store

Length of output: 1842


Remove the sed command that forces a non-existent local Gradle distribution.

Line 56 rewrites distributionUrl to gradle-bin.zip, but this file is not staged in the manifest. With --share=network enabled, Gradle should fetch the distribution from the internet using the original URL in gradle/wrapper/gradle-wrapper.properties. The current sed command causes the build to fail immediately.

Suggested fix
-      # Use local Gradle distribution (no network in sandbox)
-      - sed -i 's|distributionUrl=.*|distributionUrl=gradle-bin.zip|' gradle/wrapper/gradle-wrapper.properties
+      # Keep the repository's wrapper URL so Gradle can fetch its own distribution
📝 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
build-args:
- --share=network
build-commands:
# Use local Gradle distribution (no network in sandbox)
- sed -i 's|distributionUrl=.*|distributionUrl=gradle-bin.zip|' gradle/wrapper/gradle-wrapper.properties
# Disable Android targets (no Android SDK in Flatpak sandbox)
- bash packaging/flatpak/disable-android-for-flatpak.sh
# Build uber JAR
- ./gradlew :composeApp:packageReleaseUberJarForCurrentOS
# Build uber JAR (using non-release to avoid ProGuard duplicate jar conflicts)
- ./gradlew :composeApp:packageUberJarForCurrentOS
build-args:
- --share=network
build-commands:
# Keep the repository's wrapper URL so Gradle can fetch its own distribution
# Disable Android targets (no Android SDK in Flatpak sandbox)
- bash packaging/flatpak/disable-android-for-flatpak.sh
# Build uber JAR (using non-release to avoid ProGuard duplicate jar conflicts)
- ./gradlew :composeApp:packageUberJarForCurrentOS
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packaging/flatpak/zed.rainxch.githubstore.yml` around lines 52 - 60, Remove
the sed replacement that rewrites distributionUrl to gradle-bin.zip in the
build-commands (the line that runs sed on
gradle/wrapper/gradle-wrapper.properties); since --share=network is enabled the
wrapper should download the distribution from the original URL, so delete or
comment out that sed invocation and keep the remaining build-commands (including
disable-android-for-flatpak.sh and ./gradlew
:composeApp:packageUberJarForCurrentOS) intact.

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.

1 participant