Skip to content
8 changes: 8 additions & 0 deletions pkgs/development/compilers/ghc/8.10.2-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let
# instead of `libtinfo.so.*.`
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
];
isHadrian = true;
};
};
};
Expand Down Expand Up @@ -420,6 +421,13 @@ stdenv.mkDerivation rec {

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
} // lib.optionalAttrs (binDistUsed.isHadrian or false) {
# Normal GHC derivations expose the hadrian derivation used to build them
# here. In the case of bindists we just make sure that the attribute exists,
# as it is used for checking if a GHC derivation has been built with hadrian.
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
# exclusively, i.e. 9.6 (and 9.4?).
hadrian = null;
};

meta = rec {
Expand Down
8 changes: 8 additions & 0 deletions pkgs/development/compilers/ghc/8.10.7-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ let
# instead of `libtinfo.so.*.`
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
];
isHadrian = true;
};
};
};
Expand Down Expand Up @@ -416,6 +417,13 @@ stdenv.mkDerivation rec {

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
} // lib.optionalAttrs (binDistUsed.isHadrian or false) {
# Normal GHC derivations expose the hadrian derivation used to build them
# here. In the case of bindists we just make sure that the attribute exists,
# as it is used for checking if a GHC derivation has been built with hadrian.
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
# exclusively, i.e. 9.6 (and 9.4?).
hadrian = null;
};

meta = rec {
Expand Down
10 changes: 10 additions & 0 deletions pkgs/development/compilers/ghc/9.2.4-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ let
{ nixPackage = ncurses6; fileToCheckFor = null; }
{ nixPackage = libiconv; fileToCheckFor = null; }
];
isHadrian = true;
};
aarch64-darwin = {
variantSuffix = "";
Expand All @@ -107,6 +108,7 @@ let
{ nixPackage = ncurses6; fileToCheckFor = null; }
{ nixPackage = libiconv; fileToCheckFor = null; }
];
isHadrian = true;
};
};
# Binary distributions for the musl libc for the respective system.
Expand All @@ -118,6 +120,7 @@ let
sha256 = "026348947d30a156b84de5d6afeaa48fdcb2795b47954cd8341db00d3263a481";
};
isStatic = true;
isHadrian = true;
# We can't check the RPATH for statically linked executable
exePathForLibraryCheck = null;
archSpecificLibraries = [
Expand Down Expand Up @@ -400,6 +403,13 @@ stdenv.mkDerivation rec {

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
} // lib.optionalAttrs (binDistUsed.isHadrian or false) {
# Normal GHC derivations expose the hadrian derivation used to build them
# here. In the case of bindists we just make sure that the attribute exists,
# as it is used for checking if a GHC derivation has been built with hadrian.
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
# exclusively, i.e. 9.6 (and 9.4?).
hadrian = null;
};

meta = rec {
Expand Down
24 changes: 14 additions & 10 deletions pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ let
defaultConfigureFlags = [
"--verbose"
"--prefix=$out"
"--libdir=\\$prefix/lib/\\$compiler"
# Note: This must be kept in sync manually with mkGhcLibdir
("--libdir=\\$prefix/lib/\\$compiler" + lib.optionalString (ghc ? hadrian) "/lib")
"--libsubdir=\\$abi/\\$libname"
(optionalString enableSeparateDataOutput "--datadir=$data/share/${ghcNameWithPrefix}")
(optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
] ++ optionals stdenv.hasCC [
"--with-gcc=$CC" # Clang won't work without that extra information.
] ++ [
"--package-db=$packageConfDir"
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghcNameWithPrefix}/${pname}-${version}")
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/${ghcLibdir}/${pname}-${version}")
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
(optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}")
(optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
Expand Down Expand Up @@ -284,10 +285,13 @@ let
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";

ghcNameWithPrefix = "${ghc.targetPrefix}${ghc.haskellCompilerName}";
mkGhcLibdir = ghc: "lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
+ lib.optionalString (ghc ? hadrian) "/lib";
ghcLibdir = mkGhcLibdir ghc;

nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";

buildPkgDb = ghcName: packageConfDir: ''
buildPkgDb = thisGhc: packageConfDir: ''
# If this dependency has a package database, then copy the contents of it,
# unless it is one of our GHCs. These can appear in our dependencies when
# we are doing native builds, and they have package databases in them, but
Expand All @@ -297,8 +301,8 @@ let
# we compile with it, and doing so can result in having multiple copies of
# e.g. Cabal in the database with the same name and version, which is
# ambiguous.
if [ -d "$p/lib/${ghcName}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then
cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf ${packageConfDir}/
if [ -d "$p/${mkGhcLibdir thisGhc}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then
cp -f "$p/${mkGhcLibdir thisGhc}/package.conf.d/"*.conf ${packageConfDir}/
continue
fi
'';
Expand Down Expand Up @@ -363,14 +367,14 @@ stdenv.mkDerivation ({
# pkgs* arrays defined in stdenv/setup.hs
+ ''
for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
${buildPkgDb "${nativeGhcCommand}-${nativeGhc.version}" "$setupPackageConfDir"}
${buildPkgDb nativeGhc "$setupPackageConfDir"}
done
${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache
''
# For normal components
+ ''
for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
${buildPkgDb ghcNameWithPrefix "$packageConfDir"}
${buildPkgDb ghc "$packageConfDir"}
if [ -d "$p/include" ]; then
configureFlags+=" --extra-include-dirs=$p/include"
fi
Expand Down Expand Up @@ -510,7 +514,7 @@ stdenv.mkDerivation ({
# just the target specified; "install" will error here, since not all targets have been built.
else ''
${setupCommand} copy ${buildTarget}
local packageConfDir="$out/lib/${ghcNameWithPrefix}/package.conf.d"
local packageConfDir="$out/${ghcLibdir}/package.conf.d"
local packageConfFile="$packageConfDir/${pname}-${version}.conf"
mkdir -p "$packageConfDir"
${setupCommand} register --gen-pkg-config=$packageConfFile
Expand Down Expand Up @@ -539,7 +543,7 @@ stdenv.mkDerivation ({
${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && lib.versionOlder ghc.version "7.10") ''
for exe in "${binDir}/"* ; do
install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
install_name_tool -add_rpath "$out/${ghcLibdir}/${pname}-${version}" "$exe"
done
''}

Expand Down Expand Up @@ -675,7 +679,7 @@ stdenv.mkDerivation ({
"NIX_${ghcCommandCaps}_DOCDIR" = "${ghcEnv}/share/doc/ghc/html";
"NIX_${ghcCommandCaps}_LIBDIR" = if ghc.isHaLVM or false
then "${ghcEnv}/lib/HaLVM-${ghc.version}"
else "${ghcEnv}/lib/${ghcCommand}-${ghc.version}";
else "${ghcEnv}/${ghcLibdir}";
});

env = envFunc { };
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/haskell-modules/with-packages-wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ let
isHaLVM = ghc.isHaLVM or false;
ghc761OrLater = isGhcjs || isHaLVM || lib.versionOlder "7.6.1" ghc.version;
packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
ghcCommandCaps= lib.toUpper ghcCommand';
libDir = if isHaLVM then "$out/lib/HaLVM-${ghc.version}"
else "$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}";
else "$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
+ lib.optionalString (ghc ? hadrian) "/lib";
docDir = "$out/share/doc/ghc/html";
packageCfgDir = "${libDir}/package.conf.d";
paths = lib.concatLists (
Expand Down