From 4d78cbec6e57dab65d336f608d55c93eb09e04cc Mon Sep 17 00:00:00 2001 From: mat ess Date: Fri, 29 Jul 2022 17:41:12 -0400 Subject: [PATCH 1/7] Add cabal-paths patch for ghc 9.2.4 --- pkgs/development/compilers/ghc/9.2.4.nix | 9 + .../compilers/ghc/cabal-paths-9.2.3.patch | 182 ++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch diff --git a/pkgs/development/compilers/ghc/9.2.4.nix b/pkgs/development/compilers/ghc/9.2.4.nix index 6b8efae06e5b1..ee2c72b1fa38e 100644 --- a/pkgs/development/compilers/ghc/9.2.4.nix +++ b/pkgs/development/compilers/ghc/9.2.4.nix @@ -203,6 +203,15 @@ stdenv.mkDerivation (rec { extraPrefix = "libraries/Cabal/"; sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY="; }) + ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ + + # Prevent the paths module from emitting symbols that we don't use + # when building with separate outputs. + # + # These cause problems as they're not eliminated by GHC's dead code + # elimination on aarch64-darwin. (see + # https://github.com/NixOS/nixpkgs/issues/140774 for details). + ./cabal-paths-9.2.3.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch b/pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch new file mode 100644 index 0000000000000..d59d206ead0c5 --- /dev/null +++ b/pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch @@ -0,0 +1,182 @@ +diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs +index b2be7e1a8..bf218dbc1 100644 +--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs ++++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs +@@ -25,16 +25,21 @@ import Distribution.Package + import Distribution.PackageDescription + import Distribution.Simple.Compiler + import Distribution.Simple.LocalBuildInfo +-import Distribution.Simple.Utils (shortRelativePath) ++import Distribution.Simple.Utils (shortRelativePath, unintersperse) + import Distribution.System + import Distribution.Version + + import qualified Distribution.Simple.Build.PathsModule.Z as Z + ++import System.FilePath ( pathSeparator ) ++ + -- ------------------------------------------------------------ + -- * Building Paths_.hs + -- ------------------------------------------------------------ + ++splitPath :: FilePath -> [ String ] ++splitPath = unintersperse pathSeparator ++ + generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String + generatePathsModule pkg_descr lbi clbi = Z.render Z.Z + { Z.zPackageName = packageName pkg_descr +@@ -56,8 +61,41 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z + , Z.zDatadir = zDatadir + , Z.zLibexecdir = zLibexecdir + , Z.zSysconfdir = zSysconfdir ++ ++ , Z.zAbsBody = absBody ++ , Z.zWarnPragma = warnPragma ++ , Z.zImportList = importList ++ , Z.zShouldEmitDataDir = shouldEmitDataDir + } + where ++ dirs = [ (flat_libdir, "LibDir") ++ , (flat_dynlibdir, "DynLibDir") ++ , (flat_datadir, "DataDir") ++ , (flat_libexecdir, "LibexecDir") ++ , (flat_sysconfdir, "SysconfDir") ]; ++ shouldEmitPath p ++ | (splitPath flat_prefix) `isPrefixOf` (splitPath flat_bindir) = True ++ | (splitPath flat_prefix) `isPrefixOf` (splitPath p) = False ++ | otherwise = True ++ shouldEmitDataDir = shouldEmitPath flat_datadir ++ nixEmitPathFn (path, name) = let ++ varName = toLower <$> name ++ fnName = "get"++name ++ in if shouldEmitPath path then ++ varName ++ " :: FilePath\n"++ ++ varName ++ " = " ++ show path ++ ++ "\n" ++ fnName ++ " :: IO FilePath" ++ ++ "\n" ++ fnName ++ " = " ++ mkGetEnvOr varName ("return " ++ varName)++"\n" ++ else "" ++ mkGetEnvOr var expr = "catchIO (getEnv \""++var'++"\") (\\_ -> "++expr++")" ++ where var' = pkgPathEnvVar pkg_descr var ++ absBody = intercalate "\n" $ nixEmitPathFn <$> dirs ++ warnPragma = case filter (not . shouldEmitPath . fst) dirs of ++ [] -> "" ++ omittedDirs -> "{-# WARNING \"The functions: "++omittedFns++" Have been omitted by the Nix build system.\" #-}" ++ where omittedFns = intercalate ", " $ map snd omittedDirs ++ importList = intercalate ", " $ ("get" ++) . snd <$> filter (shouldEmitPath . fst) dirs ++ + supports_cpp = supports_language_pragma + supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1]) + supports_language_pragma = ghc_newer_than (mkVersion [6,6,1]) +diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +index 69efbda87..067287b1c 100644 +--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs ++++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +@@ -19,6 +19,10 @@ data Z + zLibexecdir :: FilePath, + zSysconfdir :: FilePath, + zNot :: (Bool -> Bool), ++ zAbsBody :: String, ++ zWarnPragma :: String, ++ zImportList :: String, ++ zShouldEmitDataDir :: Bool, + zManglePkgName :: (PackageName -> String)} + deriving Generic + render :: Z -> String +@@ -45,10 +49,18 @@ render z_root = execWriter $ do + tell "{-# OPTIONS_GHC -w #-}\n" + tell "module Paths_" + tell (zManglePkgName z_root (zPackageName z_root)) ++ tell " " ++ tell (zWarnPragma z_root) + tell " (\n" +- tell " version,\n" +- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" +- tell " getDataFileName, getSysconfDir\n" ++ tell " version, getBinDir,\n" ++ if (zShouldEmitDataDir z_root) ++ then do ++ tell " getDataFileName, \n" ++ return () ++ else do ++ tell "\n" ++ return () ++ tell (zImportList z_root) + tell " ) where\n" + tell "\n" + if (zNot z_root (zAbsolute z_root)) +@@ -97,16 +109,21 @@ render z_root = execWriter $ do + tell (zVersionDigits z_root) + tell " []\n" + tell "\n" +- tell "getDataFileName :: FilePath -> IO FilePath\n" +- tell "getDataFileName name = do\n" +- tell " dir <- getDataDir\n" +- tell " return (dir `joinFileName` name)\n" +- tell "\n" +- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" ++ if (zShouldEmitDataDir z_root) ++ then do ++ tell "getDataFileName :: FilePath -> IO FilePath\n" ++ tell "getDataFileName name = do\n" ++ tell " dir <- getDataDir\n" ++ tell " return (dir `joinFileName` name)\n" ++ return () ++ else do ++ return () + tell "\n" + tell "\n" + if (zRelocatable z_root) + then do ++ tell "\n" ++ tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" + tell "\n" + tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" + tell "getPrefixDirReloc dirRel = do\n" +@@ -152,44 +169,16 @@ render z_root = execWriter $ do + if (zAbsolute z_root) + then do + tell "\n" +- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n" ++ tell "bindir :: FilePath\n" + tell "bindir = " + tell (zBindir z_root) + tell "\n" +- tell "libdir = " +- tell (zLibdir z_root) +- tell "\n" +- tell "dynlibdir = " +- tell (zDynlibdir z_root) +- tell "\n" +- tell "datadir = " +- tell (zDatadir z_root) +- tell "\n" +- tell "libexecdir = " +- tell (zLibexecdir z_root) +- tell "\n" +- tell "sysconfdir = " +- tell (zSysconfdir z_root) +- tell "\n" + tell "\n" ++ tell "getBinDir :: IO FilePath\n" + tell "getBinDir = catchIO (getEnv \"" + tell (zManglePkgName z_root (zPackageName z_root)) + tell "_bindir\") (\\_ -> return bindir)\n" +- tell "getLibDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_libdir\") (\\_ -> return libdir)\n" +- tell "getDynLibDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" +- tell "getDataDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_datadir\") (\\_ -> return datadir)\n" +- tell "getLibexecDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_libexecdir\") (\\_ -> return libexecdir)\n" +- tell "getSysconfDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" ++ tell (zAbsBody z_root) + tell "\n" + return () + else do From 20a0022eb41ef011d7460918ea7419b89cb65c62 Mon Sep 17 00:00:00 2001 From: mat ess Date: Sun, 31 Jul 2022 13:31:19 -0400 Subject: [PATCH 2/7] Mark regex-rure broken on aarch64-darwin --- .../development/haskell-modules/configuration-ghc-9.2.x.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix index c77a86913f618..856f9c25abb35 100644 --- a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix +++ b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix @@ -3,7 +3,7 @@ with haskellLib; let - inherit (pkgs.stdenv.hostPlatform) isDarwin; + inherit (pkgs.stdenv.hostPlatform) isAarch64 isDarwin; in self: super: { @@ -91,7 +91,9 @@ self: super: { bsb-http-chunked = dontCheck super.bsb-http-chunked; # need bytestring >= 0.11 which is only bundled with GHC >= 9.2 - regex-rure = doDistribute (markUnbroken super.regex-rure); + # broken on aarch64-darwin, failing with this error message: + # https://github.com/haskell/c2hs/issues/33 + regex-rure = doDistribute ((if isDarwin && isAarch64 then x: x else markUnbroken) super.regex-rure); jacinda = doDistribute super.jacinda; # 2022-08-01: Tests are broken on ghc 9.2.4: https://github.com/wz1000/HieDb/issues/46 From 032209f862baf65a1748d21092e7b6d91ed8feec Mon Sep 17 00:00:00 2001 From: mat ess Date: Sat, 6 Aug 2022 19:46:40 -0400 Subject: [PATCH 3/7] Be less specific about versions --- pkgs/development/compilers/ghc/9.2.4.nix | 2 +- .../ghc/{cabal-paths-9.2.3.patch => cabal-paths-9.2.x.patch} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/development/compilers/ghc/{cabal-paths-9.2.3.patch => cabal-paths-9.2.x.patch} (100%) diff --git a/pkgs/development/compilers/ghc/9.2.4.nix b/pkgs/development/compilers/ghc/9.2.4.nix index ee2c72b1fa38e..d3c9e20e5d2c3 100644 --- a/pkgs/development/compilers/ghc/9.2.4.nix +++ b/pkgs/development/compilers/ghc/9.2.4.nix @@ -211,7 +211,7 @@ stdenv.mkDerivation (rec { # These cause problems as they're not eliminated by GHC's dead code # elimination on aarch64-darwin. (see # https://github.com/NixOS/nixpkgs/issues/140774 for details). - ./cabal-paths-9.2.3.patch + ./cabal-paths-9.2.x.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch similarity index 100% rename from pkgs/development/compilers/ghc/cabal-paths-9.2.3.patch rename to pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch From 081de9e3698af0f0ba9f1450b9a8d5d21c315535 Mon Sep 17 00:00:00 2001 From: mat ess Date: Tue, 3 Jan 2023 19:48:08 -0500 Subject: [PATCH 4/7] Add patch to 9.2.5 --- pkgs/development/compilers/ghc/9.2.5.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index e7c75fcaccf94..99d37c5a75c13 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -203,6 +203,15 @@ stdenv.mkDerivation (rec { extraPrefix = "libraries/Cabal/"; sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY="; }) + ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ + + # Prevent the paths module from emitting symbols that we don't use + # when building with separate outputs. + # + # These cause problems as they're not eliminated by GHC's dead code + # elimination on aarch64-darwin. (see + # https://github.com/NixOS/nixpkgs/issues/140774 for details). + ./cabal-paths-9.2.x.patch ]; postPatch = "patchShebangs ."; From b154d3defcfe68ddb674f98043ae8320203e1e34 Mon Sep 17 00:00:00 2001 From: mat ess Date: Tue, 3 Jan 2023 21:07:47 -0500 Subject: [PATCH 5/7] Remove unused inherits --- pkgs/development/compilers/ghc/9.2.4.nix | 2 +- pkgs/development/compilers/ghc/9.2.5.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/9.2.4.nix b/pkgs/development/compilers/ghc/9.2.4.nix index d3c9e20e5d2c3..6df468155f75e 100644 --- a/pkgs/development/compilers/ghc/9.2.4.nix +++ b/pkgs/development/compilers/ghc/9.2.4.nix @@ -71,7 +71,7 @@ assert !enableNativeBignum -> gmp != null; assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let - inherit (stdenv) buildPlatform hostPlatform targetPlatform; + inherit (stdenv) hostPlatform targetPlatform; inherit (bootPkgs) ghc; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 99d37c5a75c13..c81c320c20f7e 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -71,7 +71,7 @@ assert !enableNativeBignum -> gmp != null; assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let - inherit (stdenv) buildPlatform hostPlatform targetPlatform; + inherit (stdenv) hostPlatform targetPlatform; inherit (bootPkgs) ghc; From 63a496910830c9c3265519fc2867a361c2366a7b Mon Sep 17 00:00:00 2001 From: mat ess Date: Tue, 3 Jan 2023 21:07:53 -0500 Subject: [PATCH 6/7] Fix patch --- .../compilers/ghc/cabal-paths-9.2.x.patch | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch index d59d206ead0c5..8d8d473a005cc 100644 --- a/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch +++ b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch @@ -68,7 +68,7 @@ index b2be7e1a8..bf218dbc1 100644 supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1]) supports_language_pragma = ghc_newer_than (mkVersion [6,6,1]) diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -index 69efbda87..067287b1c 100644 +index 6488ea061..9d4218b28 100644 --- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs @@ -19,6 +19,10 @@ data Z @@ -104,7 +104,7 @@ index 69efbda87..067287b1c 100644 tell " ) where\n" tell "\n" if (zNot z_root (zAbsolute z_root)) -@@ -97,16 +109,21 @@ render z_root = execWriter $ do +@@ -97,13 +97,16 @@ render z_root = execWriter $ do tell (zVersionDigits z_root) tell " []\n" tell "\n" @@ -114,6 +114,7 @@ index 69efbda87..067287b1c 100644 - tell " return (dir `joinFileName` name)\n" - tell "\n" - tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" +- tell "\n" + if (zShouldEmitDataDir z_root) + then do + tell "getDataFileName :: FilePath -> IO FilePath\n" @@ -123,7 +124,11 @@ index 69efbda87..067287b1c 100644 + return () + else do + return () - tell "\n" ++ tell "\n" + let + z_var0_function_defs = do + tell "minusFileName :: FilePath -> String -> FilePath\n" +@@ -130,6 +133,8 @@ render z_root = execWriter $ do tell "\n" if (zRelocatable z_root) then do @@ -132,7 +137,7 @@ index 69efbda87..067287b1c 100644 tell "\n" tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" tell "getPrefixDirReloc dirRel = do\n" -@@ -152,44 +169,16 @@ render z_root = execWriter $ do +@@ -177,44 +182,16 @@ render z_root = execWriter $ do if (zAbsolute z_root) then do tell "\n" From 80218f1dcaa15f4dd4bc476965d80ada7758e2cc Mon Sep 17 00:00:00 2001 From: mat ess Date: Fri, 17 Feb 2023 14:25:55 -0500 Subject: [PATCH 7/7] Review feedback --- pkgs/development/compilers/ghc/9.2.4.nix | 2 +- pkgs/development/compilers/ghc/9.2.5.nix | 2 +- .../compilers/ghc/cabal-paths-9.2.x.patch | 127 +++++++++++++++--- 3 files changed, 111 insertions(+), 20 deletions(-) diff --git a/pkgs/development/compilers/ghc/9.2.4.nix b/pkgs/development/compilers/ghc/9.2.4.nix index 6df468155f75e..d3c9e20e5d2c3 100644 --- a/pkgs/development/compilers/ghc/9.2.4.nix +++ b/pkgs/development/compilers/ghc/9.2.4.nix @@ -71,7 +71,7 @@ assert !enableNativeBignum -> gmp != null; assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let - inherit (stdenv) hostPlatform targetPlatform; + inherit (stdenv) buildPlatform hostPlatform targetPlatform; inherit (bootPkgs) ghc; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index c81c320c20f7e..99d37c5a75c13 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -71,7 +71,7 @@ assert !enableNativeBignum -> gmp != null; assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let - inherit (stdenv) hostPlatform targetPlatform; + inherit (stdenv) buildPlatform hostPlatform targetPlatform; inherit (bootPkgs) ghc; diff --git a/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch index 8d8d473a005cc..e4526da4e851d 100644 --- a/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch +++ b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch @@ -1,7 +1,7 @@ diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs index b2be7e1a8..bf218dbc1 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs +--- a/Cabal/src/Distribution/Simple/Build/PathsModule.hs ++++ b/Cabal/src/Distribution/Simple/Build/PathsModule.hs @@ -25,16 +25,21 @@ import Distribution.Package import Distribution.PackageDescription import Distribution.Simple.Compiler @@ -68,21 +68,23 @@ index b2be7e1a8..bf218dbc1 100644 supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1]) supports_language_pragma = ghc_newer_than (mkVersion [6,6,1]) diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -index 6488ea061..9d4218b28 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -@@ -19,6 +19,10 @@ data Z +index 6488ea061..b2b2c0e19 100644 +--- a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs ++++ b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +@@ -19,7 +19,11 @@ data Z zLibexecdir :: FilePath, zSysconfdir :: FilePath, zNot :: (Bool -> Bool), +- zManglePkgName :: (PackageName -> String)} ++ zManglePkgName :: (PackageName -> String), ++ zShouldEmitDataDir :: Bool, + zAbsBody :: String, + zWarnPragma :: String, -+ zImportList :: String, -+ zShouldEmitDataDir :: Bool, - zManglePkgName :: (PackageName -> String)} ++ zImportList :: String} deriving Generic render :: Z -> String -@@ -45,10 +49,18 @@ render z_root = execWriter $ do + render z_root = execWriter $ do +@@ -45,10 +49,23 @@ render z_root = execWriter $ do tell "{-# OPTIONS_GHC -w #-}\n" tell "module Paths_" tell (zManglePkgName z_root (zPackageName z_root)) @@ -93,18 +95,23 @@ index 6488ea061..9d4218b28 100644 - tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" - tell " getDataFileName, getSysconfDir\n" + tell " version, getBinDir,\n" ++ tell " " + if (zShouldEmitDataDir z_root) + then do -+ tell " getDataFileName, \n" ++ tell "\n" ++ tell " getDataFileName,\n" ++ tell " " + return () + else do -+ tell "\n" + return () ++ tell "\n" ++ tell " " + tell (zImportList z_root) ++ tell "\n" tell " ) where\n" tell "\n" if (zNot z_root (zAbsolute z_root)) -@@ -97,13 +97,16 @@ render z_root = execWriter $ do +@@ -97,12 +114,15 @@ render z_root = execWriter $ do tell (zVersionDigits z_root) tell " []\n" tell "\n" @@ -114,7 +121,6 @@ index 6488ea061..9d4218b28 100644 - tell " return (dir `joinFileName` name)\n" - tell "\n" - tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" -- tell "\n" + if (zShouldEmitDataDir z_root) + then do + tell "getDataFileName :: FilePath -> IO FilePath\n" @@ -124,11 +130,10 @@ index 6488ea061..9d4218b28 100644 + return () + else do + return () -+ tell "\n" + tell "\n" let z_var0_function_defs = do - tell "minusFileName :: FilePath -> String -> FilePath\n" -@@ -130,6 +133,8 @@ render z_root = execWriter $ do +@@ -130,6 +150,8 @@ render z_root = execWriter $ do tell "\n" if (zRelocatable z_root) then do @@ -137,7 +142,7 @@ index 6488ea061..9d4218b28 100644 tell "\n" tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" tell "getPrefixDirReloc dirRel = do\n" -@@ -177,44 +182,16 @@ render z_root = execWriter $ do +@@ -177,44 +199,17 @@ render z_root = execWriter $ do if (zAbsolute z_root) then do tell "\n" @@ -182,6 +187,92 @@ index 6488ea061..9d4218b28 100644 - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" + tell (zAbsBody z_root) ++ tell "\n" tell "\n" return () else do +diff --git a/cabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs +index e4b930635..b69a73191 100644 +--- a/cabal-dev-scripts/src/GenPathsModule.hs ++++ b/cabal-dev-scripts/src/GenPathsModule.hs +@@ -43,6 +43,11 @@ $(capture "decls" [d| + + , zNot :: Bool -> Bool + , zManglePkgName :: PackageName -> String ++ ++ , zShouldEmitDataDir :: Bool ++ , zAbsBody :: String ++ , zWarnPragma :: String ++ , zImportList :: String + } + deriving (Generic) + |]) +diff --git a/templates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs +index 6bc6b7875..f5489bea8 100644 +--- a/templates/Paths_pkg.template.hs ++++ b/templates/Paths_pkg.template.hs +@@ -9,10 +9,12 @@ + {% endif %} + {-# OPTIONS_GHC -fno-warn-missing-import-lists #-} + {-# OPTIONS_GHC -w #-} +-module Paths_{{ manglePkgName packageName }} ( +- version, +- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, +- getDataFileName, getSysconfDir ++module Paths_{{ manglePkgName packageName }} {{ warnPragma }} ( ++ version, getBinDir, ++ {% if shouldEmitDataDir %} ++ getDataFileName, ++ {% endif %} ++ {{ importList }} + ) where + + {% if not absolute %} +@@ -51,12 +53,12 @@ catchIO = Exception.catch + version :: Version + version = Version {{ versionDigits }} [] + ++{% if shouldEmitDataDir %} + getDataFileName :: FilePath -> IO FilePath + getDataFileName name = do + dir <- getDataDir + return (dir `joinFileName` name) +- +-getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath ++{% endif %} + + {% defblock function_defs %} + minusFileName :: FilePath -> String -> FilePath +@@ -85,6 +87,8 @@ splitFileName p = (reverse (path2++drive), reverse fname) + + {% if relocatable %} + ++getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath ++ + getPrefixDirReloc :: FilePath -> IO FilePath + getPrefixDirReloc dirRel = do + exePath <- getExecutablePath +@@ -102,20 +106,12 @@ getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\ + + {% elif absolute %} + +-bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath ++bindir :: FilePath + bindir = {{ bindir }} +-libdir = {{ libdir }} +-dynlibdir = {{ dynlibdir }} +-datadir = {{ datadir }} +-libexecdir = {{ libexecdir }} +-sysconfdir = {{ sysconfdir }} + ++getBinDir :: IO FilePath + getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir) +-getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) +-getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) +-getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) +-getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) +-getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) ++{{ absBody }} + + {% elif isWindows %} +