Message ID | 6fccf7c2e9095cb27cb93644f3bd4a92f4687d13.1702980332.git.soeren@soeren-tempel.net |
---|---|
State | New |
Headers | show |
Series | [bug#67896] gnu: ghc-9.2: Make Cabal respect GHC_PACKAGE_PATH | expand |
If we don't want to patch the vendored Cabal version shipped by GHC itself, we could also explore packaging Cabal separately and making cabal-install depend on that. However, given that Setup.hs also uses Distribution.Simple and that there are several places in Guix itself where we need to unset GHC_PACKAGE_PATH atm, I personally believe it to be preferable to fix the vendored version. Lars, what do you think? Greetings Sören
Hi, sorry for the delay, I just tried your patch and it works well combining a local cabal project and libraries/GHC from Guix. I’d say this is a massive improvement, so I’d like to ship it with Guix. However this is a world rebuilding change, so I’ll push it to the haskell-team branch and probably wait for #67921 to be ready before it can hit master. One minor issue: If you add a patch file, also add it to gnu/local.mk. > However, given that Setup.hs also uses > Distribution.Simple and that there are several places in Guix itself > where we need to unset GHC_PACKAGE_PATH atm, I personally believe it > to be preferable to fix the vendored version. Which locations are you referring to? Cheers, Lars
Hi, Lars-Dominik Braun <lars@6xq.net> wrote: > sorry for the delay, I just tried your patch and it works well combining > a local cabal project and libraries/GHC from Guix. I’d say this is a > massive improvement, so I’d like to ship it with Guix. However this > is a world rebuilding change, so I’ll push it to the haskell-team > branch and probably wait for #67921 to be ready before it can hit master. Yea, glad to hear that. Waiting for #67921 is fine by me. Should I also prepare a patch for the GHC 9.4 package then? Currently this is only GHC 9.2. > One minor issue: If you add a patch file, also add it to gnu/local.mk. Oh, I wasn't aware. Thanks for pointing that out, will keep it in mind for future patches! > > However, given that Setup.hs also uses > > Distribution.Simple and that there are several places in Guix itself > > where we need to unset GHC_PACKAGE_PATH atm, I personally believe it > > to be preferable to fix the vendored version. > > Which locations are you referring to? I just grep'ed for GHC_PACKAGE_PATH, e.g.: * https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/virtualization.scm#n784 * https://git.savannah.gnu.org/cgit/guix.git/tree/guix/build/haskell-build-system.scm#n111 * https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/haskell.scm#n963 Greetings Sören
Hi, > Yea, glad to hear that. Waiting for #67921 is fine by me. Should I also > prepare a patch for the GHC 9.4 package then? Currently this is only GHC > 9.2. as far as I see 9.4 inherits from 9.2 and thus this patch should be applied automatically. > I just grep'ed for GHC_PACKAGE_PATH, e.g.: > > * https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/virtualization.scm#n784 > * https://git.savannah.gnu.org/cgit/guix.git/tree/guix/build/haskell-build-system.scm#n111 > * https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/haskell.scm#n963 Ah, I see. I’ll check whether this is still necessary. Cheers, Lars
> Hi, > > Lars-Dominik Braun <lars@6xq.net> wrote: > > sorry for the delay, I just tried your patch and it works well combining > > a local cabal project and libraries/GHC from Guix. I’d say this is a > > massive improvement, so I’d like to ship it with Guix. However this > > is a world rebuilding change, so I’ll push it to the haskell-team > > branch and probably wait for #67921 to be ready before it can hit master. > > Yea, glad to hear that. Waiting for #67921 is fine by me. Should I also > prepare a patch for the GHC 9.4 package then? Currently this is only GHC > 9.2. I'm currently trying to update GHC to 9.6 in that series (there are some weird issues when running the test suite). If the same cabal patch works with GHC 9.6 I can add the reference to it in the package definition (same with 9.4). Otherwise a patch for those versions would be nice.
I just tested this, the patch applies cleanly for both GHC 9.4.8 and 9.6.3. Saku Laesvuori <saku@laesvuori.fi> wrote: > > Hi, > > > > Lars-Dominik Braun <lars@6xq.net> wrote: > > > sorry for the delay, I just tried your patch and it works well combining > > > a local cabal project and libraries/GHC from Guix. I’d say this is a > > > massive improvement, so I’d like to ship it with Guix. However this > > > is a world rebuilding change, so I’ll push it to the haskell-team > > > branch and probably wait for #67921 to be ready before it can hit master. > > > > Yea, glad to hear that. Waiting for #67921 is fine by me. Should I also > > prepare a patch for the GHC 9.4 package then? Currently this is only GHC > > 9.2. > > I'm currently trying to update GHC to 9.6 in that series (there are some > weird issues when running the test suite). If the same cabal patch works > with GHC 9.6 I can add the reference to it in the package definition > (same with 9.4). Otherwise a patch for those versions would be nice.
diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm index 62815efbb1..0cd0734d6d 100644 --- a/gnu/packages/haskell.scm +++ b/gnu/packages/haskell.scm @@ -1348,7 +1348,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) diff --git a/gnu/packages/patches/ghc-9.2-cabal-support-package-path.patch b/gnu/packages/patches/ghc-9.2-cabal-support-package-path.patch new file mode 100644 index 0000000000..9e4c405c50 --- /dev/null +++ b/gnu/packages/patches/ghc-9.2-cabal-support-package-path.patch @@ -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 =