Building binaries
Single binary crates
If your Cargo.nix
was generated for a single binary crate (i.e. workspace)
then the derivation that builds your binary can be accessed via the
rootCrate.build
attribute. Use this command to build it and make the result
available in the result directory:
Within a nix file (e.g. your manually written default.nix
), you can access the
derivation like this:
Cargo workspaces with multiple crates
If your Cargo.nix
was generated for a workspace (i.e. not a single binary)
then the derivation that builds your binary CANNOT be accessed via the
rootCrate
attribute. There is no single root crate.
Instead, you can conveniently access the derivations of all your workspace
members through the workspaceMembers
attribute. Use this command to build one
of the workspace members and make the result available in the result directory:
Within a nix file (e.g. your manually written default.nix
), you can access the
derivation like this: