mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 07:46:09 +01:00
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.
This commit is contained in:
parent
e89aea5e42
commit
d068aa9861
3 changed files with 39 additions and 1 deletions
|
@ -79,7 +79,12 @@ stdenv.mkDerivation rec {
|
|||
echo -n "Generating wrappers "
|
||||
|
||||
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "-B$linkedTopDir"
|
||||
# The NIX env-vars are picked up by our patched version of ghc-paths.
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
||||
--add-flags "-B$linkedTopDir" \
|
||||
--set "NIX_GHC" "$out/bin/ghc" \
|
||||
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
||||
--set "NIX_GHC_LIBDIR" "$linkedTopDir"
|
||||
echo -n .
|
||||
done
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ cabal.mkDerivation (self: {
|
|||
pname = "ghc-paths";
|
||||
version = "0.1.0.9";
|
||||
sha256 = "0ibrr1dxa35xx20cpp8jzgfak1rdmy344dfwq4vlq013c6w8z9mg";
|
||||
patches = [ ./ghc-paths-nix.patch ];
|
||||
meta = {
|
||||
description = "Knowledge of GHC's installation directories";
|
||||
license = self.stdenv.lib.licenses.bsd3;
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue