Skip to content

Commit

Permalink
examples: use member wildcard to avoid breaking if crates are renamed (
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov authored and ulucs committed Dec 3, 2024
1 parent 59ba4b1 commit e11db6d
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 5 deletions.
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

0 comments on commit e11db6d

Please sign in to comment.