cargo-pak

Crates.iocargo-pak
lib.rscargo-pak
version0.1.7
sourcesrc
created_at2024-04-02 09:05:10.828709
updated_at2024-08-30 03:47:40.227607
descriptionGenerate manifest and desktop files for flatpak
homepage
repositoryhttps://github.com/toastxc/cargo-pack
max_upload_size
id1193354
size60,284
ToastXC (toastxc)

documentation

README

Cargo-pak

the easiest way to package flatpak files

How-to

Dependencies

You will need

  • Rust stable (as well as cargo and other tools)
  • cargo-pak
  • flatpak-builder
  • mold
rustup update
cargo install cargo-pak
apt-get install flatpak-builder mold

Create a rust application

cargo new hello
cd hello
fn main() {
    println!("hello world!");
}

Create an app config

The file must be named pak.toml!!

This config contains details for both the flatpak manifest and .Desktop file. the following example is for a graphical X11 based application.

app_id="xyz.toastxc.Hello"
app_name= "hello"
# defined in Cargo.toml (release is performant)
profile="release"

# cargo-pack will default to package name in Cargo.toml
# bin="hello-world"

# definitions: https://docs.flatpak.org/en/latest/sandbox-permissions.html
permissions = [
    "--share=network",
    "--socket=x11",
    "--device=dri"
]

# definitions: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
[desktopfile]
terminal= false

If you want to use a CLI, it's a bit more simple. Information such as the app name and version are derived from Cargo.toml

app_id="xyz.toastxc.Hello"

[desktopfile]
terminal= true

Icons

For the .desktop file icon to work you MUST leave a .png in the root of the directory, identical to the bin name. (e.g. hello-world.png) For example

[package]
name = "hello"
version = "0.1.0"
edition = "2021"
hello.png

Even if the file is NOT a png, rename it. This program can convert file types and sizes.

Commands

These commands act in a similar way to docker-compose; they are directory dependant. You must be at the root of your rust project file for this to work

Generate

This command generates a desktopfile and flatpak manifest file based on pak.toml

cargo-pak generate

Build

Builds a flatpak application based on the desktop & manifest file

cargo-pak build

Install

Installs (as root) the flatpak

cargo-pak install

Remove

Removes the flatpak from your system

cargo-pak remove

F.A.Q

Why is my icon not working?

cargo-pak automatically converts and resizes icons, it should work as long as the icon follows these conditions

  • square (exactly 1:1 ratio)
  • in root directory (./) Most file types are supported as well as sizes

Building isn't working!

If you have modified files you may need to run cargo-pak generate again.

Commit count: 20

cargo fmt