Expose conditional modules (hard-coded) #2211
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a (dirty) workaround for an issue introduced by #2183, which effectively breaks Haskell project builds depending on packages re-exporting some of
base
s modules.Technical description
The
dummy-ghc-pkg-dump
generated bylib/call-cabal-project-to-nix.nix
describes GHC packages, most notably their dependencies, exposed modules and so on so forth. But it seems that the modules that are re-exported or conditionally exported (e.g., only exported when the target architecture is JavaScript, or exported when the target platform is Windows, or anything but Windows) are ignored. This can be problematic as some packages (e.g., our fork ofbase-noprelude
) export some or all ofbase
s modules, including the ones described earlier (e.g., the conditionalGHC.Event
here or the re-exportedGHC.Num.Natural
here). Becausedummy-ghc-pkg-dump
doesn't export those modules, attempt to build projects based on said packages will fail, with a failure similar to the following:Solution
This PR does not propose a long term fix. It's just a quick workaround for us to continue using haskell.nix, by including re-exported and conditional modules for very specific conditions. This is neither robust nor exhaustive. I've only focused on the cases we need.
Unfortunately, I don't see how to implement a more long term and exhaustive solution without actually interpreting the JSON condition to determine whether the modules should be included in the build or not. Perhaps a sister-executable to
cabal2json
?To reproduce
To reproduce:
base
's modules (e.g.,base-noprelude
).Also, please note that the build succeeds at point 7 only for commits preceeding 98830ce, which is #2203. It seems that this PR introduced another issue, but it's out of scope of this PR 🙂
Is this issue already known? Is there already a fix in the works? I can set up a repo with a sample code if required, I haven't done so neither have I worked further on a long term solution in case the issue is known and already fixed.
Thank you for your help 🙂