diff --git a/pkgs/development/compilers/ghc/8.10.2-binary.nix b/pkgs/development/compilers/ghc/8.10.2-binary.nix index 10ee40f710c81..41461a26d425f 100644 --- a/pkgs/development/compilers/ghc/8.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.2-binary.nix @@ -122,6 +122,7 @@ let # instead of `libtinfo.so.*.` { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } ]; + isHadrian = true; }; }; }; @@ -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 { diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix index 94ad5a78a0a76..22552fa67fb2f 100644 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.7-binary.nix @@ -137,6 +137,7 @@ let # instead of `libtinfo.so.*.` { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } ]; + isHadrian = true; }; }; }; @@ -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 { diff --git a/pkgs/development/compilers/ghc/9.2.4-binary.nix b/pkgs/development/compilers/ghc/9.2.4-binary.nix index 57e0db560a989..79b006ce5537b 100644 --- a/pkgs/development/compilers/ghc/9.2.4-binary.nix +++ b/pkgs/development/compilers/ghc/9.2.4-binary.nix @@ -94,6 +94,7 @@ let { nixPackage = ncurses6; fileToCheckFor = null; } { nixPackage = libiconv; fileToCheckFor = null; } ]; + isHadrian = true; }; aarch64-darwin = { variantSuffix = ""; @@ -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. @@ -118,6 +120,7 @@ let sha256 = "026348947d30a156b84de5d6afeaa48fdcb2795b47954cd8341db00d3263a481"; }; isStatic = true; + isHadrian = true; # We can't check the RPATH for statically linked executable exePathForLibraryCheck = null; archSpecificLibraries = [ @@ -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 { diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 4b7201bb6ac9b..73986361499a7 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -199,7 +199,8 @@ 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"}") @@ -207,7 +208,7 @@ let "--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") @@ -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 @@ -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 ''; @@ -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 @@ -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 @@ -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 ''} @@ -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 { }; diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix index 77ccd301b43f4..34eb2b71d7597 100644 --- a/pkgs/development/haskell-modules/with-packages-wrapper.nix +++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix @@ -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 (