-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Nix shell does not provide Alex, Happy to Cabal-Install #176887
Comments
cc @NixOS/haskell I was able to reproduce this locally as well. It seems unfortunate that cabal-install doesn't know to take build-tools from Nix, although I guess it makes sense that it wouldn't know this. I feel like I've seen that another work-around for this is to use Here's one more issue that looks related: input-output-hk/haskell.nix#839 |
Duplicate of #130556 |
Thanks for looking into this! I'd be interested to know what the pros and cons are of using v1-build in a Nix shell sandbox (does it try to build its own happy/alex or just get less picky about using Nix's, does it try to use a global package DB or still use the nix-provided one, etc.). We're up to a few different workarounds, as another mentioned in some of these issues is to make the project dependent on Nix and simply remove the tools from the .cabal file, instead putting them in default.nix explicitly so they're provided but Cabal doesn't think it needs to be picky about them. So we have that, use of v1-, and nix-shell'ing the main derivation directly and then calling the phases rather than using cabal at all. Looking over the issues, I also see a couple different proposals around fixing things. One is to add it to the package-db, if that even works for executables (though it's not really "correct" for them even if it works). Another is theoretically adding a new package-db equivalent for executables and then teaching Nix to use that. And another is input-output-hk/haskell.nix#839 (comment) though I don't understand that explanation very well (.conf files?). This could also be affected in the future if Setup.hs goes away, a la haskell/cabal#7906 – I also wonder how that would impact use of a tool like BNFC, the discussion seems centered on integration of other package managers like Rust's. |
v2 insists that executables it needs are in the package db (so it can do constraint checking), while v1 is happy if a correctly named executable is in in PATH.
However, putting something in the package db also allows linking against the package’s library, meaning we can no longer separate build (»native«) and runtime dependencies which is a correctness issue in the case of cross compiling.
Not that you do need to use the v1 /sandbox/ nor build anything yourself.
… On 9. Jun 2022, at 03:12, Scott Santucci ***@***.***> wrote:
Thanks for looking into this!
I'd be interested to know what the pros and cons are of using v1-build in a Nix shell sandbox (does it try to build its own happy/alex or just get less picky about using Nix's, does it try to use a global package DB or still use the nix-provided one, etc.).
We're up to a few different workarounds, as another mentioned in some of these issues is to make the project dependent on Nix and simply remove the tools from the .cabal file, instead putting them in default.nix explicitly so they're provided but Cabal doesn't think it needs to be picky about them. So we have that, use of v1-, and nix-shell'ing the main derivation directly and then calling the phases rather than using cabal at all.
Looking over the issues, I also see a couple different proposals around fixing things. One is to add it to the package-db, if that even works for executables (though it's not really "correct" for them even if it works). Another is theoretically adding a new package-db equivalent for executables and then teaching Nix to use that. And another is input-output-hk/haskell.nix#839 (comment) though I don't understand that explanation very well (.conf files?).
This could also be affected in the future if Setup.hs goes away, a la haskell/cabal#7906 – I also wonder how that would impact use of a tool like BNFC, the discussion seems centered on integration of other package managers like Rust's.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are on a team that was mentioned.
|
Mmm, and based on a little experiment, So using |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-use-flake-inputs-instead-of-a-cabal-project/25110/2 |
@cdepillabout There's an upstream issue for it and the maintainers are open to PR's adding support: |
I've collected GitHub issues relating to this problem here: https://gist.github.com/ScottFreeCode/ef9f254e2dd91544bba4a068852fc81f |
Describe the bug
I have a Haskell package using
callCabal2nix
, withbuild-tool-depends
onalex
andhappy
. If Inix-shell
straight into mydefault.nix
and use the phase hooks, including the less commonly knowncompileBuildDriverPhase
, I can build the project in a Nix shell environment. However, if I use a shell.nix that addscabal-install
and uses.env
then I get an error fromcabal build
claiming it can't find/buildhappy
(and the phase hooks aren't there).Upstream issue: haskell/cabal#7197 (comment)
While my minimal example uses
callCabal2nix
, the same issue also affects IOG's haskell.nix (where.shellFor
is equivalent to.env
and is needed tonix-shell
at all unless you want to specify individual components fornix-shell
with-A tmp.components.exes.tmp
): input-output-hk/haskell.nix#798Steps To Reproduce
tmp.cabal:
default.nix:
shell.nix:
How to get the error:
nix-shell
cabal build
output
Expected behavior
Cabal builds the project locally.
Screenshots
N/A
Additional context
If you do the following, you bypass the issue:
app/Main.hs:
nix-shell default.nix
(i.e. don't use .env)eval "$compileBuildDriverPhase"
eval "$configurePhase"
eval "$buildPhase"
Program is built to: dist/build/tmp/tmp
The way that nix-build does it (and which avoiding .env allows you to do by explicitly evaling the hooks) uses Setup.hs instead of the cabal executable. The default Setup.hs it uses appears to be:
It looks like it prefers a local Setup.hs, even though I don't have custom build type set, so that's… interesting and potentially an incorrectly handled edge case?
Notify maintainers
@cdepillabout
Metadata
The text was updated successfully, but these errors were encountered: