-
Notifications
You must be signed in to change notification settings - Fork 80
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
Implement a nicer repository interface for nixpkgs #387
Conversation
c2342af
to
9685dd6
Compare
Do we have any thoughts on this? I'm finding it quite useful but if we think it's outside the scope of this repo I can find another place for it. |
Sorry I haven't had a chance to look at this yet. I have pretty much no experience with Hazel. @mrkkrp perhaps you could have a first look? |
I'll take a look tomorrow. |
This looks sensible to me and matches quite well how |
FYI, I recently pushed an improvement to Hazel so that the compiler is wired up correctly on MacOS: https://github.com/FormationAI/hazel/pull/39/files |
9685dd6
to
1699b86
Compare
Trying to get this passing the tests but having trouble running them locally. Running:
gives:
Am I missing something obvious here? |
Works for me locally. It fails with the same lint-related error as on CI. What OS are you on? |
I'm on Ubuntu 16.04 using Nix 2.0.4. Neither |
Update: It works if you follow the nix code examples from the issue. |
I'm going to close this for the time being as I think #442 is a superior working direction (harnessing Nix and thus obviating the need for clever toolchain tricks to try and mitigate custom builds with Hazel). |
Problem
Depending on the end goal, the set of steps required to set up
rules_haskell
with a GHC from nixpkgs (the recommended use case) is a bit involved. At present, after loadingrules_haskell
, one must at least:WORKSPACE
, bring in a GHC from nixpkgs usingnixpkgs_package
(fromrules_nixpkgs
).BUILD
, callhaskell_toolchain
to instantiate a toolchain using the nixpkgs GHC.WORKSPACE
, callregister_toolchain
to register the defined toolchain.This is not that bad and likely comparable to most
rules_language
packages for languages other than those supported natively. However, the situation degenerates when one wants to use packages from Hackage using Hazel. At this point, one must:Tweak the above
nixpkgs_package
call to use Hazel's customBUILD.ghc
file, which adds some exports (and also callshaskell_toolchain
).Currently undocumented but I think required in many, if not all cases -- also pull a version of GCC and some of its libraries from nixpkgs, along with
patchelf
, and use these to ensure that the nixpkgs GHC produces binaries linked against the Nix store and not the host system. This requires using some bits and pieces that are now exported in the Hazel repository (e.g.cc_configure_custom
).Proposal
Even disregarding the possibility that Hazel and
rules_haskell
will be merged at some point, most of the steps taken to get Hazel working are sensible in the context ofrules_haskell
alone. Moreover, I think we could do better to ensure a "pit of success" for the nixpkgs use case if it's the recommended path. Consequently, this PR proposes the following:haskell_nixpkgs_toolchain
macro which is intended to the be the one-stop shop for setting up a nixpkgs-backed GHC/Haskell toolchain. Usage might be as follows:This will bring in GHC,
c2hs
etc. from nixpkgs and perform the necessary GCC/patching dance to make sure that the binaries built are pinned to the Nix store. It will also callhaskell_toolchain
andregister_toolchain
with the correct arguments. The macro'sname
attribute is used to namespace everything so this will create targetsnixpkgs_ghc
,nixpkgs_c2hs
etc. though these can be overridden withkwargs
likeghc_package_name = "ghc"
(which e.g. is hard-coded into older Hazel versions).Pros
haskell_toolchain
is still exported if users want something more bespoke.Cons/not currently done
patchelf
code intorules_nixpkgs
-- does this sound sensible? If not and we want to keeprules_nixpkgs
super barebones I'll pull it back down intorules_haskell
, though I think there could be a use case for it: