on iko/ghcjs-patch-master help sign in
Fix filtering package in root of project (#1041)

When a package is not in a subdirectory, but instead in the root of the project the cleaning of the package source was broken. This might explain why some `cabal.project` file based projects might also see be affected by #1013.

commit39560d445e4d0318f417850c7cb2f60e6f73a8e8 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateMon 15 Feb 2021, 16:37 (6 years ago) parent9aba1e2
2 files changed+22−12
lib/clean-cabal-component.nix+10−3 lib/default.nix+12−9
lib/clean-cabal-component.nix+10−3
@@ -37,9 +37,16 @@ let
3737 then "/"
3838 else ""
3939 ) + normalizeRelativePath path;
40− combinePaths = a: b: if isAbsolutePath b
41− then b
42− else normalizePath (a + "/" + b);
40+ combinePaths = a: b:
41+ if isAbsolutePath b
42+ then b
43+ else normalizePath (
44+ if a == ""
45+ then b
46+ else if b == ""
47+ then a
48+ else a + "/" + b
49+ );
4350 # Like normalizePath but with a trailing / when needed
4451 normalizeDir = dir:
4552 let p = normalizePath dir;
lib/default.nix+12−9
@@ -314,14 +314,17 @@ in {
314314 rootAndSubDir = src: rec {
315315 subDir = src.origSubDir or "";
316316 root =
317− # Use `cleanSourceWith` to make sure the `filter` is still used
318− if src ? origSrc && src ? filter && subDir != ""
319− then haskellLib.cleanSourceWith {
320− name = src.name or "source" + "-root";
321− src = src.origSrc;
322− # Not passing src.origSubDir so that the result points `origSrc`
323− inherit (src) filter;
324− }
325− else src.origSrc or src;
317+ if subDir == ""
318+ then src # if there was no subdir use the original src
319+ else
320+ # Use `cleanSourceWith` to make sure the `filter` is still used
321+ if src ? origSrc && src ? filter
322+ then haskellLib.cleanSourceWith {
323+ name = src.name or "source" + "-root";
324+ src = src.origSrc;
325+ # Not passing src.origSubDir so that the result points `origSrc`
326+ inherit (src) filter;
327+ }
328+ else src.origSrc or src; # If there is a subDir and origSrc (but no filter) use origSrc
326329 };
327330}