lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+125 -46
+9 -8
pkgs/development/compilers/ghcjs/default.nix
··· 39 39 }: 40 40 let 41 41 version = "0.1.0"; 42 - ghcArch = if pkgs.stdenv.system == "i686-linux" 43 - then "i386-linux" 44 - else pkgs.stdenv.system; 45 - libDir = "share/ghcjs/${ghcArch}-${version}-${ghc.version}/ghcjs"; 46 42 ghcjsBoot = fetchgit { 47 43 url = git://github.com/ghcjs/ghcjs-boot.git; 48 44 rev = "ab8765edcb507b8b810e3c324fd5bd5af2b69d8f"; # 7.10 branch ··· 84 80 ]; 85 81 patches = [ ./ghcjs.patch ]; 86 82 postPatch = '' 87 - substituteInPlace Setup.hs --replace "/usr/bin/env" "${coreutils}/bin/env" 88 - substituteInPlace src/Compiler/Info.hs --replace "@PREFIX@" "$out" 83 + substituteInPlace Setup.hs \ 84 + --replace "/usr/bin/env" "${coreutils}/bin/env" 85 + 86 + substituteInPlace src/Compiler/Info.hs \ 87 + --replace "@PREFIX@" "$out" \ 88 + --replace "@VERSION@" "${version}" 89 + 89 90 substituteInPlace src-bin/Boot.hs \ 90 91 --replace "@PREFIX@" "$out" \ 91 92 --replace "@CC@" "${stdenv.cc}/bin/cc" 92 93 ''; 93 94 preBuild = '' 94 - local topDir=$out/${libDir} 95 + local topDir=$out/lib/ghcjs-${version} 95 96 mkdir -p $topDir 96 97 97 98 cp -r ${ghcjsBoot} $topDir/ghcjs-boot ··· 116 117 --with-gmp-libraries ${gmp}/lib 117 118 ''; 118 119 passthru = { 119 - inherit libDir; 120 120 isGhcjs = true; 121 121 nativeGhc = ghc; 122 + inherit nodejs; 122 123 }; 123 124 124 125 homepage = "https://github.com/ghcjs/ghcjs";
+13 -7
pkgs/development/compilers/ghcjs/ghcjs.patch
··· 60 60 , "--haddock-html" 61 61 -- workaround for hoogle support being broken in haddock for GHC 7.10RC1 62 62 diff --git a/src/Compiler/Info.hs b/src/Compiler/Info.hs 63 - index 33a401f..5d09c86 100644 63 + index 33a401f..79833c5 100644 64 64 --- a/src/Compiler/Info.hs 65 65 +++ b/src/Compiler/Info.hs 66 - @@ -49,7 +49,7 @@ compilerInfo nativeToo dflags = do 66 + @@ -48,13 +48,7 @@ compilerInfo nativeToo dflags = do 67 + 67 68 -- | the directory to use if started without -B flag 68 69 getDefaultTopDir :: IO FilePath 69 - getDefaultTopDir = do 70 + -getDefaultTopDir = do 70 71 - appdir <- getAppUserDataDirectory "ghcjs" 71 - + let appdir = "@PREFIX@/share/ghcjs" 72 - return (appdir </> subdir </> "ghcjs") 73 - where 74 - targetARCH = arch 72 + - return (appdir </> subdir </> "ghcjs") 73 + - where 74 + - targetARCH = arch 75 + - targetOS = os 76 + - subdir = targetARCH ++ '-':targetOS ++ '-':getFullCompilerVersion 77 + +getDefaultTopDir = return "@PREFIX@/lib/ghcjs-@VERSION@" 78 + 79 + getDefaultLibDir :: IO FilePath 80 + getDefaultLibDir = getDefaultTopDir
+4
pkgs/development/haskell-modules/configuration-ghcjs.nix
··· 99 99 buildDepends = [ self.base self.mtl self.text self.ghcjs-base ]; 100 100 }); 101 101 102 + ghc-paths = overrideCabal super.ghc-paths (drv: { 103 + patches = [ ./ghc-paths-nix-ghcjs.patch ]; 104 + }); 105 + 102 106 }
+9 -9
pkgs/development/haskell-modules/generic-builder.nix
··· 114 114 115 115 ghcEnv = ghc.withPackages (p: haskellBuildInputs); 116 116 117 - setupBuilder = if isGhcjs then "${ghc.nativeGhc}/bin/ghc" else "ghc"; 117 + setupCommand = if isGhcjs then "${ghc.nodejs}/bin/node ./Setup.jsexe/all.js" else "./Setup"; 118 118 ghcCommand = if isGhcjs then "ghcjs" else "ghc"; 119 119 120 120 in ··· 186 186 done 187 187 188 188 echo setupCompileFlags: $setupCompileFlags 189 - ${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 189 + ${ghcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 190 190 191 191 runHook postCompileBuildDriver 192 192 ''; ··· 197 197 unset GHC_PACKAGE_PATH # Cabal complains if this variable is set during configure. 198 198 199 199 echo configureFlags: $configureFlags 200 - ./Setup configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log" 200 + ${setupCommand} configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log" 201 201 if ${gnugrep}/bin/egrep -q '^Warning:.*depends on multiple versions' "$NIX_BUILD_TOP/cabal-configure.log"; then 202 202 echo >&2 "*** abort because of serious configure-time warning from Cabal" 203 203 exit 1 ··· 210 210 211 211 buildPhase = '' 212 212 runHook preBuild 213 - ./Setup build ${buildTarget} 213 + ${setupCommand} build ${buildTarget} 214 214 runHook postBuild 215 215 ''; 216 216 217 217 checkPhase = '' 218 218 runHook preCheck 219 - ./Setup test ${testTarget} 219 + ${setupCommand} test ${testTarget} 220 220 runHook postCheck 221 221 ''; 222 222 223 223 haddockPhase = '' 224 224 runHook preHaddock 225 225 ${optionalString (doHaddock && hasActiveLibrary) '' 226 - ./Setup haddock --html \ 226 + ${setupCommand} haddock --html \ 227 227 ${optionalString doHoogle "--hoogle"} \ 228 228 ${optionalString (hasActiveLibrary && hyperlinkSource) "--hyperlink-source"} 229 229 ''} ··· 233 233 installPhase = '' 234 234 runHook preInstall 235 235 236 - ${if !hasActiveLibrary then "./Setup install" else '' 237 - ./Setup copy 236 + ${if !hasActiveLibrary then "${setupCommand} install" else '' 237 + ${setupCommand} copy 238 238 local packageConfDir="$out/lib/${ghc.name}/package.conf.d" 239 239 local packageConfFile="$packageConfDir/${pname}-${version}.conf" 240 240 mkdir -p "$packageConfDir" 241 - ./Setup register --gen-pkg-config=$packageConfFile 241 + ${setupCommand} register --gen-pkg-config=$packageConfFile 242 242 local pkgId=$( ${gnused}/bin/sed -n -e 's|^id: ||p' $packageConfFile ) 243 243 mv $packageConfFile $packageConfDir/$pkgId.conf 244 244 ''}
+65
pkgs/development/haskell-modules/ghc-paths-nix-ghcjs.patch
··· 1 + diff --git a/GHC/Paths.hs b/GHC/Paths.hs 2 + index c87565d..88b3db4 100644 3 + --- a/GHC/Paths.hs 4 + +++ b/GHC/Paths.hs 5 + @@ -1,13 +1,35 @@ 6 + {-# LANGUAGE CPP #-} 7 + +{-# LANGUAGE ScopedTypeVariables #-} 8 + 9 + module GHC.Paths ( 10 + ghc, ghc_pkg, libdir, docdir 11 + ) where 12 + 13 + +import Control.Exception as E 14 + +import Data.Maybe 15 + +import System.Environment 16 + +import System.IO.Unsafe 17 + + 18 + +-- Yes, there's lookupEnv now, but we want to be compatible 19 + +-- with older GHCs. 20 + +checkEnv :: String -> IO (Maybe String) 21 + +checkEnv var = E.catch (fmap Just (getEnv var)) 22 + + (\ (e :: IOException) -> return Nothing) 23 + + 24 + +nixLibdir, nixDocdir, nixGhc, nixGhcPkg :: Maybe FilePath 25 + +nixLibdir = unsafePerformIO (checkEnv "NIX_GHCJS_LIBDIR") 26 + +nixDocdir = unsafePerformIO (checkEnv "NIX_GHCJS_DOCDIR") 27 + +nixGhc = unsafePerformIO (checkEnv "NIX_GHCJS") 28 + +nixGhcPkg = unsafePerformIO (checkEnv "NIX_GHCJSPKG") 29 + +{-# NOINLINE nixLibdir #-} 30 + +{-# NOINLINE nixDocdir #-} 31 + +{-# NOINLINE nixGhc #-} 32 + +{-# NOINLINE nixGhcPkg #-} 33 + + 34 + libdir, docdir, ghc, ghc_pkg :: FilePath 35 + 36 + -libdir = GHC_PATHS_LIBDIR 37 + -docdir = GHC_PATHS_DOCDIR 38 + +libdir = fromMaybe GHC_PATHS_LIBDIR nixLibdir 39 + +docdir = fromMaybe GHC_PATHS_DOCDIR nixDocdir 40 + 41 + -ghc = GHC_PATHS_GHC 42 + -ghc_pkg = GHC_PATHS_GHC_PKG 43 + +ghc = fromMaybe GHC_PATHS_GHC nixGhc 44 + +ghc_pkg = fromMaybe GHC_PATHS_GHC_PKG nixGhcPkg 45 + diff --git a/Setup.hs b/Setup.hs 46 + index fad5026..1651650 100644 47 + --- a/Setup.hs 48 + +++ b/Setup.hs 49 + @@ -27,13 +27,13 @@ main = defaultMainWithHooks simpleUserHooks { 50 + defaultPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO () 51 + defaultPostConf args flags pkgdescr lbi = do 52 + libdir_ <- rawSystemProgramStdoutConf (fromFlag (configVerbosity flags)) 53 + - ghcProgram (withPrograms lbi) ["--print-libdir"] 54 + + ghcjsProgram (withPrograms lbi) ["--print-libdir"] 55 + let libdir = reverse $ dropWhile isSpace $ reverse libdir_ 56 + 57 + - ghc_pkg = case lookupProgram ghcPkgProgram (withPrograms lbi) of 58 + + ghc_pkg = case lookupProgram ghcjsPkgProgram (withPrograms lbi) of 59 + Just p -> programPath p 60 + Nothing -> error "ghc-pkg was not found" 61 + - ghc = case lookupProgram ghcProgram (withPrograms lbi) of 62 + + ghc = case lookupProgram ghcjsProgram (withPrograms lbi) of 63 + Just p -> programPath p 64 + Nothing -> error "ghc was not found" 65 +
+25 -22
pkgs/development/haskell-modules/with-packages-wrapper.nix
··· 32 32 ghc761OrLater = isGhcjs || lib.versionOlder "7.6.1" ghc.version; 33 33 packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf"; 34 34 ghcCommand = if isGhcjs then "ghcjs" else "ghc"; 35 + ghcCommandCaps= lib.toUpper ghcCommand; 35 36 libDir = "$out/lib/${ghcCommand}-${ghc.version}"; 36 37 docDir = "$out/share/doc/ghc/html"; 37 38 packageCfgDir = "${libDir}/package.conf.d"; ··· 51 52 postBuild = '' 52 53 . ${makeWrapper}/nix-support/setup-hook 53 54 54 - ${lib.optionalString isGhcjs '' 55 - cp -r "${ghc}/${ghc.libDir}/"* ${libDir}/ 56 - ''} 57 - 58 55 if test -L "$out/bin"; then 59 56 binTarget="$(readlink -f "$out/bin")" 60 57 rm "$out/bin" ··· 62 59 chmod u+w "$out/bin" 63 60 fi 64 61 65 - for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do 66 - rm -f $out/bin/$prg 67 - makeWrapper ${ghc}/bin/$prg $out/bin/$prg \ 68 - --add-flags '"-B$NIX_GHC_LIBDIR"' \ 69 - --set "NIX_GHC" "$out/bin/${ghcCommand}" \ 70 - --set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \ 71 - --set "NIX_GHC_DOCDIR" "${docDir}" \ 72 - --set "NIX_GHC_LIBDIR" "${libDir}" \ 73 - ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''} 62 + for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do 63 + if [[ -x "${ghc}/bin/$prg" ]]; then 64 + rm -f $out/bin/$prg 65 + makeWrapper ${ghc}/bin/$prg $out/bin/$prg \ 66 + --add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \ 67 + --set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \ 68 + --set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \ 69 + --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \ 70 + --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}" \ 71 + ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''} 72 + fi 74 73 done 75 74 76 75 for prg in runghc runhaskell; do 77 - rm -f $out/bin/$prg 78 - makeWrapper ${ghc}/bin/$prg $out/bin/$prg \ 79 - --add-flags "-f $out/bin/ghc" \ 80 - --set "NIX_GHC" "$out/bin/${ghcCommand}" \ 81 - --set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \ 82 - --set "NIX_GHC_DOCDIR" "${docDir}" \ 83 - --set "NIX_GHC_LIBDIR" "${libDir}" 76 + if [[ -x "${ghc}/bin/$prg" ]]; then 77 + rm -f $out/bin/$prg 78 + makeWrapper ${ghc}/bin/$prg $out/bin/$prg \ 79 + --add-flags "-f $out/bin/${ghcCommand}" \ 80 + --set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \ 81 + --set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \ 82 + --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \ 83 + --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}" 84 + fi 84 85 done 85 86 86 87 for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do 87 - rm -f $out/bin/$prg 88 - makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" 88 + if [[ -x "${ghc}/bin/$prg" ]]; then 89 + rm -f $out/bin/$prg 90 + makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" 91 + fi 89 92 done 90 93 91 94 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}