app-id: com.pocoguy.Muse runtime: org.gnome.Platform runtime-version: "50" sdk: org.gnome.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.node24 command: muse build-options: append-path: /usr/lib/sdk/node24/bin env: NODEJS_DIR: /usr/lib/sdk/node24 FLATPAK_ENABLE_SDK_EXT: node24 build-args: - --share=network finish-args: - --share=ipc - --socket=fallback-x11 - --socket=wayland - --socket=pulseaudio - --share=network - --persist=. - --device=dri - --socket=session-bus - --filesystem=xdg-music - --filesystem=xdg-run/app/com.discordapp.Discord - --filesystem=xdg-run/discord-ipc-0 modules: - name: nodejs-runtime buildsystem: simple build-options: no-debuginfo: true build-commands: - install -Dm755 /usr/lib/sdk/node24/bin/node ${FLATPAK_DEST}/bin/node - cp -ra /usr/lib/sdk/node24/lib ${FLATPAK_DEST}/ || true sources: [] - name: rustypipe-botguard buildsystem: simple build-options: no-debuginfo: true build-commands: # Prefer a vendored tarball supplied as a local `type: file` source # (see `sources` below). Codeberg's edge bot-mitigation systematically # 503s automated clients (curl/wget/flatpak-builder's downloader) even # while a browser downloads fine, so curl --retry can't win, every # attempt is classified the same and shed. The vendored copy makes the # build independent of Codeberg. - | set -eu case "$(uname -m)" in x86_64) triple=x86_64-unknown-linux-gnu; sha=4f2ec561e8f9fadece7deadc6ce0624fbdedd852222c3eb194c22153b1323129 ;; aarch64) triple=aarch64-unknown-linux-gnu; sha=4d038857374a69aea9be8ded981d93a776dc88d4e254f5c6d292746099abf69a ;; *) echo "rustypipe-botguard: unsupported arch $(uname -m)" >&2; exit 1 ;; esac tarball="rustypipe-botguard-v0.1.2-${triple}.tar.xz" if [ -f "$tarball" ]; then cp "$tarball" bg.tar.xz else url="https://codeberg.org/ThetaDev/rustypipe-botguard/releases/download/v0.1.2/${tarball}" if command -v curl >/dev/null 2>&1; then curl -fL --retry 6 --retry-delay 5 --connect-timeout 30 -o bg.tar.xz "$url" else wget -t 6 --waitretry=5 --retry-on-http-error=429,500,502,503,504 -O bg.tar.xz "$url" fi fi echo "${sha} bg.tar.xz" | sha256sum -c - tar -xf bg.tar.xz install -Dm755 rustypipe-botguard ${FLATPAK_DEST}/bin/rustypipe-botguard sources: # Vendored release binaries, extracted into the build dir as # rustypipe-botguard-v0.1.2-.tar.xz so the build-command above # uses them instead of hitting Codeberg. One entry per arch we build: # only-arches picks exactly one, so the other tarball is never staged. - type: file only-arches: - x86_64 path: vendor/rustypipe-botguard/rustypipe-botguard-v0.1.2-x86_64-unknown-linux-gnu.tar.xz sha256: 4f2ec561e8f9fadece7deadc6ce0624fbdedd852222c3eb194c22153b1323129 - type: file only-arches: - aarch64 path: vendor/rustypipe-botguard/rustypipe-botguard-v0.1.2-aarch64-unknown-linux-gnu.tar.xz sha256: 4d038857374a69aea9be8ded981d93a776dc88d4e254f5c6d292746099abf69a - name: python-dependencies buildsystem: simple build-options: no-debuginfo: true build-commands: - pip3 install --prefix=${FLATPAK_DEST} --no-cache-dir -r requirements.txt - pip3 install --prefix=${FLATPAK_DEST} --no-cache-dir --upgrade "yt-dlp[default]" - pip3 install --prefix=${FLATPAK_DEST} --no-cache-dir "yt-dlp-ejs" sources: - type: file path: requirements.txt - name: muse buildsystem: simple build-commands: # Nuitka is not in the GNOME SDK. Install it with pip's flat --target # layout rather than --prefix so nothing has to hardcode the runtime's # python3.X version, and drive it with `python3 -m nuitka` (no console # script on PATH needed). It lands outside ${FLATPAK_DEST}, so the # compiler never ships in the finished app. - pip3 install --no-cache-dir --target=nuitka-tools nuitka - glib-compile-resources --sourcedir=. src/muse.gresource.xml --target=src/muse.gresource # Same flags as the AUR PKGBUILD, minus --clang: the GNOME SDK ships # gcc, and clang only exists behind the org.freedesktop.Sdk.Extension.llvm # SDK extension we do not pull in. This is Nuitka's "accelerated" mode, # not --standalone: the binary still loads gi, yt-dlp and the rest from # /app/lib/python3.X/site-packages that the python-dependencies module # populated, so only our own four modules get compiled. - | set -eu root="$PWD" cd src PYTHONPATH="$root/nuitka-tools:${PYTHONPATH:-}" \ python3 -m nuitka \ --file-reference-choice=runtime \ --include-package=ui \ --include-package=api \ --include-package=player \ --include-module=logger \ --output-filename=muse \ --jobs="$(nproc)" \ --assume-yes-for-downloads \ main.py # This layout is load-bearing, not cosmetic. --file-reference-choice=runtime # makes every compiled module report __file__ as # /. With the # binary at /app/lib/muse/src/muse that gives main.py a __file__ of # /app/lib/muse/src/main.py, which is what makes all three runtime lookups # resolve: dirname(__file__)/muse.gresource, dirname(__file__)/ui/style.css, # and ../assets/icons. Move the binary and every one of them breaks. - install -Dm755 src/muse ${FLATPAK_DEST}/lib/muse/src/muse - install -Dm644 src/muse.gresource ${FLATPAK_DEST}/lib/muse/src/muse.gresource - install -Dm644 src/ui/style.css ${FLATPAK_DEST}/lib/muse/src/ui/style.css - cp -r assets ${FLATPAK_DEST}/lib/muse/ - install -Dm644 com.pocoguy.Muse.desktop ${FLATPAK_DEST}/share/applications/com.pocoguy.Muse.desktop - install -Dm644 com.pocoguy.Muse.metainfo.xml ${FLATPAK_DEST}/share/metainfo/com.pocoguy.Muse.metainfo.xml - install -Dm644 assets/icons/hicolor/scalable/apps/com.pocoguy.Muse.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/com.pocoguy.Muse.svg - install -Dm644 assets/icons/hicolor/symbolic/apps/com.pocoguy.Muse-symbolic.svg ${FLATPAK_DEST}/share/icons/hicolor/symbolic/apps/com.pocoguy.Muse-symbolic.svg - install -d ${FLATPAK_DEST}/bin - | cat > ${FLATPAK_DEST}/bin/muse << 'EOF' #!/bin/sh mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/muse" cd "${XDG_DATA_HOME:-$HOME/.local/share}/muse" exec /app/lib/muse/src/muse "$@" EOF - chmod +x ${FLATPAK_DEST}/bin/muse sources: # Build from the checked-out working tree rather than re-cloning # over HTTPS. Avoids a second download per CI run, dodges # transient GitHub 500s on the Git frontend, and — importantly — # builds the actual SHA that CI was invoked on (PR branches, # workflow_dispatch, etc.) instead of always pulling `main`. - type: dir path: . # Build detritus that has no business inside the sandbox. Without this # a developer checkout copies ~900 MB per build, and src/main.build in # particular is stale Nuitka output from a previous host compile that # must not seed the in-sandbox one. .ccache matters in CI too: the # restored ccache lives in the workspace, so without skipping it we # would copy up to 1 GB of it into the sandbox and let it perturb the # source hash flatpak-builder uses to decide whether to rebuild. skip: - .venv - .git - .ccache - build-dir - .flatpak-builder - src/main.build - type: file path: com.pocoguy.Muse.desktop - type: file path: com.pocoguy.Muse.metainfo.xml