purify ghcjs

This commit is contained in:
Charles Strahan 2014-12-11 20:53:25 -05:00
parent a2d4a415d3
commit fb59151109
3 changed files with 117 additions and 34 deletions

View File

@ -194,7 +194,7 @@ in
done done
done done
configureFlags+=" --package-db=${ghc.ghc}${ghc.ghc.libdir}/ghcjs/package.conf.d" configureFlags+=" --package-db=${ghc.ghc}/${ghc.ghc.libDir}/package.conf.d"
${optionalString (self.enableSharedExecutables && self.stdenv.isLinux) '' ${optionalString (self.enableSharedExecutables && self.stdenv.isLinux) ''
configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}"; configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}";

View File

@ -9,35 +9,44 @@
, automake, libtool, cabalInstallGhcjs, gmp, base16Bytestring , automake, libtool, cabalInstallGhcjs, gmp, base16Bytestring
, cryptohash, executablePath, transformersCompat, haddockApi , cryptohash, executablePath, transformersCompat, haddockApi
, haddock, hspec, xhtml, primitive, cacert, pkgs, ghc , haddock, hspec, xhtml, primitive, cacert, pkgs, ghc
, coreutils
}: }:
cabal.mkDerivation (self: rec { let
pname = "ghcjs";
version = "0.1.0"; version = "0.1.0";
src = fetchgit { libDir = "share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.ghc.version}/ghcjs";
url = git://github.com/ghcjs/ghcjs.git; ghcjsBoot = fetchgit {
rev = "5c2d279982466e076223fcbe1e1096e22956e5a9"; url = git://github.com/ghcjs/ghcjs-boot.git;
sha256 = "0bc37b4e8bd039208a126fea39850c99459265cb273ac7237939cdbaee6ef71f"; rev = "8bf2861c0c776eec42e0a1833f220e36681e810c";
sha256 = "0fwnng56d1y98fpp2s9yl9xy21584p7fsszr4m9d3wmjciiazcv2";
}; };
shims = fetchgit { shims = fetchgit {
url = git://github.com/ghcjs/shims.git; url = git://github.com/ghcjs/shims.git;
rev = "5e11d33cb74f8522efca0ace8365c0dc994b10f6"; rev = "5e11d33cb74f8522efca0ace8365c0dc994b10f6";
sha256 = "64be139022e6f662086103fca3838330006d38e6454bd3f7b66013031a47278e"; sha256 = "13i78wd064v0nvvx6js5wqw6s01hhf1s7z03c4465xp64a817gk4";
}; };
isLibrary = true;
isExecutable = true;
jailbreak = true;
noHaddock = true;
doCheck = false;
ghcjsPrim = cabal.mkDerivation (self: { ghcjsPrim = cabal.mkDerivation (self: {
pname = "ghcjs-prim"; pname = "ghcjs-prim";
version = "0.1.0.0"; version = "0.1.0.0";
src = fetchgit { src = fetchgit {
url = git://github.com/ghcjs/ghcjs-prim.git; url = git://github.com/ghcjs/ghcjs-prim.git;
rev = "915f263c06b7f4a246c6e02ecdf2b9a0550ed967"; rev = "915f263c06b7f4a246c6e02ecdf2b9a0550ed967";
sha256 = "34dd58b6e2d0ce780da46b509fc2701c28a7b2182f8d700b53a80981ac8bcf86"; sha256 = "11ngifn822d8ac5p139g32rafa0wf319yl3blh6piknhwav5ip9l";
}; };
buildDepends = [ primitive ]; buildDepends = [ primitive ];
}); });
in cabal.mkDerivation (self: rec {
pname = "ghcjs";
inherit version;
src = fetchgit {
url = git://github.com/ghcjs/ghcjs.git;
rev = "5c2d279982466e076223fcbe1e1096e22956e5a9";
sha256 = "07zpdvpbmk9rg4iwffi7rdjr4icr1j2kkskg2a520ffhid77phqb";
};
isLibrary = true;
isExecutable = true;
jailbreak = true;
noHaddock = true;
doCheck = false;
buildDepends = [ buildDepends = [
filepath HTTP mtl network random stm time zlib aeson attoparsec filepath HTTP mtl network random stm time zlib aeson attoparsec
bzlib dataDefault ghcPaths hashable haskellSrcExts haskellSrcMeta bzlib dataDefault ghcPaths hashable haskellSrcExts haskellSrcMeta
@ -53,30 +62,32 @@ cabal.mkDerivation (self: rec {
testDepends = [ testDepends = [
HUnit testFramework testFrameworkHunit HUnit testFramework testFrameworkHunit
]; ];
postConfigure = '' patches = [ ./ghcjs.patch ];
echo Patching ghcjs with absolute paths to the Nix store postPatch = ''
sed -i -e "s|getAppUserDataDirectory \"ghcjs\"|return \"$out/share/ghcjs\"|" \ substituteInPlace Setup.hs --replace "/usr/bin/env" "${coreutils}/bin/env"
src/Compiler/Info.hs substituteInPlace src/Compiler/Info.hs --replace "@PREFIX@" "$out"
sed -i -e "s|str = \\[\\]|str = [\"--prefix=$out\", \"--libdir=$prefix/lib/$compiler\", \"--libsubdir=$pkgid\"]|" \ substituteInPlace src-bin/Boot.hs --replace "@PREFIX@" "$out"
src-bin/Boot.hs
''; '';
libdir = "/share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.ghc.version}";
postInstall = '' postInstall = ''
export HOME=$(pwd) local topDir=$out/${libDir}
export GIT_SSL_CAINFO="${cacert}/etc/ca-bundle.crt" mkdir -p $topDir
git clone git://github.com/ghcjs/ghcjs-boot.git
cd ghcjs-boot cp -r ${ghcjsBoot} $topDir/ghcjs-boot
git checkout 8bf2861c0c776eec42e0a1833f220e36681e810c chmod -R u+w $topDir/ghcjs-boot
git submodule update --init --recursive
( cd boot ; chmod u+w . ; ln -s .. ghcjs-boot ) cp -r ${shims} $topDir/shims
chmod -R u+w . # because fetchgit made it read-only chmod -R u+w $topDir/shims
local GHCJS_LIBDIR=$out${libdir}
mkdir -p $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 \ 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 --dev --with-cabal ${cabalInstallGhcjs}/bin/cabal-js --with-gmp-includes ${gmp}/include --with-gmp-libraries ${gmp}/lib env -u GHC_PACKAGE_PATH $out/bin/ghcjs-boot \
--dev \
--with-cabal ${cabalInstallGhcjs}/bin/cabal-js \
--with-gmp-includes ${gmp}/include \
--with-gmp-libraries ${gmp}/lib
''; '';
passthru = {
inherit libDir;
};
meta = { meta = {
homepage = "https://github.com/ghcjs/ghcjs"; homepage = "https://github.com/ghcjs/ghcjs";
description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API"; description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API";

View File

@ -0,0 +1,72 @@
diff --git a/src-bin/Boot.hs b/src-bin/Boot.hs
index ed348db..b102695 100644
--- a/src-bin/Boot.hs
+++ b/src-bin/Boot.hs
@@ -510,9 +510,7 @@ initPackageDB :: B ()
initPackageDB = do
msg info "creating package databases"
initDB "--global" <^> beLocations . blGlobalDB
- traverseOf_ _Just initUser <^> beLocations . blUserDBDir
where
- initUser dir = rm_f (dir </> "package.conf") >> initDB "--user" (dir </> "package.conf.d")
initDB dbName db = do
rm_rf db >> mkdir_p db
ghcjs_pkg_ ["init", toTextI db] `catchAny_` return ()
@@ -536,29 +534,22 @@ installDevelopmentTree = subTop $ do
msgD info $ "preparing development boot tree"
checkpoint' "ghcjs-boot-git" "ghcjs-boot repository already cloned and prepared" $ do
testGit "ghcjs-boot" >>= \case
- Just False -> failWith "ghcjs-boot already exists and is not a git repository"
- Just True -> do
- msg info "ghcjs-boot repository already exists but checkpoint not reached, cleaning first, then cloning"
- rm_rf "ghcjs-boot"
+ Just _ -> do
+ msg info "ghcjs-boot repository already exists; initializing ghcjs-boot"
initGhcjsBoot
Nothing -> do
msgD info "cloning ghcjs-boot git repository"
initGhcjsBoot
checkpoint' "shims-git" "shims repository already cloned" $ do
testGit "shims" >>= \case
- Just False -> failWith "shims already exists and is not a git repository"
- Just True -> do
- msgD info "shims repository already exists but checkpoint not reached, cleaning first, then cloning"
- rm_rf "shims"
- cloneGit shimsDescr "shims" bsrcShimsDevBranch bsrcShimsDev
+ Just _ -> do
+ msgD info "shims repository already exists; moving on"
Nothing -> do
msgD info "cloning shims git repository"
cloneGit shimsDescr "shims" bsrcShimsDevBranch bsrcShimsDev
where
initGhcjsBoot = sub $ do
- cloneGit bootDescr "ghcjs-boot" bsrcBootDevBranch bsrcBootDev
cd "ghcjs-boot"
- git_ ["submodule", "update", "--init", "--recursive"]
mapM_ patchPackage =<< allPackages
preparePrimops
buildGenPrim
@@ -1093,7 +1084,9 @@ cabalInstallFlags parmakeGhcjs = do
, "--builddir", "dist"
, "--with-compiler", ghcjs ^. pgmLocText
, "--with-hc-pkg", ghcjsPkg ^. pgmLocText
- , "--prefix", toTextI instDir
+ , "--prefix", "@PREFIX@"
+ , "--libdir", "$prefix/lib/$compiler"
+ , "--libsubdir", "$pkgid"
, bool haddock "--enable-documentation" "--disable-documentation"
, "--haddock-html"
, "--haddock-hoogle"
diff --git a/src/Compiler/Info.hs b/src/Compiler/Info.hs
index 2e19849..4c9e94d 100644
--- a/src/Compiler/Info.hs
+++ b/src/Compiler/Info.hs
@@ -48,7 +48,7 @@ compilerInfo nativeToo dflags = do
-- | the directory to use if started without -B flag
getDefaultTopDir :: IO FilePath
getDefaultTopDir = do
- appdir <- getAppUserDataDirectory "ghcjs"
+ let appdir = "@PREFIX@/share/ghcjs"
return (appdir </> subdir </> "ghcjs")
where
targetARCH = arch