summaryrefslogtreecommitdiff
path: root/doc/contributing.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/contributing.texi')
-rw-r--r--doc/contributing.texi100
1 files changed, 72 insertions, 28 deletions
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 6d3f1622f30..c801ba5950a 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1635,34 +1635,78 @@ dashes and prepend the prefix @code{java-}. So the class
1635@subsection Rust Crates 1635@subsection Rust Crates
1636 1636
1637@cindex rust 1637@cindex rust
1638Rust programs standing for themselves are named as any other package, using the 1638Rust applications (binary crates) and libraries (library crates) are packaged
1639lowercase upstream name. 1639separately. We put our main efforts into applications and only package
1640 1640libraries as sources, utilizing automation with a manual focus on unbundling
1641To prevent namespace collisions we prefix all other Rust packages with the 1641vendored dependencies.
1642@code{rust-} prefix. The name should be changed to lowercase as appropriate and 1642
1643dashes should remain in place. 1643Rust applications are treated like any other package and named using the
1644 1644lowercase upstream name. When using the Cargo build system (@pxref{Build
1645In the rust ecosystem it is common for multiple incompatible versions of a 1645Systems, @code{cargo-build-system}}), Rust applications should have the
1646package to be used at any given time, so all package definitions should have a 1646@code{#:install-source?} parameter set to @code{#f}, as this parameter only
1647versioned suffix. The versioned suffix is the left-most non-zero digit (and 1647makes sense for libraries. When the package source is a Cargo workspace,
1648any leading zeros, of course). This follows the ``caret'' version scheme 1648@code{#:cargo-install-paths} must be set to enable relevant support.
1649intended by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}. 1649
1650 1650Rust libraries are hidden from the user interface and managed in two modules:
1651Because of the difficulty in reusing rust packages as pre-compiled inputs for 1651
1652other packages the Cargo build system (@pxref{Build Systems, 1652@table @code
1653@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and 1653@item (gnu packages rust-crates)
1654@code{cargo-development-inputs} keywords as build system arguments. It would be 1654Source definitions imported from Rust packages' @file{Cargo.lock} via the
1655helpful to think of these as similar to @code{propagated-inputs} and 1655@code{crate} importer (@pxref{Invoking guix import}).
1656@code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies} 1656
1657should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in 1657Imported definitions must be checked and have vendored dependencies unbundled
1658@code{#:cargo-development-inputs}. If a Rust package links to other libraries 1658before being contributed to Guix.
1659then the standard placement in @code{inputs} and the like should be used. 1659
1660 1660@item (gnu packages rust-sources)
1661Care should be taken to ensure the correct version of dependencies are used; to 1661More complex definitions that need to be full packages. This includes Rust
1662this end we try to refrain from skipping the tests or using @code{#:skip-build?} 1662libraries requiring external inputs to unbundle and Cargo workspaces.
1663when possible. Of course this is not always possible, as the package may be 1663
1664developed for a different Operating System, depend on features from the Nightly 1664These libraries should have the @code{#:skip-build?} parameter set to @code{#t}.
1665Rust compiler, or the test suite may have atrophied since it was released. 1665For Cargo workspaces, @code{#:cargo-package-crates} must be set.
1666
1667Since they are added manually, they follow the usual naming convention for Guix
1668packages (@pxref{Package Naming}), with a @code{rust-} prefix.
1669
1670In the Rust community it is common for multiple incompatible versions of a
1671package to be used at any given time, so all libraries should have a versioned
1672suffix. The versioned suffix is the left-most non-zero digit (and any leading
1673zeros, of course). This follows the ``caret'' version scheme intended by Cargo.
1674Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
1675
1676In practice we often package development snapshots of Rust libraries and can't
1677simply identify them by version. In this case, the complete version information
1678can be turned into a version string via @code{git-version}, for example
1679@code{rust-pipewire-0.8.0.fd3d8f7} and @code{rust-pubgrub-0.3.0.b70cf70}.
1680@end table
1681
1682To avoid merge conflicts with changes from multiple branches, these two modules
1683are maintained by the Rust team (@pxref{Teams}).
1684
1685Rust libraries are not referenced directly. @code{(guix build-sytem cargo)}
1686provides a @code{cargo-inputs} procedure to lookup input lists generated by the
1687lockfile importer.
1688
1689@cindex cargo inputs
1690@findex define-cargo-inputs
1691@findex lookup-cargo-inputs
1692@deffn {Procedure} cargo-inputs name [#:module '(gnu packages rust-crates)]
1693Lookup Cargo inputs for @var{name} in @var{module}, return an empty list if
1694unavailable.
1695
1696@var{name} must be consistent with the one used in lockfile importer invocation,
1697usually matching the variable name of the package:
1698
1699@example
1700$ guix import -i @file{gnu/packages/rust-crates.scm} crate -f @file{/path/to/Cargo.lock} @var{name}
1701@end example
1702
1703@var{module} must export a public interface @code{lookup-cargo-inputs}, a
1704template is available in the @file{etc/teams/rust} directory of Guix source
1705tree.
1706@end deffn
1707
1708@xref{Packaging Rust Crates,,, guix-cookbook, GNU Guix Cookbook}, for
1709packaging workflow.
1666 1710
1667 1711
1668@node Elm Packages 1712@node Elm Packages