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