reflex-frp / reflex-platform

A curated package set and set of tools that let you build Haskell packages so they can run on a variety of platforms. reflex-platform is built on top of the nix package manager.

Home Page:https://reflex-frp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

network-3.1.1.1 and ghcjs

dktr0 opened this issue · comments

Trying to build a GHCJS project (that builds fine with much older version of the reflex platform) with the current head of the stable branch - and it fails with this error when trying to build the network library (which is not a direct dependency of the GHCJS project but is a dependency of a dependency). Thanks for any insight/assistance!

building '/nix/store/4y2kcaqpbhhsg872ik88lf640mgcajqq-network-3.1.1.1.drv'...
setupCompilerEnvironmentPhase
Build with /nix/store/hasdvbzwyy515wzxfn6spa7q3bl1s1yb-ghcjs-8.6.0.1.
unpacking sources
unpacking source archive /nix/store/g9vm4r2crbj31xmval8npcj6x6237g0b-network-3.1.1.1.tar.gz
source root is network-3.1.1.1
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file network-3.1.1.1/tests/Spec.hs
patching sources
applying patch /nix/store/yjk6rhygfyzsjdw78x3jhxyy9m5ay3ay-ghcjs-network.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/Network/Socket.hsc b/Network/Socket.hsc
|index 4edebd4..43ecdb7 100644
|--- a/Network/Socket.hsc
|+++ b/Network/Socket.hsc
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
1 out of 1 hunk ignored
builder for '/nix/store/4y2kcaqpbhhsg872ik88lf640mgcajqq-network-3.1.1.1.drv' failed with exit code 1
cannot build derivation '/nix/store/xf8bzc4qlicvpkg6qhz4f2rzi8b2m86s-ghcjs-8.6.0.1-with-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/xf8bzc4qlicvpkg6qhz4f2rzi8b2m86s-ghcjs-8.6.0.1-with-packages.drv' failed

Update: the patch above refers to a file that no longer exists in recent-ish versions of the network module. When I try to get past this by using direct derivations for any recent (or even not so recent) versions of network (ie. avoiding the patch in reflex-platform), I get errors like this (pretty much the same with all version of network I've tried):

/nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/sh //build/network-3.1.1.1/configure '--with-compiler=ghcjs' '--prefix=/nix/store/n68ly360qsnhfmvjkybvivzv7725k76y-network-3.1.1.1' '--libdir=$prefix/lib/$compiler' '--host=js-unknown-ghcjs' 'CC=/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin/cc'
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration `js-unknown-ghcjs': machine `js-unknown' not recognized
configure: error: /nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/bash //build/network-3.1.1.1/config.sub js-unknown-ghcjs failed
error: builder for '/nix/store/1b1m7x7pm5l1vblnjbkcfyxvc2rm4cak-network-3.1.1.1.drv' failed with exit code 1;
       last 10 log lines:
       > Using strip version 2.31 found on system at:
       > /nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin/strip
       > Using tar found on system at:
       > /nix/store/k6ssslsxmvndgm056k7x4s75390sjfkz-gnutar-1.32/bin/tar
       > No uhc found
       > /nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/sh //build/network-3.1.1.1/configure '--with-compiler=ghcjs' '--prefix=/nix/store/n68ly360qsnhfmvjkybvivzv7725k76y-network-3.1.1.1' '--libdir=$prefix/lib/$compiler' '--host=js-unknown-ghcjs' 'CC=/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin/cc'
       > configure: WARNING: unrecognized options: --with-compiler
       > checking build system type... x86_64-pc-linux-gnu
       > checking host system type... Invalid configuration `js-unknown-ghcjs': machine `js-unknown' not recognized
       > configure: error: /nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/bash //build/network-3.1.1.1/config.sub js-unknown-ghcjs failed
       For full logs, run 'nix log /nix/store/1b1m7x7pm5l1vblnjbkcfyxvc2rm4cak-network-3.1.1.1.drv'.
error: 1 dependencies of derivation '/nix/store/30yxm5j21bl5sn1jpwqxjdndaf92j9rn-ghcjs-8.6.0.1-with-packages.drv' failed to build
commented

Had the same issue and figured it out!

config.sub determines if a host is valid, and upstream only added support in v3.1.2.6 in this commit: haskell/network@cb5362e

The pesky thing is that nix automatically upgrades the autotool files in the preConfigurePhase, so the fix gets overwritten. Patching doesn't help because the patchPhase happens before the configurePhase. Thankfully, there is a bool that governs this behaviour:

    network = (self.callHackageDirect {
      pkg = "network";
      ver = "3.1.2.7";
      sha256 = "sha256-5yueRra6dky5TSU87SUITVxxQ5aFplTL39zGyeTJwpw=";
    } {}).overrideAttrs (prevAttrs: {
      dontUpdateAutotoolsGnuConfigScripts = true;
      nativeBuildInputs = (prevAttrs.nativeBuildInputs or []) ++ [pkgs.autoreconfHook];
      });

While we're here, I enabled autoreconf like instructed in the readme, but this may not be necessary.

This also obsoletes the previous hack introduced in #525