Crates.io | cargo-pak |
lib.rs | cargo-pak |
version | 0.1.3 |
source | src |
created_at | 2024-04-02 09:05:10.828709 |
updated_at | 2024-06-25 10:14:38.776057 |
description | Generate manifest and desktop files for flatpak |
homepage | |
repository | https://github.com/toastxc/cargo-pack |
max_upload_size | |
id | 1193354 |
size | 53,512 |
the easiest way to package flatpak files
You will need
rustup update
cargo install cargo-pak
apt-get install flatpak-builder mold
cargo new hello
cd hello
fn main() {
println!("hello world!");
}
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
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.
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
This command generates a desktopfile and flatpak manifest file based on pak.toml
cargo-pak generate
Builds a flatpak application based on the desktop & manifest file
cargo-pak build
Installs (as root) the flatpak
cargo-pak install
Removes the flatpak from your system
cargo-pak remove
cargo-pak automatically converts and resizes icons, it should work as long as the icon follows these conditions
If you have modified files you may need to run cargo-pak generate
again.