This commit is contained in:
Jonas Heinrich 2026-03-10 23:58:45 +01:00
parent 5e4560e89e
commit 9961a31936
7 changed files with 1587 additions and 16 deletions

1472
build-aux/cargo-sources.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "/run/build/next-companion/cargo-vendor"

View file

@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Generate Flatpak source entries for Cargo dependencies from Cargo.lock.
Usage:
python3 build-aux/flatpak-cargo-generator.py [Cargo.lock] \
> build-aux/cargo-sources.json
"""
import json
import sys
try:
import tomllib
except ImportError:
try:
import tomli as tomllib # pip install tomli
except ImportError:
print("Error: requires Python 3.11+ or the 'tomli' package", file=sys.stderr)
sys.exit(1)
CRATES_IO_DL = "https://static.crates.io/crates"
REGISTRY_SOURCE = "registry+https://github.com/rust-lang/crates.io-index"
def main() -> None:
lockfile = sys.argv[1] if len(sys.argv) > 1 else "Cargo.lock"
with open(lockfile, "rb") as f:
lock = tomllib.load(f)
sources = []
for pkg in lock.get("package", []):
name = pkg["name"]
version = pkg["version"]
source = pkg.get("source", "")
checksum = pkg.get("checksum")
# Only vendor packages from crates.io (they have a checksum)
if source == REGISTRY_SOURCE and checksum:
sources.append(
{
"type": "archive",
"archive-type": "tar-gz",
"url": f"{CRATES_IO_DL}/{name}/{version}/download",
"sha256": checksum,
"dest": f"cargo-vendor/{name}-{version}",
}
)
print(json.dumps(sources, indent=2))
if __name__ == "__main__":
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -37,6 +37,10 @@
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = buildDeps;
buildInputs = runtimeDeps;
postInstall = ''
install -Dm644 data/icons/org.nextbike.NextCompanion.png \
$out/share/icons/hicolor/512x512/apps/org.nextbike.NextCompanion.png
'';
};
apps.${system}.default = {

View file

@ -0,0 +1,47 @@
app-id: org.nextbike.NextCompanion
runtime: org.gnome.Platform
runtime-version: '47'
sdk: org.gnome.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.rust-stable
command: next-companion
finish-args:
- --share=network # nextbike API calls
- --share=ipc
- --socket=wayland
- --socket=fallback-x11
- --device=dri # GPU acceleration
build-options:
append-path: /usr/lib/sdk/rust-stable/bin
env:
CARGO_HOME: /run/build/next-companion/cargo-home
RUST_BACKTRACE: '1'
arch:
aarch64:
env:
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-unknown-linux-gnu-gcc
modules:
- name: next-companion
buildsystem: simple
build-commands:
- mkdir -p .cargo
- cp cargo-vendor-config/cargo-vendor-config.toml .cargo/config.toml
- cargo --offline build --release
- |
install -Dm755 \
"target/${CARGO_BUILD_TARGET:+${CARGO_BUILD_TARGET}/}release/next-companion" \
/app/bin/next-companion
- install -Dm644 data/icons/org.nextbike.NextCompanion.png
/app/share/icons/hicolor/512x512/apps/org.nextbike.NextCompanion.png
sources:
- type: dir
path: .
- type: file
path: build-aux/cargo-vendor-config.toml
dest: cargo-vendor-config
dest-filename: cargo-vendor-config.toml
- build-aux/cargo-sources.json

View file

@ -263,12 +263,7 @@ fn build_ui(app: &Application) {
let rent_sheet = Box::builder()
.orientation(Orientation::Vertical)
.spacing(16)
.build();
let rent_sheet_title = Label::builder()
.css_classes(["title-4"])
.label("Rent Bike")
.xalign(0.0)
.spacing(12)
.build();
let rent_form = Box::builder()
.orientation(Orientation::Vertical)
@ -278,7 +273,6 @@ fn build_ui(app: &Application) {
rent_form.append(&rent_err);
rent_form.append(&rent_submit);
rent_form.append(&rent_spinner);
rent_sheet.append(&rent_sheet_title);
rent_sheet.append(&rent_form);
// — Return form —
@ -318,14 +312,8 @@ fn build_ui(app: &Application) {
let ret_sheet = Box::builder()
.orientation(Orientation::Vertical)
.spacing(16)
.spacing(12)
.build();
let ret_sheet_title = Label::builder()
.css_classes(["title-4"])
.label("Return Bike")
.xalign(0.0)
.build();
ret_sheet.append(&ret_sheet_title);
ret_sheet.append(&ret_inner);
// — Shared sheet stack —
@ -335,8 +323,8 @@ fn build_ui(app: &Application) {
let sheet_box = Box::builder()
.orientation(Orientation::Vertical)
.margin_top(8)
.margin_bottom(24)
.margin_top(34)
.margin_bottom(18)
.margin_start(16)
.margin_end(16)
.build();