on iko/ghcjs-patch-master help sign in
Better error message when building missing ghcjs (#1140)

Currently if you try to build a ghcjs version that does not exist haskell.nix falls back on the GHC version. Once ghcjs is in the ghc tree this will work, but for now we should have an error message that is more descriptive than attempting and failing to build ghc for a js target. New error looks like this: ``` $ nix-build -A pkgs-unstable.pkgsCross.ghcjs.buildPackages.haskell-nix.compiler.ghc861 error: ghcjs 8.6.1 is no longer supported by haskell.nix. Consider using 8.6.5 ```

commit90184a79f96c877a71dd33cb6d590ee62317ed82 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 17 Jun 2021, 11:57 (5 years ago) parentf899936
2 files changed+21−42
overlays/bootstrap.nix+16−34 test/haskell-language-server/stack.nix+5−8
overlays/bootstrap.nix+16−34
@@ -48,6 +48,7 @@ let
4848 };
4949 traceWarnOld = v: x: __trace
5050 "WARNING: ${x.src-spec.version} is out of date, consider using ${latestVer.${v}}." x;
51+ errorOldGhcjs = v: up: throw "ghcjs ${v} is no longer supported by haskell.nix. Consider using ${latestVer.${up}}";
5152in {
5253 haskell-nix = prev.haskell-nix // {
5354 # Use this to disable the existing haskell infra structure for testing purposes
@@ -515,6 +516,21 @@ in {
515516 isHaskellNixBootCompiler = true;
516517 })
517518 ({
519+ # Better error messages when an unsupported version of ghcjs is used
520+ ghc844 = errorOldGhcjs "8.4.4" "8.6";
521+ ghc861 = errorOldGhcjs "8.6.1" "8.6";
522+ ghc862 = errorOldGhcjs "8.6.2" "8.6";
523+ ghc863 = errorOldGhcjs "8.6.3" "8.6";
524+ ghc864 = errorOldGhcjs "8.6.4" "8.6";
525+ ghc881 = errorOldGhcjs "8.8.1" "8.8";
526+ ghc882 = errorOldGhcjs "8.8.2" "8.8";
527+ ghc883 = errorOldGhcjs "8.8.3" "8.8";
528+ ghc8101 = errorOldGhcjs "8.10.1" "8.10";
529+ ghc8102 = errorOldGhcjs "8.10.2" "8.10";
530+ ghc8103 = errorOldGhcjs "8.10.3" "8.10";
531+ ghc8104 = errorOldGhcjs "8.10.4" "8.10";
532+ ghc810420210212 = throw "ghcjs for ghc810420210212 is not supported by haskell.nix";
533+ ghc901 = throw "ghcjs 9.0.1 is not yet supported by haskell.nix";
518534 ghc865 = let buildGHC = final.buildPackages.haskell-nix.compiler.ghc865;
519535 in let booted-ghcjs = final.callPackage ../compiler/ghcjs/ghcjs.nix {
520536 ghcjsSrcJson = ../compiler/ghcjs/ghcjs-src.json;
@@ -547,40 +563,6 @@ in {
547563 cd lib
548564 lndir ${booted-ghcjs}/lib ${targetPrefix}ghc-8.6.5
549565 '' + installDeps targetPrefix);
550− ghc883 = let buildGHC = final.buildPackages.haskell-nix.compiler.ghc883;
551− in let booted-ghcjs = final.callPackage ../compiler/ghcjs/ghcjs.nix {
552− ghcjsSrcJson = ../compiler/ghcjs/ghcjs88-src.json;
553− ghcjsVersion = "8.8.0.0.1";
554− ghc = buildGHC;
555− ghcVersion = "8.8.3";
556− compiler-nix-name = "ghc883";
557− }; in let targetPrefix = "js-unknown-ghcjs-"; in final.runCommand "${targetPrefix}ghc-8.8.3" {
558− nativeBuildInputs = [ final.xorg.lndir ];
559− passthru = {
560− inherit targetPrefix;
561− version = "8.8.3";
562− isHaskellNixCompiler = true;
563− enableShared = false;
564− inherit (booted-ghcjs) configured-src bundled-ghcjs project;
565− inherit booted-ghcjs buildGHC;
566− extraConfigureFlags = [
567− "--ghcjs"
568− "--with-ghcjs=${targetPrefix}ghc" "--with-ghcjs-pkg=${targetPrefix}ghc-pkg"
569− "--with-gcc=${final.buildPackages.emscripten}/bin/emcc"
570− ];
571− };
572− # note: we'll use the buildGHCs `hsc2hs`, ghcjss wrapper just horribly breaks in this nix setup.
573− } (''
574− mkdir -p $out/bin
575− cd $out/bin
576− ln -s ${booted-ghcjs}/bin/ghcjs ${targetPrefix}ghc
577− ln -s ${booted-ghcjs}/bin/ghcjs-pkg ${targetPrefix}ghc-pkg
578− ln -s ${buildGHC}/bin/hsc2hs ${targetPrefix}hsc2hs
579− cd ..
580− mkdir -p lib/${targetPrefix}ghc-8.8.3
581− cd lib
582− lndir ${booted-ghcjs}/lib ${targetPrefix}ghc-8.8.3
583− '' + installDeps targetPrefix);
584566 ghc884 = let buildGHC = final.buildPackages.haskell-nix.compiler.ghc884;
585567 in let booted-ghcjs = final.callPackage ../compiler/ghcjs/ghcjs.nix {
586568 ghcjsSrcJson = ../compiler/ghcjs/ghcjs88-src.json;
test/haskell-language-server/stack.nix+5−8
@@ -1,21 +1,18 @@
1−{ lib, testSrc, haskell-nix, evalPackages, buildPackages, compiler-nix-name, recurseIntoAttrs }:
1+{ stdenv, lib, testSrc, haskell-nix, evalPackages, buildPackages, compiler-nix-name, recurseIntoAttrs }:
22let
33 project = buildPackages.haskell-nix.project' {
44 inherit compiler-nix-name;
55 src = evalPackages.fetchgit {
66 url = "https://github.com/haskell/haskell-language-server.git";
77 fetchSubmodules = true;
8− rev = "1.1.0";
9− sha256 = "sha256-5bIr7Zsvn1B8bjjiHPLQQS8+qW3ZiEwqBnFUG+fAcU8=";
8+ rev = "1.2.0";
9+ sha256 = "sha256-vNpb/Fjb9sKkt/1r29c82P/NeAXpxQbVKnM/EDWY6z4=";
1010 };
11− projectFileName = "stack-${buildPackages.haskell-nix.compiler.${
12− if compiler-nix-name == "ghc8105"
13− then "ghc8104"
14− else compiler-nix-name
15− }.version}.yaml";
11+ projectFileName = "stack-${buildPackages.haskell-nix.compiler.${compiler-nix-name}.version}.yaml";
1612 sha256map = {
1713 "https://github.com/alanz/ghc-exactprint.git"."6748e24da18a6cea985d20cc3e1e7920cb743795" = "18r41290xnlizgdwkvz16s7v8k2znc7h215sb1snw6ga8lbv60rb";
1814 "https://github.com/bubba/brittany.git"."c59655f10d5ad295c2481537fc8abf0a297d9d1c" = "1rkk09f8750qykrmkqfqbh44dbx1p8aq1caznxxlw8zqfvx39cxl";
15+ "https://github.com/hsyl20/ghc-api-compat.git"."8fee87eac97a538dbe81ff1ab18cff10f2f9fa15" = "sha256-byehvdxQxhNk5ZQUXeFHjAZpAze4Ct9261ro4c5acZk=";
1916 };
2017 };
2118in recurseIntoAttrs {