2016-11-18 16:13:56 +01:00
{ mkDerivation
2017-02-25 23:45:40 +01:00
, lib
2017-02-27 08:10:34 +01:00
, broken ? false
2016-11-18 16:13:56 +01: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 02:44:44 +02:00
, vector , yaml , fetchgit , fetchFromGitHub
2016-11-18 16:13:56 +01:00
, alex , happy , git , gnumake , autoconf , patch
, automake , libtool
, cryptohash
2018-07-21 02:44:44 +02:00
, haddock , hspec , xhtml , pkgs
2016-11-18 16:13:56 +01:00
, coreutils
, libiconv
2018-09-28 00:27:07 +02:00
, version
, ghcjsSrc
, ghcjsBootSrc
2016-11-18 16:13:56 +01:00
, ghcjsBoot ? import ./ghcjs-boot.nix {
inherit runCommand ;
src = ghcjsBootSrc ;
}
2018-09-28 00:27:07 +02:00
, shims
2016-11-18 16:13:56 +01: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-28 00:27:07 +02:00
, stage1Packages
2016-11-21 10:13:09 +01:00
, stage2 ? import ./stage2.nix
2017-02-25 23:45:40 +01:00
2018-09-28 00:27:07 +02:00
, patches
2017-02-25 23:45:40 +01:00
# used for resolving compiler plugins
, ghcLibdir ? null
2016-11-18 16:13:56 +01: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 09:36:08 +01:00
alex happy git gnumake autoconf automake libtool patch gmp
2016-11-18 16:13:56 +01:00
base16-bytestring cryptohash executable-path haddock-api
transformers-compat QuickCheck haddock hspec xhtml
2017-04-07 20:02:32 +02:00
regex-posix libiconv
2016-11-18 16:13:56 +01:00
] ;
buildTools = [ nodejs git ] ;
testDepends = [
HUnit test-framework test-framework-hunit
] ;
2017-02-25 23:45:40 +01:00
inherit patches ;
2016-11-18 16:13:56 +01: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 23:45:40 +01: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 16:13:56 +01:00
'' ;
2017-02-09 00:22:11 +01:00
passthru = {
2016-11-18 16:13:56 +01:00
inherit bootPkgs ;
2018-09-28 18:06:31 +02:00
ghcVersion = ghc . version ;
2016-11-18 16:13:56 +01:00
isCross = true ;
isGhcjs = true ;
inherit nodejs ghcjsBoot ;
2017-10-31 23:10:47 +01:00
socket-io = pkgs . nodePackages . " s o c k e t . i o " ;
2018-06-14 17:35:19 +02:00
haskellCompilerName = " g h c j s - ${ version } " ;
2016-11-18 16:13:56 +01:00
2018-01-08 19:30:15 +01:00
# let us assume ghcjs is never actually cross compiled
2018-01-08 19:31:12 +01:00
targetPrefix = " " ;
2018-01-08 19:30:15 +01:00
2018-06-20 23:57:35 +02:00
enableShared = true ;
2016-11-18 16:13:56 +01:00
inherit stage1Packages ;
2016-11-21 10:13:09 +01:00
mkStage2 = stage2 {
2016-11-18 16:13:56 +01:00
inherit ghcjsBoot ;
} ;
} ;
2017-08-01 22:03:30 +02:00
homepage = https://github.com/ghcjs/ghcjs ;
2016-11-18 16:13:56 +01: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 09:57:38 +02:00
maintainers = with stdenv . lib . maintainers ; [ jwiegley cstrahan dmjio elvishjerricco ] ;
2018-03-05 12:36:34 +01:00
hydraPlatforms = if broken then [ ] else ghc . meta . platforms ;
2017-02-27 08:10:34 +01:00
inherit broken ;
2016-11-18 16:13:56 +01:00
} )