ghcjs: properly wrap binaries in environment

This also:

 1  Builds Setup.hs with ghcjs, which (among other things) defines
    __GHCJS__ and ghcjs_HOST_OS during pre-processing.
 2  Fixes ghc-paths to point at ghcjs and use NIX_GHCJS_* env-vars.
 3  Boots ghcjs into $prefix/lib/$compiler.
This commit is contained in:
Charles Strahan
2015-05-06 15:56:02 -04:00
committed by Domen Kožar
parent 27d4e762a0
commit 4e04fdce86
6 changed files with 125 additions and 46 deletions

View File

@@ -39,10 +39,6 @@
}:
let
version = "0.1.0";
ghcArch = if pkgs.stdenv.system == "i686-linux"
then "i386-linux"
else pkgs.stdenv.system;
libDir = "share/ghcjs/${ghcArch}-${version}-${ghc.version}/ghcjs";
ghcjsBoot = fetchgit {
url = git://github.com/ghcjs/ghcjs-boot.git;
rev = "ab8765edcb507b8b810e3c324fd5bd5af2b69d8f"; # 7.10 branch
@@ -84,14 +80,19 @@ in mkDerivation (rec {
];
patches = [ ./ghcjs.patch ];
postPatch = ''
substituteInPlace Setup.hs --replace "/usr/bin/env" "${coreutils}/bin/env"
substituteInPlace src/Compiler/Info.hs --replace "@PREFIX@" "$out"
substituteInPlace Setup.hs \
--replace "/usr/bin/env" "${coreutils}/bin/env"
substituteInPlace src/Compiler/Info.hs \
--replace "@PREFIX@" "$out" \
--replace "@VERSION@" "${version}"
substituteInPlace src-bin/Boot.hs \
--replace "@PREFIX@" "$out" \
--replace "@CC@" "${stdenv.cc}/bin/cc"
'';
preBuild = ''
local topDir=$out/${libDir}
local topDir=$out/lib/ghcjs-${version}
mkdir -p $topDir
cp -r ${ghcjsBoot} $topDir/ghcjs-boot
@@ -116,9 +117,9 @@ in mkDerivation (rec {
--with-gmp-libraries ${gmp}/lib
'';
passthru = {
inherit libDir;
isGhcjs = true;
nativeGhc = ghc;
inherit nodejs;
};
homepage = "https://github.com/ghcjs/ghcjs";

View File

@@ -60,15 +60,21 @@ index 3c68dcf..64f3cf7 100644
, "--haddock-html"
-- workaround for hoogle support being broken in haddock for GHC 7.10RC1
diff --git a/src/Compiler/Info.hs b/src/Compiler/Info.hs
index 33a401f..5d09c86 100644
index 33a401f..79833c5 100644
--- a/src/Compiler/Info.hs
+++ b/src/Compiler/Info.hs
@@ -49,7 +49,7 @@ compilerInfo nativeToo dflags = do
@@ -48,13 +48,7 @@ compilerInfo nativeToo dflags = do
-- | the directory to use if started without -B flag
getDefaultTopDir :: IO FilePath
getDefaultTopDir = do
-getDefaultTopDir = do
- appdir <- getAppUserDataDirectory "ghcjs"
+ let appdir = "@PREFIX@/share/ghcjs"
return (appdir </> subdir </> "ghcjs")
where
targetARCH = arch
- return (appdir </> subdir </> "ghcjs")
- where
- targetARCH = arch
- targetOS = os
- subdir = targetARCH ++ '-':targetOS ++ '-':getFullCompilerVersion
+getDefaultTopDir = return "@PREFIX@/lib/ghcjs-@VERSION@"
getDefaultLibDir :: IO FilePath
getDefaultLibDir = getDefaultTopDir