From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id iF7RJJ1rgWXA9gAAkFu2QA (envelope-from ) for ; Tue, 19 Dec 2023 11:08:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id mLKpH51rgWUoIwEA62LTzQ (envelope-from ) for ; Tue, 19 Dec 2023 11:08:29 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=Mv4HT8KG; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1702980509; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Q/SBWhKhi9hanlDuSImaGKDGHlXJNF/ec6NwIOkywO8=; b=nYjez+FAnJY745suM2EZQ3Gi3Up6X+ANaT++eu7b1oWcdPhhukDkhGuWUAomXj/kfUKNy7 gjQCyz/TIAayXv+z0SXTgyqMt8iP4EQ1+8SWwQyBqhsMRhDvCLPMewdpUSbhd6Cr6xuIV0 Qf0dPBSfBUBP13yjKSDqwjt85RKP43m6C4DA3JF2SQAwvZJkqJmBnqE1DNgdXpGRHVj7ae cjAH5BNaj9UXNHCuAMNdLUELnLfGgpXEVaGo2djkP4pGkRc8fwVaKOrJZskzsX+HmvEEQF eWfA4CKpkWESJL7CHqtIPUb0GGA1smS6Ua80dsU2gRXbcNAeVjUZvpYBUkqMzg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702980509; a=rsa-sha256; cv=none; b=AUt0ltXcWofB3hiykVFgAXw8tjag9Rol8dQMShZPbNfwFCECqlz7x70oDgURF2jNdu4iXR NiCSmkWtPp7v48NHdRrQyOCMbRbEX5O+IigbTMLYKgQOY8dk08jjG0Vd5XPQB/+8E/JdJY XjBL60DKSWIn8RgR3qlxozVXr1bC5g/+l9W3VzFnCOVIs43dxCFXZ4ZJXLyc26ukCoG5Iz x0ewmCzCBnMgNRoh9KTH0IROUf/7ZOz+5hjHXqBviB/IhCDE1QBoN99BkUx2QK3QPhC9uc rX9dvlmLtA494xpQWkdT9V5RuevY+pkKtvzmkNnZHGQxSHVgxsWXcQ8NY6n6ew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=Mv4HT8KG; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 33CF855E15 for ; Tue, 19 Dec 2023 11:08:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFX1D-0004aI-Pk; Tue, 19 Dec 2023 05:08:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFX17-0004Zn-9q for guix-patches@gnu.org; Tue, 19 Dec 2023 05:08:01 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFX16-0000lD-RQ for guix-patches@gnu.org; Tue, 19 Dec 2023 05:08:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rFX18-0001yf-Iu; Tue, 19 Dec 2023 05:08:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67896] [PATCH] gnu: ghc-9.2: Make Cabal respect GHC_PACKAGE_PATH Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, guix-patches@gnu.org Resent-Date: Tue, 19 Dec 2023 10:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67896 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67896@debbugs.gnu.org Cc: Lars-Dominik Braun X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Lars-Dominik Braun Received: via spool by submit@debbugs.gnu.org id=B.17029804597515 (code B ref -1); Tue, 19 Dec 2023 10:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 19 Dec 2023 10:07:39 +0000 Received: from localhost ([127.0.0.1]:34446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFX0k-0001x6-Ua for submit@debbugs.gnu.org; Tue, 19 Dec 2023 05:07:39 -0500 Received: from lists.gnu.org ([2001:470:142::17]:45970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFX0j-0001wX-Dd for submit@debbugs.gnu.org; Tue, 19 Dec 2023 05:07:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFX0a-0004PC-1i for guix-patches@gnu.org; Tue, 19 Dec 2023 05:07:28 -0500 Received: from magnesium.8pit.net ([45.76.88.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFX0W-0000hg-VC; Tue, 19 Dec 2023 05:07:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=PkqmREvHFQ 7W7gPH+C1ClmUdCFZePLpPMjEwMGOtwI8=; h=date:subject:to:from; d=soeren-tempel.net; b=Mv4HT8KGl6v6nF5hpLeu9/DaNH6GmqFBZil8DOTvrvc0wBk 30KevrKz5UOYlTQt3L5aXaBWRjEAndRtarkQdEr1Fbjvbdh1bSBtORcxAlhKPsm1ncpVqe zizFnWQwCd7rO7sEvVO4qXbtLHSbq/XZZ0hQnNU0Rz/oAGQ8L/R62Y= Received: from localhost (dynamic-2a02-3102-49da-001b-34ef-c804-0250-115c.310.pool.telefonica.de [2a02:3102:49da:1b:34ef:c804:250:115c]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 5d9852b0 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Tue, 19 Dec 2023 11:07:17 +0100 (CET) From: soeren@soeren-tempel.net Date: Tue, 19 Dec 2023 11:05:32 +0100 Message-ID: <6fccf7c2e9095cb27cb93644f3bd4a92f4687d13.1702980332.git.soeren@soeren-tempel.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=45.76.88.171; envelope-from=soeren@soeren-tempel.net; helo=magnesium.8pit.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.09 X-Spam-Score: -4.09 X-Migadu-Queue-Id: 33CF855E15 X-Migadu-Scanner: mx11.migadu.com X-TUID: RaImoA2jw8ni From: Sören Tempel **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 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 --- gnu/packages/haskell.scm | 3 +- .../ghc-9.2-cabal-support-package-path.patch | 67 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/ghc-9.2-cabal-support-package-path.patch 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 = base-commit: 29c94dd522833b2603a651c14a5b06120bcf1829