-
Notifications
You must be signed in to change notification settings - Fork 250
Description
To build components we build the Setup
module, which links against lib:Cabal
, the code for doing this is in
haskell.nix/builder/hspkg-builder.nix
Lines 33 to 52 in 19a1220
defaultSetupSrc = builtins.toFile "Setup.hs" '' | |
import Distribution.Simple | |
main = defaultMain | |
''; | |
defaultSetup = buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } '' | |
cat ${defaultSetupSrc} > Setup.hs | |
mkdir -p $out/bin | |
${(ghc.passthru.buildGHC or ghc).targetPrefix}ghc Setup.hs --make -o $out/bin/Setup | |
''; | |
setup = if package.buildType == "Simple" && package.setup-depends == [] | |
then defaultSetup | |
else setup-builder { | |
component = components.setup // { | |
depends = components.setup.depends ++ package.setup-depends; | |
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ]; | |
}; | |
inherit package name src flags revision patches defaultSetupSrc; | |
inherit (config) preUnpack postUnpack; | |
}; |
We thus build Setup
against the lib:Cabal
that comes with ghc, which we try to patch across all ghc installs:
haskell.nix/overlays/patches/ghc/ghc-8.6-Cabal-fix-datadir.patch
Lines 1 to 21 in 19a1220
Submodule libraries/Cabal contains modified content | |
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs | |
index 678ccbca3..ffa712e8a 100644 | |
--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs | |
+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs | |
@@ -192,10 +192,14 @@ generate pkg_descr lbi clbi = | |
bindir = flat_bindir, | |
libdir = flat_libdir, | |
dynlibdir = flat_dynlibdir, | |
- datadir = flat_datadir, | |
libexecdir = flat_libexecdir, | |
sysconfdir = flat_sysconfdir | |
} = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest | |
+ | |
+ InstallDirs { | |
+ datadir = flat_datadir | |
+ } = absoluteInstallDirs pkg_descr lbi NoCopyDest | |
+ | |
InstallDirs { | |
bindir = flat_bindirrel, | |
libdir = flat_libdirrel, |
As it so happens our bootstrap compiler are not patched but might still exhibit faulty lib:Cabal
s. As such it seems only prudent that we would link the defaultSetup
against a controlled lib:Cabal
as well.
I believe all we'd need to do is to use the setup-builder
instead and feed it the correct depends
value.