Skip to content

How to reason through Cargo workspace? #359

Closed
@j-baker

Description

@j-baker

Hi! I've got a Cargo workspace which has two binaries in them, cli and server, as well as a few other crates. Reading the docs, it's not quite clear to me how I should go about configuring this with Crane. At present, I've solved by having two build tasks, like

    cli = craneLib.buildPackage (commonArgs // {
        inherit cargoArtifacts;
        pname = "helcache";
    });
    server = craneLib.buildPackage (commonArgs // {
        inherit cargoArtifacts;
        pname = "server";
    });

but this still pumps out warnings like

trace: warning: crane will use a placeholder value since `name` cannot be found in /nix/store/gjid9c55li2p761pkvq30nbksb7ckpr2-Cargo.toml
to silence this warning consider one of the following:
- setting `pname = "...";` in the derivation arguments explicitly
- setting `package.name = "..."` or `workspace.package.name = "..."` in the root Cargo.toml
- explicitly looking up the values from a different Cargo.toml via 
  `craneLib.crateNameFromCargoToml { cargoToml = ./path/to/Cargo.toml; }`

and each package appears to contain both binaries. This is all to say - how do you envisage people use workspaces?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions