
I am starting a project that might use ghcjs and it seems to me that if someone's first impression of it is tying stack install and having it take several hours to build everything that is not a very welcoming way to get people to use ghcjs. Why not precompiled binaries? Also while It has been compiling i have seen a lot of warnings? Zach -- Zach Kessin SquareTarget http://squaretarget.rocks?utm_source=email-sig Twitter: @zkessin https://twitter.com/zkessin Skype: zachkessin ᐧ

Zachary, I highly recommend using the nix package manager for GHCJS projects. Nix is very easy to install and uninstall (rm -rf /nix). To install: curl https://nixos.org/nix/install | sh To be put into a shell where ghcjs exists along with a few dependencies, run, nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: with pkgs; [ghcjs-base ghcjs-dom])"
From here the only real framework that exists is reflex-dom. There is actually the reflex-platform project that uses the nix package manager ( https://github.com/reflex-frp/reflex-platform)
- David
On Sun, Oct 30, 2016 at 4:01 AM, Zachary Kessin
I am starting a project that might use ghcjs and it seems to me that if someone's first impression of it is tying stack install and having it take several hours to build everything that is not a very welcoming way to get people to use ghcjs. Why not precompiled binaries?
Also while It has been compiling i have seen a lot of warnings?
Zach
-- Zach Kessin SquareTarget http://squaretarget.rocks?utm_source=email-sig Twitter: @zkessin https://twitter.com/zkessin Skype: zachkessin ᐧ
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Cell: 1.630.740.8204

On 30 Oct 2016, at 21:42, David Johnson
wrote: Zachary,
I highly recommend using the nix package manager for GHCJS projects.
Nix is very easy to install and uninstall (rm -rf /nix).
To install: curl https://nixos.org/nix/install | sh
To be put into a shell where ghcjs exists along with a few dependencies, run, nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: with pkgs; [ghcjs-base ghcjs-dom])”
Unfortunately it is failing with: ``` building path(s) ‘/nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7’ setupCompilerEnvironmentPhase Build with /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0. unpacking sources unpacking source archive /nix/store/86ny46814x0qw0srcgywwgzsz1myhpnn-entropy-0.3.7.tar.gz source root is entropy-0.3.7 setting SOURCE_DATE_EPOCH to timestamp 1434401149 of file entropy-0.3.7/System/EntropyXen.hs patching sources compileBuildDriverPhase setupCompileFlags: -package-db=/tmp/nix-build-entropy-0.3.7.drv-2/package.conf.d -j1 [1 of 1] Compiling Main ( Setup.hs, /tmp/nix-build-entropy-0.3.7.drv-2/Main.o ) Linking Setup ... configuring configureFlags: --verbose --prefix=/nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7 --libdir=$prefix/lib/$compiler --libsubdir=$pkgid --with-gcc=gcc --package-db=/tmp/nix-build-entropy-0.3.7.drv-2/package.conf.d --ghc-option=-opt l=-Wl,-rpath=/nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/lib/ghcjs-0.2.0/entropy-0.3.7 --enable-split-objs --disable-library-profiling --disable-executable-profiling --enable-shared --enable-library-vanilla --enable-executab le-dynamic --disable-tests --with-hsc2hs=/nix/store/mcfx2csfnjsqk83h64jw0w1a4df48rwp-ghc-7.10.3/bin/hsc2hs --ghcjs Configuring entropy-0.3.7... Flags chosen: halvm=False Dependency base >=4.3 && <5: using base-4.8.0.0 Dependency bytestring -any: using bytestring-0.10.6.0 Dependency unix -any: using unix-2.7.1.0 Using Cabal-1.22.5.0 compiled by ghc-7.10 Using compiler: ghcjs-0.2.0 Using install prefix: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7 Binaries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/bin Libraries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/lib/ghcjs-0.2.0/entropy-0.3.7 Private binaries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/libexec Data files installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/share/x86_64-linux-ghcjs-0.2.0-ghc7_10_3/entropy-0.3.7 Documentation installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/share/doc/x86_64-linux-ghcjs-0.2.0-ghc7_10_3/entropy-0.3.7 Configuration files installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/etc No alex found Using ar found on system at: /nix/store/d61gfhj50bfrrlvp4jzdxmsap3izsvyc-binutils-2.27/bin/ar No c2hs found No cpphs found Using gcc version 5.4.0 given by user at: /nix/store/wckiwf1m333akbm3d7pyrj57g3i39367-gcc-wrapper-5.4.0/bin/gcc No ghc found No ghc-pkg found Using ghcjs version 0.2.0 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/ghcjs Using ghcjs-pkg version 7.10.3 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/ghcjs-pkg No greencard found Using haddock version 2.16.1 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/haddock-ghcjs No happy found Using haskell-suite found on system at: haskell-suite-dummy-location Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location No hmake found No hpc found Using hsc2hs version 0.67 given by user at: /nix/store/mcfx2csfnjsqk83h64jw0w1a4df48rwp-ghc-7.10.3/bin/hsc2hs No hscolour found No jhc found Using ld found on system at: /nix/store/wckiwf1m333akbm3d7pyrj57g3i39367-gcc-wrapper-5.4.0/bin/ld No lhc found No lhc-pkg found No pkg-config found Using strip version 2.27 found on system at: /nix/store/d61gfhj50bfrrlvp4jzdxmsap3izsvyc-binutils-2.27/bin/strip Using tar found on system at: /nix/store/p6jsf52izfpgb758xvdcw19byj644iak-gnutar-1.29/bin/tar No uhc found building Setup: Could not determine C compiler builder for ‘/nix/store/8ig44jskrggpnsqmiwjr3y7kz8aib9jj-entropy-0.3.7.drv’ failed with exit code 1 cannot build derivation ‘/nix/store/658g4wwinrpiy4qc23r9rzf0abab6q13-ghcjs-0.2.0.drv’: 1 dependencies couldn't be built error: build of ‘/nix/store/658g4wwinrpiy4qc23r9rzf0abab6q13-ghcjs-0.2.0.drv’ failed /run/current-system/sw/bin/nix-shell: failed to build all dependencies ``` I also tried it with 16.09 which also failed. — aycan

Zachary, The ghcjs-dom package on nixpkgs is pretty badly broken. This is because cabal2nix doesn't generate nix expressions that are sensitive to ghcjs. Therefore, you have to override derivations before you even begin. To do this create the directory ~/.nixpkgs with file config.nix (~/.nixpkgs/config.nix). Then paste the contents of this config.nix [1] into your local file system, then try the previous script again:
nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: with pkgs; [ghcjs-base ghcjs-dom])”
[1] https://gist.github.com/dmjio/380f8d8729f7f81be48ffdddb3fb1de0
Regards,
Dave
On Mon, Oct 31, 2016 at 6:59 AM, Aycan İrican
On 30 Oct 2016, at 21:42, David Johnson
wrote: Zachary,
I highly recommend using the nix package manager for GHCJS projects.
Nix is very easy to install and uninstall (rm -rf /nix).
To install: curl https://nixos.org/nix/install | sh
To be put into a shell where ghcjs exists along with a few dependencies, run, nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: with pkgs; [ghcjs-base ghcjs-dom])”
Unfortunately it is failing with:
``` building path(s) ‘/nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4 q6-entropy-0.3.7’ setupCompilerEnvironmentPhase Build with /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0. unpacking sources unpacking source archive /nix/store/86ny46814x0qw0srcgywwgzsz1myhp nn-entropy-0.3.7.tar.gz source root is entropy-0.3.7 setting SOURCE_DATE_EPOCH to timestamp 1434401149 of file entropy-0.3.7/System/EntropyXen.hs patching sources compileBuildDriverPhase setupCompileFlags: -package-db=/tmp/nix-build-entropy-0.3.7.drv-2/package.conf.d -j1 [1 of 1] Compiling Main ( Setup.hs, /tmp/nix-build-entropy-0.3.7.drv-2/Main.o ) Linking Setup ... configuring configureFlags: --verbose --prefix=/nix/store/ bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7 --libdir=$prefix/lib/$compiler --libsubdir=$pkgid --with-gcc=gcc --package-db=/tmp/nix-build-entropy-0.3.7.drv-2/package.conf.d --ghc-option=-opt l=-Wl,-rpath=/nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4 q6-entropy-0.3.7/lib/ghcjs-0.2.0/entropy-0.3.7 --enable-split-objs --disable-library-profiling --disable-executable-profiling --enable-shared --enable-library-vanilla --enable-executab le-dynamic --disable-tests --with-hsc2hs=/nix/store/ mcfx2csfnjsqk83h64jw0w1a4df48rwp-ghc-7.10.3/bin/hsc2hs --ghcjs Configuring entropy-0.3.7... Flags chosen: halvm=False Dependency base >=4.3 && <5: using base-4.8.0.0 Dependency bytestring -any: using bytestring-0.10.6.0 Dependency unix -any: using unix-2.7.1.0 Using Cabal-1.22.5.0 compiled by ghc-7.10 Using compiler: ghcjs-0.2.0 Using install prefix: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7 Binaries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/bin Libraries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/lib/ghcjs-0. 2.0/entropy-0.3.7 Private binaries installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/libexec Data files installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/share/x86_64- linux-ghcjs-0.2.0-ghc7_10_3/entropy-0.3.7 Documentation installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/share/doc/ x86_64-linux-ghcjs-0.2.0-ghc7_10_3/entropy-0.3.7 Configuration files installed in: /nix/store/bcdkyjdrvx1jmqzkh031h1zz0x3sd4q6-entropy-0.3.7/etc No alex found Using ar found on system at: /nix/store/d61gfhj50bfrrlvp4jzdxmsap3izsvyc-binutils-2.27/bin/ar No c2hs found No cpphs found Using gcc version 5.4.0 given by user at: /nix/store/wckiwf1m333akbm3d7pyrj57g3i39367-gcc-wrapper-5.4.0/bin/gcc No ghc found No ghc-pkg found Using ghcjs version 0.2.0 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/ghcjs Using ghcjs-pkg version 7.10.3 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/ghcjs-pkg No greencard found Using haddock version 2.16.1 found on system at: /nix/store/nxnnsdk5njk6913z017h0hf6v5f3waah-ghcjs-0.2.0/bin/haddock-ghcjs No happy found Using haskell-suite found on system at: haskell-suite-dummy-location Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy- location No hmake found No hpc found Using hsc2hs version 0.67 given by user at: /nix/store/mcfx2csfnjsqk83h64jw0w1a4df48rwp-ghc-7.10.3/bin/hsc2hs No hscolour found No jhc found Using ld found on system at: /nix/store/wckiwf1m333akbm3d7pyrj57g3i39367-gcc-wrapper-5.4.0/bin/ld No lhc found No lhc-pkg found No pkg-config found Using strip version 2.27 found on system at: /nix/store/d61gfhj50bfrrlvp4jzdxmsap3izsvyc-binutils-2.27/bin/strip Using tar found on system at: /nix/store/p6jsf52izfpgb758xvdcw19byj644iak-gnutar-1.29/bin/tar No uhc found building Setup: Could not determine C compiler builder for ‘/nix/store/8ig44jskrggpnsqmiwjr3y7kz8aib9jj-entropy-0.3.7.drv’ failed with exit code 1 cannot build derivation ‘/nix/store/658g4wwinrpiy4qc23r9rzf0abab6q13-ghcjs-0.2.0.drv’: 1 dependencies couldn't be built error: build of ‘/nix/store/658g4wwinrpiy4qc23r9rzf0abab6q13-ghcjs-0.2.0.drv’ failed /run/current-system/sw/bin/nix-shell: failed to build all dependencies ```
I also tried it with 16.09 which also failed.
— aycan
-- Cell: 1.630.740.8204

Hi David,
cabal2nix doesn't generate nix expressions that are sensitive to ghcjs.
the expressions in Nixpkgs target GHC 8.0.x, not GHCJS. If you want cabal2nix to generate expressions for GHCJS instead, then you'll just have to run it with the flag "--compiler=ghcjs". Builds generated by the Nix function haskell.packages.ghcjs.callHackage do this automatically. Best regards, Peter

Hi Peti,
Thanks for chiming in on this, was not aware cabal2nix's ghcjs
functionality. This is great. 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? Or is it better for us to resort
to overriding all ghcjs specific packages on hackage in
"pkgs/development/haskell-modules/configuration-ghcjs.nix" ?
The derivation below is pretty much useless for anyone using GHC (not a
library nor executable, 0 deps specified). I imagine as GHCJS continues to
grow, and hackage contains more 'ghcjs-only' packages, it will become
onerous to continally override in configuration-ghcjs.nix (ghcjs-dom is
also a good example of needing to do this).
```
"ghcjs-dom-jsffi" = callPackage ({ mkDerivation }:
mkDerivation {
pname =
"ghcjs-dom-jsffi";
version = "0.5.0.2";
sha256 = "... some hash
...";
isLibrary = false;
isExecutable = false;
description = "DOM library using JSFFI and GHCJS";
license = stdenv.lib.licenses.mit;
hydraPlatforms =
stdenv.lib.platforms.none;
}) {};
```
Peti, 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)?
Regards,
David
On Tue, Nov 1, 2016 at 2:43 AM, Peter Simons
Hi David,
cabal2nix doesn't generate nix expressions that are sensitive to ghcjs.
the expressions in Nixpkgs target GHC 8.0.x, not GHCJS. If you want cabal2nix to generate expressions for GHCJS instead, then you'll just have to run it with the flag "--compiler=ghcjs". Builds generated by the Nix function haskell.packages.ghcjs.callHackage do this automatically.
Best regards, Peter
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Cell: 1.630.740.8204

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... 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

The culprit is that GHCJS isn't released. This again means that the stack
project doesn't want to support it (yet). This is unfortunate, but the way
things are.
(In addition to GHCJS not being released, I'm guessing that there is no FP
Complete customer using ghcjs yet)
I wouldn't recommend using nix for this, as when you work with ghcjs,
you'll likely need to be on the bleeding edge anyways. I don't see what
issue nix solves in this, but it does add an extra level of complexity.
If you want to use stackage nightly (as lts is a bit stuck at the moment),
I can recommend the following which works for me:
resolver: nightly-2016-10-25
compiler: ghcjs-0.2.1.820161025_ghc-8.0.1
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.1.820161025_ghc-8.0.1:
url:
http://tolysz.org/ghcjs/untested/ghc-8.0-2016-10-25-nightly-2016-10-25-82016...
sha1: ca05f23ab6af89803a9fa8ce7241ebdd2eee7dae
Alexander
On Sun, Oct 30, 2016 at 10:01 AM, Zachary Kessin
I am starting a project that might use ghcjs and it seems to me that if someone's first impression of it is tying stack install and having it take several hours to build everything that is not a very welcoming way to get people to use ghcjs. Why not precompiled binaries?
Also while It has been compiling i have seen a lot of warnings?
Zach
-- Zach Kessin SquareTarget http://squaretarget.rocks?utm_source=email-sig Twitter: @zkessin https://twitter.com/zkessin Skype: zachkessin ᐧ
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (5)
-
Alexander Kjeldaas
-
Aycan İrican
-
David Johnson
-
Peter Simons
-
Zachary Kessin