diff --git a/.gitignore b/.gitignore index 9f3a8fb..0b3cd58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ gcroot result* target/ +/extra-tests/*/alt-store /extra-tests/*/flake.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index eb54954..e88c258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/extra-tests/alt-store/flake.nix b/extra-tests/alt-store/flake.nix new file mode 100644 index 0000000..a71c08e --- /dev/null +++ b/extra-tests/alt-store/flake.nix @@ -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); + }; + }); +} diff --git a/extra-tests/alt-store/test.sh b/extra-tests/alt-store/test.sh new file mode 100755 index 0000000..5704067 --- /dev/null +++ b/extra-tests/alt-store/test.sh @@ -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 diff --git a/extra-tests/test.sh b/extra-tests/test.sh index 8aaacae..3a70ec5 100755 --- a/extra-tests/test.sh +++ b/extra-tests/test.sh @@ -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 diff --git a/lib/mkDummySrc.nix b/lib/mkDummySrc.nix index 39b32fb..510f8a3 100644 --- a/lib/mkDummySrc.nix +++ b/lib/mkDummySrc.nix @@ -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