Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: use member wildcard to avoid breaking if crates are renamed #728

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/quick-start-workspace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[workspace]
resolver = "2"
members = ["my-*", "my-workspace-hack"]
# Note that we define member crates with a wildcard here and NOT with explicit
# paths because the flake.nix is written in a way such that top-level members
# (`my-cli` and `my-server`) are built as different derivations which avoid being
# rebuilt if the other package's sources change.
members = ["crates/*"]

[workspace.package]
version = "0.1.0"
Expand Down
12 changes: 8 additions & 4 deletions examples/quick-start-workspace/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./my-common
./my-workspace-hack
./crates/my-common
./crates/my-workspace-hack
crate
];
};
Expand All @@ -81,15 +81,19 @@
# This allows consumers to only depend on (and build) only what they need.
# Though it is possible to build the entire workspace as a single derivation,
# so this is left up to you on how to organize things
#
# Note that the cargo workspace must define `workspace.members` using wildcards,
# otherwise, omitting a crate (like we do below) will result in errors since
# cargo won't be able to find the sources for all members.
my-cli = craneLib.buildPackage (individualCrateArgs // {
pname = "my-cli";
cargoExtraArgs = "-p my-cli";
src = fileSetForCrate ./my-cli;
src = fileSetForCrate ./crates/my-cli;
});
my-server = craneLib.buildPackage (individualCrateArgs // {
pname = "my-server";
cargoExtraArgs = "-p my-server";
src = fileSetForCrate ./my-server;
src = fileSetForCrate ./crates/my-server;
});
in
{
Expand Down