haskell.compiler.ghc94: fix installPhase race

When building a compiler with some of the features disabled (e.g. when
cross-compiling GHC), the installPhase occasionally fails due to what
seems to be a race condition where $out/lib/ghc-$version doesn't yet
exist.

We work around the problem by creating the directory in preInstall.
This commit is contained in:
Alex Tunstall
2025-06-08 12:11:22 +02:00
committed by sternenseemann
parent ecbbc46b76
commit dcdc862ff0
@@ -593,6 +593,13 @@ stdenv.mkDerivation (
# Hydra which already warrants a significant speedup
requiredSystemFeatures = [ "big-parallel" ];
# Install occasionally fails due to a race condition in minimal builds.
# > /nix/store/wyzpysxwgs3qpvmylm9krmfzh2plicix-coreutils-9.7/bin/install -c -m 755 -d "/nix/store/xzb3390rhvhg2a0cvzmrvjspw1d8nf8h-ghc-riscv64-unknown-linux-gnu-9.4.8/bin"
# > install: cannot create regular file '/nix/store/xzb3390rhvhg2a0cvzmrvjspw1d8nf8h-ghc-riscv64-unknown-linux-gnu-9.4.8/lib/ghc-9.4.8': No such file or directory
preInstall = ''
mkdir -p "$out/lib/${passthru.haskellCompilerName}"
'';
postInstall =
''
settingsFile="$out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings"