Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch ghc-paths to interact better with ghcWithPackages.
When the ghc-paths library is compiled, the paths of the compiler it is compiled with are being hardcoded in the library (and can then be queried from other applications using the library). But on Nix, packages are compiled with ghc-wrapper, and subsequently possibly used with a special version of ghc generated for a particular environment of packages. So one version of ghc-paths may potentially end up being used by lots of different instances of ghc. The hardcoding approach fails. As a work-around, we now patch ghc-paths so that it allows setting the paths that can be queried via environment variables. Specific GHC environments can then set these environment variables in the wrapper shell script that invokes GHC. This should at least partially solve issue #213.
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
pkgs/development/libraries/haskell/ghc-paths/ghc-paths-nix.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff -Naur ghc-paths-0.1.0.9/GHC/Paths.hs ghc-paths-0.1.0.9-new/GHC/Paths.hs | ||
--- ghc-paths-0.1.0.9/GHC/Paths.hs 2012-12-16 13:53:45.720148396 +0100 | ||
+++ ghc-paths-0.1.0.9-new/GHC/Paths.hs 2012-12-16 13:51:50.073070123 +0100 | ||
@@ -4,10 +4,24 @@ | ||
ghc, ghc_pkg, libdir, docdir | ||
) where | ||
|
||
+import Data.Maybe | ||
+import System.Environment | ||
+import System.IO.Unsafe | ||
+ | ||
+nixLibdir, nixDocdir, nixGhc, nixGhcPkg :: Maybe FilePath | ||
+nixLibdir = unsafePerformIO (lookupEnv "NIX_GHC_LIBDIR") | ||
+nixDocdir = unsafePerformIO (lookupEnv "NIX_GHC_DOCDIR") | ||
+nixGhc = unsafePerformIO (lookupEnv "NIX_GHC") | ||
+nixGhcPkg = unsafePerformIO (lookupEnv "NIX_GHCPKG") | ||
+{-# 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 |
d068aa9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technical problem: "GHC/Paths.hs:12:30: Not in scope: `lookupEnv'"