Skip to content

Commit 39560d4

Browse files
authored
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.
1 parent 9aba1e2 commit 39560d4

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

lib/clean-cabal-component.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)