haskell.packages.*.ghcWithPackages: Fix on darwin
Previously, `ghcWithPackages` would fail to build on macOS because package `.conf` files now contain a literal `${pkgroot}` (which of course does not exist): ``` $ grep -Poz "dynamic-library-dirs:\s*\K .+\n" /nix/store/s5xrmb3583fd5qjrqsg73fblaq46gqpd-ghc-9.10.1-with-packages/lib/ghc-9.10.1/lib/package.conf.d/* ... /nix/store/s5xrmb3583fd5qjrqsg73fblaq46gqpd-ghc-9.10.1-with-packages/lib/ghc-9.10.1/lib/package.conf.d/unix-2.8.5.1-ce1b.conf.copy: ${pkgroot}/../lib/aarch64-osx-ghc-9.10.1 ... ``` Therefore, we use `ghc-pkg --simple-output list` to get a list of `.conf` files and `ghc-pkg --simple-output field "$pkg" dynamic-library-dirs` to get the value of the field while expanding `${pkgroot}` prefixes.
This commit is contained in:
parent
41a64ff35a
commit
c2ffd1f4a8
@ -62,13 +62,6 @@ let
|
|||||||
else
|
else
|
||||||
"$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
|
"$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
|
||||||
+ lib.optionalString (ghc ? hadrian) "/lib";
|
+ lib.optionalString (ghc ? hadrian) "/lib";
|
||||||
# Boot libraries for GHC are present in a separate directory.
|
|
||||||
bootLibDir =
|
|
||||||
let
|
|
||||||
arch = if stdenv.targetPlatform.isAarch64 then "aarch64" else "x86_64";
|
|
||||||
platform = if stdenv.targetPlatform.isDarwin then "osx" else "linux";
|
|
||||||
in
|
|
||||||
"${ghc}/lib/${ghc.haskellCompilerName}/lib/${arch}-${platform}-${ghc.haskellCompilerName}";
|
|
||||||
docDir = "$out/share/doc/ghc/html";
|
docDir = "$out/share/doc/ghc/html";
|
||||||
packageCfgDir = "${libDir}/package.conf.d";
|
packageCfgDir = "${libDir}/package.conf.d";
|
||||||
paths = lib.concatLists (
|
paths = lib.concatLists (
|
||||||
@ -154,14 +147,17 @@ else
|
|||||||
# symlinkJoin:
|
# symlinkJoin:
|
||||||
rm -f $dynamicLinksDir/*
|
rm -f $dynamicLinksDir/*
|
||||||
|
|
||||||
# Boot libraries are located differently than other libraries since GHC 9.6, so handle them separately.
|
dynamicLibraryDirs=()
|
||||||
if [[ -x "${bootLibDir}" ]]; then
|
|
||||||
find "${bootLibDir}" -name '*.dylib' -exec ln -s {} "$dynamicLinksDir" \;
|
|
||||||
fi
|
|
||||||
|
|
||||||
for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u); do
|
for pkg in $($out/bin/ghc-pkg list --simple-output); do
|
||||||
find "$d" -name '*.dylib' -exec ln -s {} "$dynamicLinksDir" \;
|
dynamicLibraryDirs+=($($out/bin/ghc-pkg --simple-output field "$pkg" dynamic-library-dirs))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for dynamicLibraryDir in $(echo "''${dynamicLibraryDirs[@]}" | tr ' ' '\n' | sort -u); do
|
||||||
|
echo "Linking $dynamicLibraryDir/*.dylib from $dynamicLinksDir"
|
||||||
|
find "$dynamicLibraryDir" -name '*.dylib' -exec ln -s {} "$dynamicLinksDir" \;
|
||||||
|
done
|
||||||
|
|
||||||
for f in $packageConfDir/*.conf; do
|
for f in $packageConfDir/*.conf; do
|
||||||
# Initially, $f is a symlink to a read-only file in one of the inputs
|
# Initially, $f is a symlink to a read-only file in one of the inputs
|
||||||
# (as a result of this symlinkJoin derivation).
|
# (as a result of this symlinkJoin derivation).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user