Skip to content

Fix filtering package in root of project #1041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2021
Merged
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
13 changes: 10 additions & 3 deletions lib/clean-cabal-component.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ let
then "/"
else ""
) + normalizeRelativePath path;
combinePaths = a: b: if isAbsolutePath b
then b
else normalizePath (a + "/" + b);
combinePaths = a: b:
if isAbsolutePath b
then b
else normalizePath (
if a == ""
then b
else if b == ""
then a
else a + "/" + b
);
# Like normalizePath but with a trailing / when needed
normalizeDir = dir:
let p = normalizePath dir;
Expand Down
21 changes: 12 additions & 9 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,17 @@ in {
rootAndSubDir = src: rec {
subDir = src.origSubDir or "";
root =
# Use `cleanSourceWith` to make sure the `filter` is still used
if src ? origSrc && src ? filter && subDir != ""
then haskellLib.cleanSourceWith {
name = src.name or "source" + "-root";
src = src.origSrc;
# Not passing src.origSubDir so that the result points `origSrc`
inherit (src) filter;
}
else src.origSrc or src;
if subDir == ""
then src # if there was no subdir use the original src
else
# Use `cleanSourceWith` to make sure the `filter` is still used
if src ? origSrc && src ? filter
then haskellLib.cleanSourceWith {
name = src.name or "source" + "-root";
src = src.origSrc;
# Not passing src.origSubDir so that the result points `origSrc`
inherit (src) filter;
}
else src.origSrc or src; # If there is a subDir and origSrc (but no filter) use origSrc
};
}