mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 05:36:09 +03:00
mkDummySrc: fix cleaning to work with Nix store overrides (#448)
* Turns out if a build is invoked with `--store` then the source cleaning filter will observe paths rooted at the alternative store which breaks out previous string handling (and results in incorrectly ignoring files which should be included)
This commit is contained in:
parent
2c89c36bff
commit
418ec86477
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
gcroot
|
||||
result*
|
||||
target/
|
||||
/extra-tests/*/alt-store
|
||||
/extra-tests/*/flake.lock
|
||||
|
@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
* All dependencies (outside of `nixpkgs`) have been dropped from the (main)
|
||||
flake.lock file so they do not pollute downstream projects' lock files.
|
||||
|
||||
### Fixed
|
||||
* `mkDummySrc` now properly handles file cleaning (and file including) when a
|
||||
build is invoked with a `--store ...` override
|
||||
|
||||
## [0.14.3] - 2023-10-17
|
||||
|
||||
### Changed
|
||||
|
18
extra-tests/alt-store/flake.nix
Normal file
18
extra-tests/alt-store/flake.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
inputs = {
|
||||
crane.url = "github:ipetkov/crane";
|
||||
nixpkgs.follows = "crane/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
craneLib = crane.lib.${system};
|
||||
in
|
||||
{
|
||||
# https://github.com/ipetkov/crane/issues/446
|
||||
packages.default = craneLib.buildPackage {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ../../checks/simple);
|
||||
};
|
||||
});
|
||||
}
|
8
extra-tests/alt-store/test.sh
Executable file
8
extra-tests/alt-store/test.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Regression test for https://github.com/ipetkov/crane/issues/446
|
||||
set -eu
|
||||
|
||||
scriptDir=$(dirname "$0")
|
||||
cd "${scriptDir}"
|
||||
|
||||
nix build .#default --override-input crane ../.. --store $(pwd)/alt-store
|
@ -18,6 +18,7 @@ runTest() {
|
||||
scriptPath=$(dirname "$0")
|
||||
cd "${scriptPath}"
|
||||
|
||||
runTest ./alt-store/test.sh
|
||||
runTest ./dummy-does-not-depend-on-flake-source-via-path/test.sh
|
||||
runTest ./dummy-does-not-depend-on-flake-source-via-self/test.sh
|
||||
runTest ./fetch-cargo-git/test.sh
|
||||
|
@ -93,7 +93,7 @@ let
|
||||
then src.origSrc
|
||||
else src;
|
||||
|
||||
uncleanSrcBasePath = (toString origSrc) + "/";
|
||||
uncleanSrcBasePath = builtins.unsafeDiscardStringContext ((toString origSrc) + "/");
|
||||
uncleanFiles = findCargoFiles origSrc;
|
||||
|
||||
cargoTomlsBase = uncleanSrcBasePath;
|
||||
@ -112,7 +112,11 @@ let
|
||||
name = "cleaned-mkDummySrc";
|
||||
filter = path: type:
|
||||
let
|
||||
strippedPath = removePrefix uncleanSrcBasePath path;
|
||||
# using `path` can have weird consequences here with alternative store paths
|
||||
# so we cannot assume `uncleanSrcBasePath` will be a strict prefix. Thus we
|
||||
# chop off anything up to and including its value
|
||||
# https://github.com/ipetkov/crane/issues/446
|
||||
strippedPath = lib.last (lib.splitString uncleanSrcBasePath path);
|
||||
filter = x:
|
||||
if type == "directory" then
|
||||
lib.hasPrefix strippedPath x
|
||||
|
Loading…
Reference in New Issue
Block a user