diff options
author | Charles Strahan <charles.c.strahan@gmail.com> | 2014-12-11 20:53:25 -0500 |
---|---|---|
committer | Charles Strahan <charles.c.strahan@gmail.com> | 2014-12-11 20:56:41 -0500 |
commit | fb591511094c328873ba3789dd459e9cc630d356 (patch) | |
tree | 2ddd2ecc82c6dd982e6e2d49532c613f1bfbb718 /pkgs | |
parent | a2d4a415d3eb598013f4ef9fddba6630043c5787 (diff) | |
download | nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar.gz nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar.bz2 nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar.lz nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar.xz nixlib-fb591511094c328873ba3789dd459e9cc630d356.tar.zst nixlib-fb591511094c328873ba3789dd459e9cc630d356.zip |
purify ghcjs
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/cabal/ghcjs.nix | 2 | ||||
-rw-r--r-- | pkgs/development/tools/haskell/ghcjs/default.nix | 77 | ||||
-rw-r--r-- | pkgs/development/tools/haskell/ghcjs/ghcjs.patch | 72 |
3 files changed, 117 insertions, 34 deletions
diff --git a/pkgs/build-support/cabal/ghcjs.nix b/pkgs/build-support/cabal/ghcjs.nix index 55e10dd1f5a0..81728ff63970 100644 --- a/pkgs/build-support/cabal/ghcjs.nix +++ b/pkgs/build-support/cabal/ghcjs.nix @@ -194,7 +194,7 @@ in 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) '' configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}"; diff --git a/pkgs/development/tools/haskell/ghcjs/default.nix b/pkgs/development/tools/haskell/ghcjs/default.nix index dcd5356d261d..9f998b17ccd9 100644 --- a/pkgs/development/tools/haskell/ghcjs/default.nix +++ b/pkgs/development/tools/haskell/ghcjs/default.nix @@ -9,35 +9,44 @@ , automake, libtool, cabalInstallGhcjs, gmp, base16Bytestring , cryptohash, executablePath, transformersCompat, haddockApi , haddock, hspec, xhtml, primitive, cacert, pkgs, ghc +, coreutils }: -cabal.mkDerivation (self: rec { - pname = "ghcjs"; +let version = "0.1.0"; - src = fetchgit { - url = git://github.com/ghcjs/ghcjs.git; - rev = "5c2d279982466e076223fcbe1e1096e22956e5a9"; - sha256 = "0bc37b4e8bd039208a126fea39850c99459265cb273ac7237939cdbaee6ef71f"; + libDir = "share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.ghc.version}/ghcjs"; + ghcjsBoot = fetchgit { + url = git://github.com/ghcjs/ghcjs-boot.git; + rev = "8bf2861c0c776eec42e0a1833f220e36681e810c"; + sha256 = "0fwnng56d1y98fpp2s9yl9xy21584p7fsszr4m9d3wmjciiazcv2"; }; shims = fetchgit { url = git://github.com/ghcjs/shims.git; rev = "5e11d33cb74f8522efca0ace8365c0dc994b10f6"; - sha256 = "64be139022e6f662086103fca3838330006d38e6454bd3f7b66013031a47278e"; + sha256 = "13i78wd064v0nvvx6js5wqw6s01hhf1s7z03c4465xp64a817gk4"; }; - isLibrary = true; - isExecutable = true; - jailbreak = true; - noHaddock = true; - doCheck = false; ghcjsPrim = cabal.mkDerivation (self: { pname = "ghcjs-prim"; version = "0.1.0.0"; src = fetchgit { url = git://github.com/ghcjs/ghcjs-prim.git; rev = "915f263c06b7f4a246c6e02ecdf2b9a0550ed967"; - sha256 = "34dd58b6e2d0ce780da46b509fc2701c28a7b2182f8d700b53a80981ac8bcf86"; + sha256 = "11ngifn822d8ac5p139g32rafa0wf319yl3blh6piknhwav5ip9l"; }; 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 = [ filepath HTTP mtl network random stm time zlib aeson attoparsec bzlib dataDefault ghcPaths hashable haskellSrcExts haskellSrcMeta @@ -53,30 +62,32 @@ cabal.mkDerivation (self: rec { testDepends = [ HUnit 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 + patches = [ ./ghcjs.patch ]; + postPatch = '' + substituteInPlace Setup.hs --replace "/usr/bin/env" "${coreutils}/bin/env" + substituteInPlace src/Compiler/Info.hs --replace "@PREFIX@" "$out" + substituteInPlace src-bin/Boot.hs --replace "@PREFIX@" "$out" ''; - libdir = "/share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.ghc.version}"; postInstall = '' - export HOME=$(pwd) - export GIT_SSL_CAINFO="${cacert}/etc/ca-bundle.crt" - git clone git://github.com/ghcjs/ghcjs-boot.git - cd ghcjs-boot - git checkout 8bf2861c0c776eec42e0a1833f220e36681e810c - git submodule update --init --recursive - ( cd boot ; chmod u+w . ; ln -s .. ghcjs-boot ) - chmod -R u+w . # because fetchgit made it read-only - local GHCJS_LIBDIR=$out${libdir} - mkdir -p $GHCJS_LIBDIR - cp -R ${shims} $GHCJS_LIBDIR/shims - ${cabalInstallGhcjs}/bin/cabal-js update + local topDir=$out/${libDir} + 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 + 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 = { homepage = "https://github.com/ghcjs/ghcjs"; description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API"; diff --git a/pkgs/development/tools/haskell/ghcjs/ghcjs.patch b/pkgs/development/tools/haskell/ghcjs/ghcjs.patch new file mode 100644 index 000000000000..053480b9bfdb --- /dev/null +++ b/pkgs/development/tools/haskell/ghcjs/ghcjs.patch @@ -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 |