-
Notifications
You must be signed in to change notification settings - Fork 1
Workaround for cabal trying to build dependencies in nix-shell #8
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
Conversation
Without this PR, after a
And after a
It seems to work right now, but earlier I also encountered a spurious cc error doing this, which I can't reproduce anymore:
Anyways, with this PR, and again with clean caches, it's more reproducible and also a lot faster:
|
This workaround could also be used for cardano-node, which seems to have the same problem: https://github.com/input-output-hk/cardano-node/blob/master/shell.nix#L15-L17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
diff --git a/cabal.project b/cabal.project
index 2b8295a..11e0d0a 100644
--- a/cabal.project
+++ b/cabal.project
@@ -72,6 +72,12 @@ constraints: secp256k1-haskell +recovery
tests: True
+-- =============================================================
+-- WARNING:
+-- Do not add any directive other than source-repository-package
+-- past that point.
+-- =============================================================
+
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
Good job, LGTM!
287f4da
to
0b01f19
Compare
Applied! Edit: |
0b01f19
to
3697298
Compare
For source-repository-package's, cabal tries to build them on its own, even when all dependencies are already provided by Nix. Relevant issues: - haskell/cabal#6049 - IntersectMBO/ouroboros-network#645 - haskell/cabal#5586 (comment) This seems to be a problem even with a cabal that includes haskell/cabal#6917 (see input-output-hk/haskell.nix#720 (comment) for how to test a cabal-install 3.4) The only known workaround is to remove the source-repository-package sections from cabal.project, but this should only be done for cabal when used from a nix-shell, not from cabal without a nix-shell, and not outside the nix-shell. To make this work smoothly, the script `scripts/nix-setup` can be used, which splits the source-repository-package sections into cabal.project.srcs, which is then again included from here (to make the Nix setup still work). Running the script again undoes it.
3697298
to
7773d67
Compare
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)
The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.
To make this work smoothly, the script
scripts/nix-setup
can be used,which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
Note that once the script is ran,
cabal.project
is marked as read-only, and git won't track changes to it (since you wouldn't want to commit the removed source-repository-package sections). To make changes, run the script again first.This is a pretty heavy-handed workaround, but I believe this is the best solution possible without spending huge amounts of time on it. This seemed to work very well in my testing and shouldn't conflict with the non-Nix development workflow or with
nix-build
's.