Integrate ghcjs
Use nixpkgs.haskellPackages_ghcjs to build packages with ghcjs.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
{ cabal, filepath, HTTP, HUnit, mtl, network, QuickCheck, random, stm
|
||||
, testFramework, testFrameworkHunit, testFrameworkQuickcheck2, time
|
||||
, zlib, aeson, attoparsec, bzlib, dataDefault, ghcPaths, hashable
|
||||
, haskellSrcExts, haskellSrcMeta, lens, optparseApplicative_0_7_0_2
|
||||
, parallel, safe, shelly, split, stringsearch, syb, systemFileio
|
||||
, systemFilepath, tar, terminfo, textBinary, unorderedContainers
|
||||
, vector, wlPprintText, yaml, fetchgit, Cabal, CabalGhcjs, cabalInstall
|
||||
, regexPosix, alex, happy, git, gnumake, gcc, autoconf, patch
|
||||
, automake, libtool, cabalInstallGhcjs, gmp
|
||||
}:
|
||||
|
||||
cabal.mkDerivation (self: rec {
|
||||
pname = "ghcjs";
|
||||
version = "0.1.0";
|
||||
src = fetchgit {
|
||||
url = git://github.com/ghcjs/ghcjs.git;
|
||||
rev = "c9ce6b9d87296b1236d5ef0f7d5236b2cedcff84";
|
||||
sha256 = "0cla5bchprc8g5n39fkssnv3lj378h948irsnr7dslaki6laaagw";
|
||||
};
|
||||
bootSrc = fetchgit {
|
||||
url = git://github.com/ghcjs/ghcjs-boot.git;
|
||||
rev = "2daaf8fc0efd5b5906a7157a172ce77ca3b28d81";
|
||||
sha256 = "0kwn3lh196rp02kz2vxd0mkqyix99xqzs4vsazv0s49ari0dc4w8";
|
||||
};
|
||||
shims = fetchgit {
|
||||
url = git://github.com/ghcjs/shims.git;
|
||||
rev = "a6dd0202dcdb86ad63201495b8b5d9763483eb35";
|
||||
sha256 = "07cd7ijw4i62iz1xjpwilriiybpqdx246w8d3j27ny1xfsj9wnax";
|
||||
};
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
jailbreak = true;
|
||||
noHaddock = true;
|
||||
buildDepends = [
|
||||
filepath HTTP mtl network random stm time zlib aeson attoparsec
|
||||
bzlib dataDefault ghcPaths hashable haskellSrcExts haskellSrcMeta
|
||||
lens optparseApplicative_0_7_0_2 parallel safe shelly split
|
||||
stringsearch syb systemFileio systemFilepath tar terminfo textBinary
|
||||
unorderedContainers vector wlPprintText yaml
|
||||
alex happy git gnumake gcc autoconf automake libtool patch gmp
|
||||
];
|
||||
testDepends = [
|
||||
HUnit regexPosix testFramework testFrameworkHunit
|
||||
];
|
||||
postConfigure = ''
|
||||
echo Patching ghcjs with absolute paths to the Nix store
|
||||
sed -i -e "s|getAppUserDataDirectory \"ghcjs\"|return \"$out/share/ghcjs\"|" \
|
||||
src/Compiler/Info.hs
|
||||
sed -i -e "s|str = \\[\\]|str = [\"--prefix=$out\", \"--libdir=$prefix/lib/$compiler\", \"--libsubdir=$pkgid\"]|" \
|
||||
src-bin/Boot.hs
|
||||
'';
|
||||
postInstall = ''
|
||||
export HOME=$(pwd)
|
||||
cp -R ${bootSrc} ghcjs-boot
|
||||
cd ghcjs-boot
|
||||
( cd boot ; chmod u+w . ; ln -s .. ghcjs-boot )
|
||||
chmod -R u+w . # because fetchgit made it read-only
|
||||
local GHCJS_LIBDIR=$out/share/ghcjs/x86_64-linux-0.1.0-7.8.2
|
||||
ensureDir $GHCJS_LIBDIR
|
||||
cp -R ${shims} $GHCJS_LIBDIR/shims
|
||||
${cabalInstallGhcjs}/bin/cabal-js update
|
||||
PATH=$out/bin:${CabalGhcjs}/bin:$PATH LD_LIBRARY_PATH=${gmp}/lib:${gcc.gcc}/lib64:$LD_LIBRARY_PATH \
|
||||
env -u GHC_PACKAGE_PATH $out/bin/ghcjs-boot --init --with-cabal ${cabalInstallGhcjs}/bin/cabal-js --with-gmp-includes ${gmp}/include --with-gmp-libraries ${gmp}/lib
|
||||
'';
|
||||
meta = {
|
||||
homepage = "https://github.com/ghcjs/ghcjs";
|
||||
description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API";
|
||||
license = self.stdenv.lib.licenses.bsd3;
|
||||
platforms = self.ghc.meta.platforms;
|
||||
maintainers = [ self.stdenv.lib.maintainers.jwiegley ];
|
||||
};
|
||||
})
|
||||
@@ -0,0 +1,77 @@
|
||||
{ stdenv, ghc, makeWrapper, coreutils, writeScript }:
|
||||
let
|
||||
ghcjs = ghc;
|
||||
packageDBFlag = "-package-db";
|
||||
|
||||
GHCGetPackages = writeScript "ghc-get-packages.sh" ''
|
||||
#! ${stdenv.shell}
|
||||
# Usage:
|
||||
# $1: version of GHC
|
||||
# $2: invocation path of GHC
|
||||
# $3: prefix
|
||||
version="$1"
|
||||
if test -z "$3"; then
|
||||
prefix="${packageDBFlag} "
|
||||
else
|
||||
prefix="$3"
|
||||
fi
|
||||
PATH="$PATH:$2"
|
||||
IFS=":"
|
||||
for p in $PATH; do
|
||||
for i in "$p/../share/ghcjs/$system-${ghcjs.version}-${ghcjs.ghc.version}"{,/lib,/ghcjs}"/package.conf.d" "$p/../lib/ghcjs-${ghc.version}_ghc-${ghc.ghc.version}/package.conf.d" ; do
|
||||
# output takes place here
|
||||
test -f $i/package.cache && echo -n " $prefix$i"
|
||||
done
|
||||
done
|
||||
'';
|
||||
|
||||
GHCPackages = writeScript "ghc-packages.sh" ''
|
||||
#! ${stdenv.shell} -e
|
||||
declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
|
||||
|
||||
for arg in $(${GHCGetPackages} ${ghcjs.version} "$(dirname $0)"); do # Why is ghc.version passed in from here instead of captured in the other script directly?
|
||||
case "$arg" in
|
||||
${packageDBFlag}) ;;
|
||||
*)
|
||||
CANONICALIZED="$(${coreutils}/bin/readlink -f -- "$arg")"
|
||||
GHC_PACKAGES_HASH["$CANONICALIZED"]= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
for path in ''${!GHC_PACKAGES_HASH[@]}; do
|
||||
echo -n "$path:"
|
||||
done
|
||||
'';
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "ghcjs-ghc${ghcjs.ghc.version}-${ghcjs.version}-wrapper";
|
||||
|
||||
buildInputs = [makeWrapper];
|
||||
propagatedBuildInputs = [ghcjs];
|
||||
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
for prg in ghcjs ; do
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghcjs.version} \"\$(dirname \$0)\")"
|
||||
done
|
||||
for prg in ghcjs-pkg ; do
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghcjs.version} \"\$(dirname \$0)\" -${packageDBFlag}=)"
|
||||
done
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
|
||||
|
||||
mkdir -p $out/share/doc
|
||||
ln -s $ghc/lib $out/lib
|
||||
ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghcjs.version}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
ghc = ghcjs;
|
||||
inherit GHCGetPackages GHCPackages;
|
||||
inherit (ghcjs) meta version;
|
||||
}
|
||||
Reference in New Issue
Block a user