[Haskell-cafe] GHCJS Bad first impression

Peter Simons simons at nospf.cryp.to
Wed Nov 2 06:42:40 UTC 2016


Hi David,

 > There are some packages in haskellPackages (ghcjs-dom-jsffi) that are
 > really only meant to be used with ghcjs. In this case would it be
 > appropriate to somehow detect this, and use the "--compiler=ghcjs"
 > flag during generation?

the tricky part is to somehow detect this. :-) If we'd know that a
certain package targets ghcjs only, then we could generate the
instructions specifically for that compiler. That would make our users
lives much easier, because more builds would work out of the box. I'm
just not sure how to detect this property. Also, this heuristic would
not help with building packages that target both ghc and ghcjs, i.e. by
using conditional logic in the Cabal file.

 > is there a way we could generate two derivations (w/ and w/o the
 > --ghcjs flag) and conditionally select the one we want based on the
 > compiler (meaning ghcjs vs. latest ghc)?

Nix is powerful enough to make those distinctions, and for a while I
considered extending the generator to generate expressions that capture
all the conditional logic found in Cabal:

  https://github.com/NixOS/cabal2nix/blob/master/doc/03-map-cabal-files-to-nix-without-information-loss.md

In the end, I didn't bother though because the callHackage function
solves this problem by generating build expressions that fit the
environment of the function, i.e.

  haskell.packages.ghc704.callHackage "hsdns" "1.6.1" {}

gives you a build that targets GHC version 7.0.4 and

  haskell.packages.ghcjs.callHackage "hsdns" "1.6.1" {}

gives you a build that targets GHCJS. callHackage accomplishes that by
generating the Nix expressions during the time of evaluation and then
importing the generated expression from the Nix store. Unfortunately,
this import-from-derivation feature raises a several design issues for
Nix that no-one has been able to answer satisfactorily yet:

  https://github.com/NixOS/nix/issues/954

Most importantly, it's unclear how to make that feature interact with
Hydra, which runs Nix in its "restricted mode" that disables IFD.

Best regards,
Peter



More information about the Haskell-Cafe mailing list