|
| 1 | +# Flatpak Packaging for Hyprnote |
| 2 | + |
| 3 | +This document describes how to build Hyprnote as a Flatpak and submit it to Flathub. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Hyprnote uses the "build from source" strategy for Flatpak packaging, which is the preferred approach for Flathub. This means the entire application is built inside the Flatpak sandbox using vendored dependencies. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +Install the required tools: |
| 12 | + |
| 13 | +```bash |
| 14 | +# Install Flatpak and flatpak-builder |
| 15 | +sudo apt install flatpak flatpak-builder |
| 16 | + |
| 17 | +# Add Flathub repository |
| 18 | +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo |
| 19 | + |
| 20 | +# Install GNOME runtime and SDK |
| 21 | +flatpak install flathub org.gnome.Platform//47 org.gnome.Sdk//47 |
| 22 | + |
| 23 | +# Install SDK extensions for Rust and Node |
| 24 | +flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 |
| 25 | +flatpak install flathub org.freedesktop.Sdk.Extension.node22//24.08 |
| 26 | +``` |
| 27 | + |
| 28 | +Install the flatpak-builder-tools for generating vendored dependencies: |
| 29 | + |
| 30 | +```bash |
| 31 | +# Clone flatpak-builder-tools |
| 32 | +git clone https://github.com/nickvidal/flatpak-builder-tools.git |
| 33 | + |
| 34 | +# For Node/pnpm dependencies |
| 35 | +pip install aiohttp toml |
| 36 | + |
| 37 | +# For Cargo dependencies |
| 38 | +pip install toml |
| 39 | +``` |
| 40 | + |
| 41 | +## Generating Vendored Dependencies |
| 42 | + |
| 43 | +Before building the Flatpak, you need to generate JSON files containing all vendored dependencies. These files allow the build to proceed offline, which is required by Flathub. |
| 44 | + |
| 45 | +### Generate pnpm dependencies |
| 46 | + |
| 47 | +From the repository root: |
| 48 | + |
| 49 | +```bash |
| 50 | +# Generate pnpm-sources.json |
| 51 | +python3 flatpak-builder-tools/node/flatpak-node-generator.py pnpm \ |
| 52 | + -o apps/desktop/flatpak/pnpm-sources.json \ |
| 53 | + pnpm-lock.yaml |
| 54 | +``` |
| 55 | + |
| 56 | +### Generate Cargo dependencies |
| 57 | + |
| 58 | +From the repository root: |
| 59 | + |
| 60 | +```bash |
| 61 | +# Generate cargo-sources.json |
| 62 | +python3 flatpak-builder-tools/cargo/flatpak-cargo-generator.py \ |
| 63 | + -d Cargo.lock \ |
| 64 | + -o apps/desktop/flatpak/cargo-sources.json |
| 65 | +``` |
| 66 | + |
| 67 | +## Building Locally |
| 68 | + |
| 69 | +Once the vendored dependency files are generated, you can build the Flatpak locally: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Build and install to user Flatpak |
| 73 | +flatpak-builder --user --install --force-clean \ |
| 74 | + flatpak-build-dir \ |
| 75 | + apps/desktop/flatpak/com.hyprnote.Hyprnote.yml |
| 76 | +``` |
| 77 | + |
| 78 | +## Running the Flatpak |
| 79 | + |
| 80 | +After building and installing: |
| 81 | + |
| 82 | +```bash |
| 83 | +flatpak run com.hyprnote.Hyprnote |
| 84 | +``` |
| 85 | + |
| 86 | +## Debugging |
| 87 | + |
| 88 | +To debug inside the Flatpak sandbox: |
| 89 | + |
| 90 | +```bash |
| 91 | +# Open a shell inside the sandbox |
| 92 | +flatpak run --devel --command=sh com.hyprnote.Hyprnote |
| 93 | + |
| 94 | +# Inside the sandbox, you can inspect /app and run the binary directly |
| 95 | +ls /app/bin/ |
| 96 | +/app/bin/hyprnote |
| 97 | +``` |
| 98 | + |
| 99 | +## Flathub Submission |
| 100 | + |
| 101 | +### Preparation Checklist |
| 102 | + |
| 103 | +Before submitting to Flathub, ensure: |
| 104 | + |
| 105 | +- [ ] The manifest builds successfully with `flatpak-builder` |
| 106 | +- [ ] The app runs correctly via `flatpak run com.hyprnote.Hyprnote` |
| 107 | +- [ ] All vendored dependencies are up to date |
| 108 | +- [ ] The metainfo.xml file has valid screenshots and descriptions |
| 109 | +- [ ] The desktop file has correct categories and keywords |
| 110 | + |
| 111 | +### Submission Process |
| 112 | + |
| 113 | +1. Fork the `flathub/flathub` repository on GitHub |
| 114 | + |
| 115 | +2. Clone your fork and checkout the `new-pr` branch: |
| 116 | + ```bash |
| 117 | + git clone --branch=new-pr [email protected]:YOUR_USERNAME/flathub.git |
| 118 | + cd flathub |
| 119 | + ``` |
| 120 | + |
| 121 | +3. Create a new branch for your app: |
| 122 | + ```bash |
| 123 | + git checkout -b com.hyprnote.Hyprnote |
| 124 | + ``` |
| 125 | + |
| 126 | +4. Create the app directory and copy files: |
| 127 | + ```bash |
| 128 | + mkdir com.hyprnote.Hyprnote |
| 129 | + cp /path/to/hyprnote/apps/desktop/flatpak/com.hyprnote.Hyprnote.yml com.hyprnote.Hyprnote/ |
| 130 | + cp /path/to/hyprnote/apps/desktop/flatpak/com.hyprnote.Hyprnote.desktop com.hyprnote.Hyprnote/ |
| 131 | + cp /path/to/hyprnote/apps/desktop/flatpak/com.hyprnote.Hyprnote.metainfo.xml com.hyprnote.Hyprnote/ |
| 132 | + cp /path/to/hyprnote/apps/desktop/flatpak/pnpm-sources.json com.hyprnote.Hyprnote/ |
| 133 | + cp /path/to/hyprnote/apps/desktop/flatpak/cargo-sources.json com.hyprnote.Hyprnote/ |
| 134 | + ``` |
| 135 | + |
| 136 | +5. Update the manifest to use a git source instead of a local directory: |
| 137 | + ```yaml |
| 138 | + sources: |
| 139 | + - type: git |
| 140 | + url: https://github.com/fastrepl/hyprnote.git |
| 141 | + tag: desktop_vX.Y.Z # Use the release tag |
| 142 | + commit: abc123... # Include the commit hash |
| 143 | + ``` |
| 144 | +
|
| 145 | +6. Commit and push: |
| 146 | + ```bash |
| 147 | + git add . |
| 148 | + git commit -m "Add com.hyprnote.Hyprnote" |
| 149 | + git push origin com.hyprnote.Hyprnote |
| 150 | + ``` |
| 151 | + |
| 152 | +7. Open a pull request from your branch to the `new-pr` branch of `flathub/flathub` |
| 153 | + |
| 154 | +8. Respond to review comments from Flathub maintainers |
| 155 | + |
| 156 | +### After Approval |
| 157 | + |
| 158 | +Once approved: |
| 159 | +- Flathub creates a dedicated repository: `flathub/com.hyprnote.Hyprnote` |
| 160 | +- You are invited as a maintainer |
| 161 | +- Future updates are done by pushing to that repository |
| 162 | + |
| 163 | +## Updating the Flatpak |
| 164 | + |
| 165 | +When releasing a new version: |
| 166 | + |
| 167 | +1. Update the version in `com.hyprnote.Hyprnote.metainfo.xml` |
| 168 | +2. Regenerate vendored dependencies if dependencies changed |
| 169 | +3. Update the git source tag/commit in the Flathub manifest |
| 170 | +4. Push changes to the Flathub app repository |
| 171 | + |
| 172 | +## File Structure |
| 173 | + |
| 174 | +``` |
| 175 | +apps/desktop/ |
| 176 | + flatpak/ |
| 177 | + com.hyprnote.Hyprnote.yml # Flatpak manifest |
| 178 | + com.hyprnote.Hyprnote.desktop # Desktop entry file |
| 179 | + com.hyprnote.Hyprnote.metainfo.xml # AppStream metadata |
| 180 | + pnpm-sources.json # Vendored pnpm dependencies (generated) |
| 181 | + cargo-sources.json # Vendored Cargo dependencies (generated) |
| 182 | + src-tauri/ |
| 183 | + tauri.conf.flatpak.json # Tauri config for Flatpak (updater disabled) |
| 184 | +``` |
| 185 | + |
| 186 | +## Permissions |
| 187 | + |
| 188 | +The Flatpak manifest includes the following permissions: |
| 189 | + |
| 190 | +- **Display**: Wayland and X11 fallback for GUI |
| 191 | +- **Audio**: PulseAudio for microphone and speaker capture |
| 192 | +- **Network**: For cloud AI services and calendar sync |
| 193 | +- **Notifications**: For meeting reminders and alerts |
| 194 | +- **System Tray**: For background operation indicator |
| 195 | +- **Filesystem**: Access to Documents and Downloads folders |
| 196 | + |
| 197 | +## Troubleshooting |
| 198 | + |
| 199 | +### Build fails with missing dependencies |
| 200 | + |
| 201 | +Regenerate the vendored dependency files: |
| 202 | +```bash |
| 203 | +python3 flatpak-builder-tools/node/flatpak-node-generator.py pnpm -o apps/desktop/flatpak/pnpm-sources.json pnpm-lock.yaml |
| 204 | +python3 flatpak-builder-tools/cargo/flatpak-cargo-generator.py -d Cargo.lock -o apps/desktop/flatpak/cargo-sources.json |
| 205 | +``` |
| 206 | + |
| 207 | +### Audio not working |
| 208 | + |
| 209 | +Ensure PulseAudio is running on your system. The Flatpak uses `--socket=pulseaudio` for audio access. |
| 210 | + |
| 211 | +### System tray icon not showing |
| 212 | + |
| 213 | +Some desktop environments require additional configuration for StatusNotifier support. The manifest includes `--talk-name=org.kde.StatusNotifierWatcher` for tray icon support. |
| 214 | + |
| 215 | +## References |
| 216 | + |
| 217 | +- [Tauri Flatpak Documentation](https://v2.tauri.app/distribute/flatpak/) |
| 218 | +- [Flathub Documentation](https://docs.flathub.org/) |
| 219 | +- [Flatpak Builder Tools](https://github.com/nickvidal/flatpak-builder-tools) |
| 220 | +- [AppStream Metainfo Guidelines](https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/) |
0 commit comments