Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `mkDummySrc` can now pass the `cleanCargoTomlFilter` argument to `cleanCargoToml`
* `craneLib.filters` exposes `cargoTomlAggressive`, `cargoTomlConservative`, and
`cargoTomlDefault` for composition of custom filters for `cleanCargoToml`
* `doStripVersion`: a new option for `buildDepsOnly`, `buildPackage`,
`buildTrunkPackage`, `cleanCargoToml`, and `mkDummySrc` which strips version
information from workspace crates in the dummy source. This improves cache hit
rates when only the crate version changes but dependencies remain the same.
Comment on lines +14 to +17
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a note for later, the changelog entry will need to move under the Unreleased (after a merge or rebase with master) since there was a new release that went out


## [0.23.0] - 2026-01-13

Expand Down
63 changes: 63 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,69 @@ onlyDrvs (
}
);

# Verify that buildDepsOnly produces the same derivation for different versions
# when doStripVersion is enabled (versions 1.2.3 and 9.8.7 should produce identical deps)
# Note: the crate source is in a subdirectory that has the same name for both versions,
# to avoid name differences triggering a cache miss
stripVersionDepsEquality =
let
depsV1 = myLib.buildDepsOnly {
src = ./stripVersion/sources;
doStripVersion = true;
};
depsV2 = myLib.buildDepsOnly {
src = ./stripVersionAlt/sources;
doStripVersion = true;
};
in
pkgs.runCommand "strip-version-deps-equality-check" { } ''
if [ "${depsV1}" != "${depsV2}" ]; then
echo "ERROR: buildDepsOnly derivations differ despite doStripVersion=true"
echo " stripVersion (1.2.3): ${depsV1}"
echo " stripVersionAlt (9.8.7): ${depsV2}"
exit 1
fi
echo "SUCCESS: buildDepsOnly derivations are identical with doStripVersion=true"
touch $out
'';

# Verify that buildDepsOnly produces DIFFERENT derivations when doStripVersion is disabled
# This ensures the equality check above is meaningful
stripVersionDepsInequality =
let
depsV1 = myLib.buildDepsOnly {
src = ./stripVersion/sources;
doStripVersion = false;
};
depsV2 = myLib.buildDepsOnly {
src = ./stripVersionAlt/sources;
doStripVersion = false;
};
in
pkgs.runCommand "strip-version-deps-inequality-check" { } ''
if [ "${depsV1}" = "${depsV2}" ]; then
echo "ERROR: buildDepsOnly derivations are identical despite doStripVersion=false"
echo " This means the test is not meaningful - versions should differ!"
echo " stripVersion (1.2.3): ${depsV1}"
echo " stripVersionAlt (9.8.7): ${depsV2}"
exit 1
fi
echo "SUCCESS: buildDepsOnly derivations differ with doStripVersion=false (as expected)"
echo " stripVersion (1.2.3): ${depsV1}"
echo " stripVersionAlt (9.8.7): ${depsV2}"
touch $out
'';

compilesFreshSimpleStripVersion = self.compilesFresh "simple" (myLib.cargoBuild) {
src = ./simple;
doStripVersion = true;
};

compilesFreshStripVersion = self.compilesFresh "strip-version-test" (myLib.cargoBuild) {
src = ./stripVersion/sources;
doStripVersion = true;
};
Comment on lines +987 to +990
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is failing. You can iterate on it directly via nix build -L ./test#checks.x86_64-linux.compilesFreshStripVersion, or you can run the entire test suite via ./test.sh


windows = myLibWindows.buildPackage {
strictDeps = true;
pname = "windows";
Expand Down
Loading