infinisil/all-hies

Switch to haskell.nix

infinisil opened this issue · 18 comments

Another really neat thing might be to try get a static build going with https://github.com/nh2/static-haskell-nix, not sure how well that's compatible with haskell.nix though

The advantage of this is that there's no more long-ass stack2nix step to generate the Nix files. However the disadvantage is that it takes about twice as long (2 seconds for a single HIE version in comparison to 1 second with stack2nix) to instantiate the derivation.

I tried to build hie ghc-8.6.5 using stack-to-nix. It failed with

Error:
    The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
installed package ghc-8.6.5 is broken due to missing package terminfo-0.4.1.2

I suspect there's a broken package upstream.

What are the consequences of using a haskell.nix compiled HIE with a nixpkgs provisioned haskell development shell (and vice-versa)? Will it all just work as long as the GHC version numbers are the same?

Seems to work fine

This seems to work (in the hie directory)
https://gist.github.com/4ebbfeb4f951641c81a4c89683d8d385

There is a concerning bug when using hie-bios (and hence hie itself) when compiled with haskell.nix: input-output-hk/haskell.nix#553

The short is: any TH which uses the types returned by reify is likely to be broken.

See #52 (comment), where I explained why haskell.nix probably won't work for all-hies after all. I guess I should just close this.

Hm, on the other hand, maybe the best solution is to just use haskell.nix and drop support for GHC versions it doesn't support.

I've started looking further into haskell.nix, fixing some problems along the way to make it go smoothly, see haskell/haskell-ide-engine#1770 and input-output-hk/nix-tools#90.

It also looks like haskell.nix now supports almost all versions that HIE supports (the only two versions it doesn't are 8.4.2 and 8.4.3, which I'd be totally fine with dropping support for)

I'll continue working on this, seems very promising.

So the haskell.nix branch is here, and GHC 8.6.5 and 8.8.3 build just fine (e.g. with nix-build -A builds.ghc865), but the other versions not so much. E.g. 8.8.2 doesn't build because of input-output-hk/haskell.nix#481. I wouldn't mind some help with that. If I can't get it working I'll just have to drop support for other versions, which would make this more of a "some-hies" than "all-hies" :/

I've tried to build HIE with support of ghc865 and ghc883 on haskell.nix branch

nix-env -iA selection --arg selector 'p: { inherit (p) ghc865 ghc883; }' -f https://github.com/infinisil/all-hies/tarball/haskell.nix --show-trace

and got this error

replacing old 'haskell-ide-engine-combined'
installing 'haskell-ide-engine-combined-1.4'
building '/nix/store/9yfhcam96hg0aywim2lnv1bd831svs9j-source.drv'...
building '/nix/store/ja1z9gb7jbcwhixxzj3zvwa24d5vlh32-ghc-8.4.4-x86_64-deb8-linux.tar.xz.drv'...

trying https://github.com/haskell/haskell-ide-engine/tarball/1.4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0   1104      0 --:--:-- --:--:-- --:--:--  1095

trying https://haskell.org/ghc/dist/8.4.4/ghc-8.4.4-x86_64-deb8-linux.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   359  100   359    0     0    330      0  0:00:01  0:00:01 --:--:--   330
100  791k    0  791k    0     0   577k      0 --:--:--  0:00:01 --:--:-- 1946k
unpacking source archive /tmp/nix-build-source.drv-0/1.4
do not know how to unpack source archive /tmp/nix-build-source.drv-0/1.4
builder for '/nix/store/9yfhcam96hg0aywim2lnv1bd831svs9j-source.drv' failed with exit code 1
cannot build derivation '/nix/store/7373mb270dhy8vshiqamb4v9mjrawdb4-haskell-ide-engine-patched.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/q1w025zayjvijw0rgmkspkca4wprv0aj-stack-repos.drv': 1 dependencies couldn't be built
error: while evaluating 'assertValidity' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:247:20, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:278:18:
while evaluating 'checkValidity' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:228:19, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:248:18:
while evaluating 'hasDeniedUnfreeLicense' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:64:28, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:229:8:
while evaluating 'hasLicense' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:35:16, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/pkgs/stdenv/generic/check-meta.nix:66:5:
while evaluating the attribute 'packages.hie' at /nix/store/axzy3h695csaq9b99kzj5x2h89arj1y1-haskell.nix/build.nix:106:11:
while evaluating the attribute 'hsPkgs.haskell-ide-engine.components.exes' at /nix/store/4p74s0h0z1w3bpm7z3qqwi33rkds73vv-source/overlays/haskell.nix:494:42:
while evaluating the attribute 'hsPkgs' at undefined position:
while evaluatingnonymous function at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:84:45, called from undefined position:
while evaluating the attribute 'value' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:379:9:
while evaluating the option `hsPkgs':
while evaluating the attribute 'mergedValue' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:411:5:
while evaluating the attribute 'values' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:405:9:
while evaluating the attribute 'values' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:505:7:
while evaluating anonymous function at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:391:28, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:391:17:
while evaluating 'dischargeProperties' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:464:25, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:392:62:
while evaluating the attribute 'value' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:277:44:
while evaluating the attribute 'packages' at undefined position:
while evaluating anonymous function at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:84:45, called from undefined position:
while evaluating the attribute 'value' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:379:9:
while evaluating the option `packages':
while evaluating the attribute 'mergedValue' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:411:5:
while evaluating the attribute 'values' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:405:9:
while evaluating the attribute 'values' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:505:7:
while evaluating anonymous function at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:391:28, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:391:17:
while evaluating 'dischargeProperties' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:464:25, called from /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:392:62:
while evaluating the attribute 'value' at /nix/store/rkamf4cwqf8hbzr3sd7sq3x4qdzs6m3j-nixpkgs/lib/modules.nix:277:44:
while evaluating anonymous function at /nix/store/4p74s0h0z1w3bpm7z3qqwi33rkds73vv-source/lib/stack-cache-generator.nix:4:1, called from /nix/store/4p74s0h0z1w3bpm7z3qqwi33rkds73vv-source/overlays/haskell.nix:482:34:
build of '/nix/store/q1w025zayjvijw0rgmkspkca4wprv0aj-stack-repos.drv' failed a

Maybe I've done smth wrong?

Ah, I've been using the iohk cachix to avoid having to build the bootstrapping stuff. Once I know that the haskell.nix derivations are working, I'll push the builds to the all-hies cachix. For now you can use

$ cachix use iohk

to avoid most of the building (though it's still a lot even with that)

No changes. It stops on unpacking sources of stack-repos.

meck commented

I get the same error as @drchaos when trying this branch.

Ahh that was my mistake after all (I didn't look too closely at the error), I pushed a fix now. (The iohk cachix is still recommended though)

@infinisil It works now! Thanks.

Now done with #64