mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
gnu: ghc-9.2: Make Cabal respect GHC_PACKAGE_PATH
**tl;dr** Applying this patch makes Cabal work in Guix environments and ensures that Cabal picks up Haskell packages installed via Guix. Guix makes heavy use of GHC_PACKAGE_PATH to make GHC pickup Haskell packages installed via the Guix package manager. The environment variable is set using native-search-paths from the GHC packages. Unfortunately, upstream Cabal does presently not respect GHC_PACKAGE_PATH. If this environment variable is set, `cabal build` and other commands will terminate. For building packages, Guix does not make much use of cabal-install hence this is not as big of an issue. However, cabal-install does therefore presently not work out-of-the-box in environments created by Guix. For example, in `guix shell` environments. This makes it essentially impossible to use Guix for setting up development environments for Haskell software. Cabal upstream is aware of this issue and a patch exists to workaround this problem. The patch is currently not merged upstream due to issues related to reconfiguration (changing GHC_PACKAGE_PATH between `cabal configure` and `cabal build`). However, I would argue that this edge case is not that relevant for Guix and therefore propose including this patch with the Cabal Guix package. As outlined above, cabal-install is not usable by default presently, and I would therefore argue that this is a major improvement over the current situation. I am willing to work with Cabal upstream to have this issue fixed upstream eventually. Note that this requires patching the GHC package instead of the cabal-install package as Guix uses the version of the Cabal package <https://hackage.haskell.org/package/Cabal> distributed with GHC. See: https://github.com/haskell/cabal/issues/3728 * gnu/packages/haskell-apps.scm (cabal-install): Include patch to support the GHC_PACKAGE_PATH environment variable. Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> Signed-off-by: Lars-Dominik Braun <lars@6xq.net> Change-Id: Ib77ffa937b878690d0e2d8964b534842b99da039
This commit is contained in:
parent
208c2d63bb
commit
9236047476
3 changed files with 70 additions and 1 deletions
|
@ -1330,6 +1330,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/geoclue-config.patch \
|
||||
%D%/packages/patches/gettext-libunicode-update.patch \
|
||||
%D%/packages/patches/ghc-8.0-fall-back-to-madv_dontneed.patch \
|
||||
%D%/packages/patches/ghc-9.2-cabal-support-package-path.patch \
|
||||
%D%/packages/patches/ghc-9.2-glibc-2.33-link-order.patch \
|
||||
%D%/packages/patches/ghc-9.2-grep-warnings.patch \
|
||||
%D%/packages/patches/ghc-testsuite-dlopen-pie.patch \
|
||||
|
|
|
@ -1444,7 +1444,8 @@ (define-public ghc-9.2
|
|||
(sha256
|
||||
(base32
|
||||
"07028i0hm74svvq9b3jpkczaj6lsdgn3hgr4wa7diqiq3dypj1h6"))
|
||||
(patches (search-patches "ghc-9.2-glibc-2.33-link-order.patch"))))
|
||||
(patches (search-patches "ghc-9.2-glibc-2.33-link-order.patch"
|
||||
"ghc-9.2-cabal-support-package-path.patch"))))
|
||||
(arguments
|
||||
(substitute-keyword-arguments (package-arguments base)
|
||||
((#:phases phases '%standard-phases)
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
Without this patch, Cabal terminates if GHC_PACKAGE_PATH is set. This is
|
||||
an annoyance with Guix as it makes heavy use of GHC_PACKAGE_PATH to have
|
||||
GHC pickup Haskell package installed via Guix. Therefore, Cabal does
|
||||
presently not work by default in environments created by Guix. This is
|
||||
a workaround which makes Cabal respect GHC_PACKAGE_PATH.
|
||||
|
||||
Taken from https://github.com/haskell/cabal/issues/3728
|
||||
|
||||
diff -upr a/libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs b/libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs
|
||||
--- a/libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs 2022-11-06 20:41:17.000000000 +0100
|
||||
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs 2023-12-18 14:34:15.148911717 +0100
|
||||
@@ -71,6 +71,7 @@ module Distribution.Simple.GHC (
|
||||
) where
|
||||
|
||||
import Prelude ()
|
||||
+import Distribution.Compat.Environment (lookupEnv)
|
||||
import Distribution.Compat.Prelude
|
||||
|
||||
import qualified Distribution.Simple.GHC.Internal as Internal
|
||||
@@ -117,7 +118,7 @@ import System.Directory
|
||||
, canonicalizePath, removeFile, renameFile, getDirectoryContents )
|
||||
import System.FilePath ( (</>), (<.>), takeExtension
|
||||
, takeDirectory, replaceExtension
|
||||
- ,isRelative )
|
||||
+ , isRelative, searchPathSeparator )
|
||||
import qualified System.Info
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix (createSymbolicLink)
|
||||
@@ -333,9 +334,11 @@ getInstalledPackages :: Verbosity -> Com
|
||||
-> ProgramDb
|
||||
-> IO InstalledPackageIndex
|
||||
getInstalledPackages verbosity comp packagedbs progdb = do
|
||||
- checkPackageDbEnvVar verbosity
|
||||
checkPackageDbStack verbosity comp packagedbs
|
||||
- pkgss <- getInstalledPackages' verbosity packagedbs progdb
|
||||
+ envPackageDBs <-
|
||||
+ maybe [] (map SpecificPackageDB . unintersperse searchPathSeparator)
|
||||
+ <$> lookupEnv "GHC_PACKAGE_PATH"
|
||||
+ pkgss <- getInstalledPackages' verbosity (envPackageDBs ++ packagedbs) progdb
|
||||
index <- toPackageIndex verbosity pkgss progdb
|
||||
return $! hackRtsPackage index
|
||||
|
||||
@@ -405,10 +408,6 @@ getUserPackageDB _verbosity ghcProg plat
|
||||
packageConfFileName = "package.conf.d"
|
||||
ghcVersion = fromMaybe (error "GHC.getUserPackageDB: no ghc version") $ programVersion ghcProg
|
||||
|
||||
-checkPackageDbEnvVar :: Verbosity -> IO ()
|
||||
-checkPackageDbEnvVar verbosity =
|
||||
- Internal.checkPackageDbEnvVar verbosity "GHC" "GHC_PACKAGE_PATH"
|
||||
-
|
||||
checkPackageDbStack :: Verbosity -> Compiler -> PackageDBStack -> IO ()
|
||||
checkPackageDbStack verbosity comp =
|
||||
if flagPackageConf implInfo
|
||||
@@ -461,8 +460,11 @@ getInstalledPackagesMonitorFiles :: Verb
|
||||
-> ProgramDb
|
||||
-> [PackageDB]
|
||||
-> IO [FilePath]
|
||||
-getInstalledPackagesMonitorFiles verbosity platform progdb =
|
||||
- traverse getPackageDBPath
|
||||
+getInstalledPackagesMonitorFiles verbosity platform progdb packageDBs = do
|
||||
+ envPackageDBs <-
|
||||
+ maybe [] (map SpecificPackageDB . unintersperse searchPathSeparator)
|
||||
+ <$> lookupEnv "GHC_PACKAGE_PATH"
|
||||
+ traverse getPackageDBPath (envPackageDBs ++ packageDBs)
|
||||
where
|
||||
getPackageDBPath :: PackageDB -> IO FilePath
|
||||
getPackageDBPath GlobalPackageDB =
|
Loading…
Reference in a new issue