Merge pull request #14581 from obadz/haste-compiler

haskellPackages.haste-compiler: fix so that it now builds and runs

+141 -1
+24
doc/haskell-users-guide.md
··· 647 647 rm /nix/var/nix/manifests/* 648 648 rm /nix/var/nix/channel-cache/* 649 649 650 + ### How to use the Haste Haskell-to-Javascript transpiler 651 + 652 + Open a shell with `haste-compiler` and `haste-cabal-install` (you don't actually need 653 + `node`, but it can be useful to test stuff): 654 + 655 + $ nix-shell -p "haskellPackages.ghcWithPackages (self: with self; [haste-cabal-install haste-compiler])" -p nodejs 656 + 657 + You may not need the following step but if `haste-boot` fails to compile all the 658 + packages it needs, this might do the trick 659 + 660 + $ haste-cabal update 661 + 662 + `haste-boot` builds a set of core libraries so that they can be used from Javascript 663 + transpiled programs: 664 + 665 + $ haste-boot 666 + 667 + Transpile and run a "Hello world" program: 668 + 669 + $ echo 'module Main where main = putStrLn "Hello world"' > hello-world.hs 670 + $ hastec --onexec hello-world.hs 671 + $ node hello-world.js 672 + Hello world 673 + 650 674 ### Builds on Darwin fail with `math.h` not found 651 675 652 676 Users of GHC on Darwin have occasionally reported that builds fail, because the
+4 -1
pkgs/development/haskell-modules/configuration-common.nix
··· 154 154 gl = dontHaddock super.gl; 155 155 groupoids = dontHaddock super.groupoids; 156 156 hamlet = dontHaddock super.hamlet; 157 - haste-compiler = dontHaddock super.haste-compiler; 158 157 HaXml = dontHaddock super.HaXml; 159 158 HDBC-odbc = dontHaddock super.HDBC-odbc; 160 159 hoodle-core = dontHaddock super.hoodle-core; ··· 964 963 # https://github.com/danidiaz/pipes-transduce/issues/2 965 964 pipes-transduce = super.pipes-transduce.override { foldl = self.foldl_1_1_6; }; 966 965 966 + # Haste stuff 967 + haste-Cabal = self.callPackage ../tools/haskell/haste/haste-Cabal.nix {}; 968 + haste-cabal-install = self.callPackage ../tools/haskell/haste/haste-cabal-install.nix { Cabal = self.haste-Cabal; HTTP = self.HTTP_4000_2_23; }; 969 + haste-compiler = self.callPackage ../tools/haskell/haste/haste-compiler.nix { inherit overrideCabal; super-haste-compiler = super.haste-compiler; }; 967 970 }
+35
pkgs/development/tools/haskell/haste/haste-Cabal.nix
··· 1 + # Haste requires its own patched up version of Cabal that's not on hackage 2 + { mkDerivation, array, base, binary, bytestring, containers 3 + , deepseq, directory, extensible-exceptions, filepath, old-time 4 + , pretty, process, QuickCheck, regex-posix, stdenv, tasty 5 + , tasty-hunit, tasty-quickcheck, time, unix 6 + , fetchFromGitHub 7 + }: 8 + 9 + mkDerivation { 10 + pname = "Cabal"; 11 + version = "1.23.0.0"; 12 + src = fetchFromGitHub { 13 + owner = "valderman"; 14 + repo = "cabal"; 15 + rev = "a1962987ba32d5e20090830f50c6afdc78dae005"; 16 + sha256 = "1gjmscfsikcvgkv6zricpfxvj23wxahndm784lg9cpxrc3pn5hvh"; 17 + }; 18 + libraryHaskellDepends = [ 19 + array base binary bytestring containers deepseq directory filepath 20 + pretty process time unix 21 + ]; 22 + testHaskellDepends = [ 23 + base bytestring containers directory extensible-exceptions filepath 24 + old-time pretty process QuickCheck regex-posix tasty tasty-hunit 25 + tasty-quickcheck unix 26 + ]; 27 + prePatch = '' 28 + rm -rf cabal-install 29 + cd Cabal 30 + ''; 31 + doCheck = false; 32 + homepage = "http://www.haskell.org/cabal/"; 33 + description = "A framework for packaging Haskell software"; 34 + license = stdenv.lib.licenses.bsd3; 35 + }
+46
pkgs/development/tools/haskell/haste/haste-cabal-install.nix
··· 1 + # Haste requires its own patched up version of cabal-install that's not on hackage 2 + { mkDerivation, array, base, bytestring, Cabal, containers 3 + , directory, extensible-exceptions, filepath, HTTP, mtl, network 4 + , network-uri, pretty, process, QuickCheck, random, regex-posix 5 + , stdenv, stm, tagged, tasty, tasty-hunit, tasty-quickcheck, time 6 + , unix, zlib 7 + , fetchFromGitHub 8 + }: 9 + 10 + mkDerivation { 11 + pname = "cabal-install"; 12 + version = "1.23.0.0"; 13 + src = fetchFromGitHub { 14 + owner = "valderman"; 15 + repo = "cabal"; 16 + rev = "a1962987ba32d5e20090830f50c6afdc78dae005"; 17 + sha256 = "1gjmscfsikcvgkv6zricpfxvj23wxahndm784lg9cpxrc3pn5hvh"; 18 + }; 19 + isLibrary = false; 20 + isExecutable = true; 21 + executableHaskellDepends = [ 22 + array base bytestring Cabal containers directory filepath HTTP mtl 23 + network network-uri pretty process random stm time unix zlib 24 + ]; 25 + testHaskellDepends = [ 26 + array base bytestring Cabal containers directory 27 + extensible-exceptions filepath HTTP mtl network network-uri pretty 28 + process QuickCheck random regex-posix stm tagged tasty tasty-hunit 29 + tasty-quickcheck time unix zlib 30 + ]; 31 + prePatch = '' 32 + rm -rf Cabal 33 + cd cabal-install 34 + ''; 35 + postInstall = '' 36 + mkdir $out/etc 37 + mv bash-completion $out/etc/bash_completion.d 38 + 39 + # Manually added by Nix maintainer 40 + mv -v $out/etc/bash_completion.d/cabal $out/etc/bash_completion.d/haste-cabal 41 + ''; 42 + doCheck = false; 43 + homepage = "http://www.haskell.org/cabal/"; 44 + description = "The command-line interface for Cabal and Hackage"; 45 + license = stdenv.lib.licenses.bsd3; 46 + }
+32
pkgs/development/tools/haskell/haste/haste-compiler.nix
··· 1 + { overrideCabal 2 + , super-haste-compiler 3 + }: 4 + 5 + overrideCabal super-haste-compiler (drv: { 6 + configureFlags = [ "-f-portable" ]; 7 + prePatch = '' 8 + # Get ghc libdir by invoking ghc and point to haste-cabal binary 9 + substituteInPlace src/Haste/Environment.hs \ 10 + --replace \ 11 + 'hasteGhcLibDir = hasteSysDir' \ 12 + 'hasteGhcLibDir = head $ lines $ either (error . show) id $ unsafePerformIO $ shell $ run "ghc" ["--print-libdir"] ""' \ 13 + --replace \ 14 + 'hasteCabalBinary = hasteBinDir </> "haste-cabal" ++ binaryExt' \ 15 + 'hasteCabalBinary = "haste-cabal" ++ binaryExt' 16 + 17 + # Don't try to download/install haste-cabal in haste-boot: 18 + patch src/haste-boot.hs << EOF 19 + @@ -178,10 +178,6 @@ 20 + pkgSysLibDir, jsmodSysDir, pkgSysDir] 21 + 22 + mkdir True (hasteCabalRootDir portableHaste) 23 + - case getHasteCabal cfg of 24 + - Download -> installHasteCabal portableHaste tmpdir 25 + - Prebuilt fp -> copyHasteCabal portableHaste fp 26 + - Source mdir -> buildHasteCabal portableHaste (maybe "../cabal" id mdir) 27 + 28 + -- Spawn off closure download in the background. 29 + dir <- pwd -- use absolute path for closure to avoid dir changing race 30 + EOF 31 + ''; 32 + })