about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch
diff options
context:
space:
mode:
authorobadz <dav-github@odav.org>2015-08-05 20:48:18 +0100
committerobadz <dav-github@odav.org>2015-08-06 11:14:05 +0100
commit3801ef59127330d30f98ff3af3e04e7ac790722e (patch)
tree1085c539bb6dd90ace1536ac2e8a516b9a4d64ab /pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch
parent23f5a23ec7251a54918d00aa996bfffcb6b72d3b (diff)
downloadnixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar.gz
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar.bz2
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar.lz
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar.xz
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.tar.zst
nixlib-3801ef59127330d30f98ff3af3e04e7ac790722e.zip
haskell: move patches to patches directory
Diffstat (limited to 'pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch')
-rw-r--r--pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch b/pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch
new file mode 100644
index 000000000000..26ea0eaa5a8b
--- /dev/null
+++ b/pkgs/development/haskell-modules/patches/ghc-paths-nix-ghcjs.patch
@@ -0,0 +1,65 @@
+diff --git a/GHC/Paths.hs b/GHC/Paths.hs
+index c87565d..88b3db4 100644
+--- a/GHC/Paths.hs
++++ b/GHC/Paths.hs
+@@ -1,13 +1,35 @@
+ {-# LANGUAGE CPP #-}
++{-# LANGUAGE ScopedTypeVariables #-}
+ 
+ module GHC.Paths (
+         ghc, ghc_pkg, libdir, docdir
+   ) where
+ 
++import Control.Exception as E
++import Data.Maybe
++import System.Environment
++import System.IO.Unsafe
++
++-- Yes, there's lookupEnv now, but we want to be compatible
++-- with older GHCs.
++checkEnv :: String -> IO (Maybe String)
++checkEnv var = E.catch (fmap Just (getEnv var))
++                       (\ (e :: IOException) -> return Nothing)
++
++nixLibdir, nixDocdir, nixGhc, nixGhcPkg :: Maybe FilePath
++nixLibdir = unsafePerformIO (checkEnv "NIX_GHCJS_LIBDIR")
++nixDocdir = unsafePerformIO (checkEnv "NIX_GHCJS_DOCDIR")
++nixGhc    = unsafePerformIO (checkEnv "NIX_GHCJS")
++nixGhcPkg = unsafePerformIO (checkEnv "NIX_GHCJSPKG")
++{-# NOINLINE nixLibdir #-}
++{-# NOINLINE nixDocdir #-}
++{-# NOINLINE nixGhc    #-}
++{-# NOINLINE nixGhcPkg #-}
++
+ libdir, docdir, ghc, ghc_pkg :: FilePath
+ 
+-libdir  = GHC_PATHS_LIBDIR
+-docdir  = GHC_PATHS_DOCDIR
++libdir  = fromMaybe GHC_PATHS_LIBDIR  nixLibdir
++docdir  = fromMaybe GHC_PATHS_DOCDIR  nixDocdir
+ 
+-ghc     = GHC_PATHS_GHC
+-ghc_pkg = GHC_PATHS_GHC_PKG
++ghc     = fromMaybe GHC_PATHS_GHC     nixGhc
++ghc_pkg = fromMaybe GHC_PATHS_GHC_PKG nixGhcPkg
+diff --git a/Setup.hs b/Setup.hs
+index fad5026..1651650 100644
+--- a/Setup.hs
++++ b/Setup.hs
+@@ -27,13 +27,13 @@ main = defaultMainWithHooks simpleUserHooks {
+     defaultPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
+     defaultPostConf args flags pkgdescr lbi = do
+       libdir_ <- rawSystemProgramStdoutConf (fromFlag (configVerbosity flags))
+-                     ghcProgram (withPrograms lbi) ["--print-libdir"]
++                     ghcjsProgram (withPrograms lbi) ["--print-libdir"]
+       let libdir = reverse $ dropWhile isSpace $ reverse libdir_
+ 
+-          ghc_pkg = case lookupProgram ghcPkgProgram (withPrograms lbi) of
++          ghc_pkg = case lookupProgram ghcjsPkgProgram (withPrograms lbi) of
+                           Just p  -> programPath p
+                           Nothing -> error "ghc-pkg was not found"
+-          ghc     = case lookupProgram ghcProgram (withPrograms lbi) of
++          ghc     = case lookupProgram ghcjsProgram (withPrograms lbi) of
+                           Just p  -> programPath p
+                           Nothing -> error "ghc was not found"
+