2016-11-18 15:13:56 +00:00
{ mkDerivation
2017-02-25 22:45:40 +00:00
, lib
2017-02-27 07:10:34 +00:00
, broken ? false
2016-11-18 15:13:56 +00:00
, test-framework
, test-framework-hunit
, data-default
, ghc-paths
, haskell-src-exts
, haskell-src-meta
, optparse-applicative
, system-fileio
, system-filepath
, text-binary
, unordered-containers
, cabal-install
, wl-pprint-text
, base16-bytestring
, executable-path
, transformers-compat
, haddock-api
, regex-posix
, bootPkgs , gmp
, runCommand
, nodejs , stdenv , filepath , HTTP , HUnit , mtl , network , QuickCheck , random , stm
, time
, zlib , aeson , attoparsec , bzlib , hashable
, lens
, parallel , safe , shelly , split , stringsearch , syb
, tar , terminfo
2018-07-21 01:44:44 +01:00
, vector , yaml , fetchgit , fetchFromGitHub
2016-11-18 15:13:56 +00:00
, alex , happy , git , gnumake , autoconf , patch
, automake , libtool
, cryptohash
2018-07-21 01:44:44 +01:00
, haddock , hspec , xhtml , pkgs
2016-11-18 15:13:56 +00:00
, coreutils
, libiconv
2018-09-27 23:27:07 +01:00
, version
, ghcjsSrc
, ghcjsBootSrc
2016-11-18 15:13:56 +00:00
, ghcjsBoot ? import ./ghcjs-boot.nix {
inherit runCommand ;
src = ghcjsBootSrc ;
}
2018-09-27 23:27:07 +01:00
, shims
2016-11-18 15:13:56 +00:00
# This is the list of the Stage 1 packages that are built into a booted ghcjs installation
# It can be generated with the command:
# nix-shell -p haskell.packages.ghcjs.ghc --command "ghcjs-pkg list | sed -n 's/^ \(.*\)-\([0-9.]*\)$/\1_\2/ p' | sed 's/\./_/g' | sed 's/^\([^_]*\)\(.*\)$/ \"\1\"/'"
2018-09-27 23:27:07 +01:00
, stage1Packages
2016-11-21 09:13:09 +00:00
, stage2 ? import ./stage2.nix
2017-02-25 22:45:40 +00:00
2018-09-27 23:27:07 +01:00
, patches
2017-02-25 22:45:40 +00:00
# used for resolving compiler plugins
, ghcLibdir ? null
2016-11-18 15:13:56 +00:00
} :
let
inherit ( bootPkgs ) ghc ;
in mkDerivation ( rec {
pname = " g h c j s " ;
inherit version ;
src = ghcjsSrc ;
isLibrary = true ;
isExecutable = true ;
jailbreak = true ;
doHaddock = false ;
doCheck = false ;
buildDepends = [
filepath HTTP mtl network random stm time zlib aeson attoparsec
bzlib data-default ghc-paths hashable haskell-src-exts haskell-src-meta
lens optparse-applicative parallel safe shelly split
stringsearch syb system-fileio system-filepath tar terminfo text-binary
unordered-containers vector wl-pprint-text yaml
2017-12-05 08:36:08 +00:00
alex happy git gnumake autoconf automake libtool patch gmp
2016-11-18 15:13:56 +00:00
base16-bytestring cryptohash executable-path haddock-api
transformers-compat QuickCheck haddock hspec xhtml
2017-04-07 19:02:32 +01:00
regex-posix libiconv
2016-11-18 15:13:56 +00:00
] ;
buildTools = [ nodejs git ] ;
testDepends = [
HUnit test-framework test-framework-hunit
] ;
2017-02-25 22:45:40 +00:00
inherit patches ;
2016-11-18 15:13:56 +00:00
postPatch = ''
substituteInPlace Setup . hs \
- - replace " / u s r / b i n / e n v " " ${ coreutils } / b i n / e n v "
substituteInPlace src/Compiler/Info.hs \
- - replace " @ P R E F I X @ " " $ o u t " \
- - replace " @ V E R S I O N @ " " ${ version } "
substituteInPlace src-bin/Boot.hs \
- - replace " @ P R E F I X @ " " $ o u t " \
- - replace " @ C C @ " " ${ stdenv . cc } / b i n / c c "
'' ;
preBuild = ''
export HOME = " $ T M P "
local topDir = $ out/lib/ghcjs- $ { version }
mkdir - p $ topDir
cp - r $ { ghcjsBoot } $ topDir/ghcjs-boot
chmod - R u + w $ topDir/ghcjs-boot
cp - r $ { shims } $ topDir/shims
chmod - R u + w $ topDir/shims
# Make the patches be relative their corresponding package's directory.
# See: https://github.com/ghcjs/ghcjs-boot/pull/12
for patch in " $ t o p D i r / g h c j s - b o o t / p a t c h e s / " * . patch ; do
echo " f i x i n g p a t c h : $ p a t c h "
sed - i - e ' s @ \ ( a \ | b \ ) /boot / [ ^ / ] \ + @ \ 1 @ g' $ patch
done
'' ;
# We build with --quick so we can build stage 2 packages separately.
# This is necessary due to: https://github.com/haskell/cabal/commit/af19fb2c2d231d8deff1cb24164a2bf7efb8905a
# Cabal otherwise fails to build: http://hydra.nixos.org/build/31824079/nixlog/1/raw
postInstall = ''
PATH = $ out/bin : $ PATH LD_LIBRARY_PATH = $ { gmp . out } /lib : $ { stdenv . cc } /lib64 : $ LD_LIBRARY_PATH \
env - u GHC_PACKAGE_PATH $ out/bin/ghcjs-boot \
- - dev \
- - quick \
- - with-cabal $ { cabal-install } /bin/cabal \
- - with-gmp-includes $ { gmp . dev } /include \
- - with-gmp-libraries $ { gmp . out } /lib
2017-02-25 22:45:40 +00:00
'' + l i b . o p t i o n a l S t r i n g ( g h c L i b d i r ! = n u l l ) ''
printf ' % s' ' $ { ghcLibdir } ' > " $ o u t / l i b / g h c j s - ${ version } / g h c _ l i b d i r "
2016-11-18 15:13:56 +00:00
'' ;
2017-02-08 23:22:11 +00:00
passthru = {
2016-11-18 15:13:56 +00:00
inherit bootPkgs ;
2018-09-28 17:06:31 +01:00
ghcVersion = ghc . version ;
2016-11-18 15:13:56 +00:00
isCross = true ;
isGhcjs = true ;
inherit nodejs ghcjsBoot ;
2017-10-31 22:10:47 +00:00
socket-io = pkgs . nodePackages . " s o c k e t . i o " ;
2018-06-14 16:35:19 +01:00
haskellCompilerName = " g h c j s - ${ version } " ;
2016-11-18 15:13:56 +00:00
2018-01-08 18:30:15 +00:00
# let us assume ghcjs is never actually cross compiled
2018-01-08 18:31:12 +00:00
targetPrefix = " " ;
2018-01-08 18:30:15 +00:00
2018-06-20 22:57:35 +01:00
enableShared = true ;
2016-11-18 15:13:56 +00:00
inherit stage1Packages ;
2016-11-21 09:13:09 +00:00
mkStage2 = stage2 {
2016-11-18 15:13:56 +00:00
inherit ghcjsBoot ;
} ;
} ;
2017-08-01 21:03:30 +01:00
homepage = https://github.com/ghcjs/ghcjs ;
2016-11-18 15:13:56 +00:00
description = " A H a s k e l l t o J a v a S c r i p t c o m p i l e r t h a t u s e s t h e G H C A P I " ;
license = stdenv . lib . licenses . bsd3 ;
platforms = ghc . meta . platforms ;
2018-04-01 08:57:38 +01:00
maintainers = with stdenv . lib . maintainers ; [ jwiegley cstrahan dmjio elvishjerricco ] ;
2018-03-05 11:36:34 +00:00
hydraPlatforms = if broken then [ ] else ghc . meta . platforms ;
2017-02-27 07:10:34 +00:00
inherit broken ;
2016-11-18 15:13:56 +00:00
} )