Rust package guidelines

From ArchWiki
Jump to navigation Jump to search
Package creation guidelines

32-bitCLRCrossEclipseElectronFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustVCSWebWine

This document covers standards and guidelines on writing PKGBUILDs for Rust.

General guidelines

Package naming

For Rust binaries use only the program name.

Note: The package name should be entirely lowercase.


Building a Rust package.

 build() {
   cargo build --release --locked


  • --release tells cargo to compile a release build
  • --locked tells cargo to adhere the Cargo.lock file and prevent it from updating dependencies which is important for reproducible builds.


Most Rust projects provide a simple way to run the testsuite.

 check() {
   cargo test --release --locked


Rust builds binaries in target/release and can simply be installed to /usr/bin.

 package() {
   install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"

Some packages should install more files such as a man page, so in that case it would be better to use cargo:

 package() {
   cargo install --root "${pkgdir}"/usr --root "${srcdir}/${pkgname}-${pkgver}"