@@ -9,6 +9,7 @@ let self =
99# build-tools
1010, bootPkgs
1111, buildPackages
12+ , pkgsBuildBuild
1213, autoconf , automake , coreutils , fetchurl , fetchpatch , perl , python3 , m4 , sphinx , numactl , elfutils , libcxx , libcxxabi ? throw "No libcxxabi"
1314, autoreconfHook
1415, bash
@@ -95,7 +96,7 @@ let self =
9596#
9697# We use this instead of `buildPackages` so that plan evaluation
9798# can work on platforms other than the `buildPlatform`.
98- , ghcEvalPackages ? buildPackages
99+ , ghcEvalPackages ? pkgsBuildBuild
99100} @args :
100101
101102assert ! ( enableIntegerSimple || enableNativeBignum ) -> gmp != null ;
@@ -128,23 +129,23 @@ let
128129 INTEGER_LIBRARY = ${ if enableIntegerSimple then "integer-simple" else "integer-gmp" }
129130 '' ;
130131
131- nodejs = buildPackages . nodejs_24 ;
132+ nodejs = pkgsBuildBuild . nodejs_24 ;
132133
133- libffi-wasm = buildPackages . runCommand "libffi-wasm" {
134+ libffi-wasm = pkgsBuildBuild . runCommand "libffi-wasm" {
134135 nativeBuildInputs = [
135- ( buildPackages . haskell-nix . tool "ghc912" "libffi-wasm" {
136- src = buildPackages . haskell-nix . sources . libffi-wasm ;
136+ ( pkgsBuildBuild . haskell-nix . tool "ghc912" "libffi-wasm" {
137+ src = pkgsBuildBuild . haskell-nix . sources . libffi-wasm ;
137138 evalPackages = ghcEvalPackages ;
138139 } )
139140 targetPackages . buildPackages . llvmPackages . clang
140141 targetPackages . buildPackages . llvmPackages . llvm
141- targetPackages . buildPackages . binaryen
142+ pkgsBuildBuild . binaryen
142143 ] ;
143144 outputs = [ "out" "dev" ] ;
144145 NIX_NO_SELF_RPATH = true ;
145146 } ''
146147 mkdir cbits
147- cp ${ buildPackages . haskell-nix . sources . libffi-wasm } /cbits/* cbits/
148+ cp ${ pkgsBuildBuild . haskell-nix . sources . libffi-wasm } /cbits/* cbits/
148149 libffi-wasm
149150 wasm32-unknown-wasi-clang -Wall -Wextra -mcpu=mvp -Oz -DNDEBUG -Icbits -c cbits/ffi.c -o cbits/ffi.o
150151 wasm32-unknown-wasi-clang -Wall -Wextra -mcpu=mvp -Oz -DNDEBUG -Icbits -c cbits/ffi_call.c -o cbits/ffi_call.o
159160 wasm-opt --low-memory-unused --converge --debuginfo --flatten --rereloop --gufa -O4 -Oz libffi.so -o $out/lib/libffi.so
160161 '' ;
161162
162- lib-wasm = buildPackages . symlinkJoin {
163+ lib-wasm = pkgsBuildBuild . symlinkJoin {
163164 name = "lib-wasm" ;
164165 paths = [ targetPackages . wasilibc libffi-wasm ] ;
165166 } ;
@@ -315,13 +316,15 @@ let
315316 compiler-nix-name =
316317 if builtins . compareVersions ghc-version "9.4.7" < 0
317318 then "ghc928"
318- else if buildPackages . haskell . compiler ? ghc966
319+ else if pkgsBuildBuild . haskell . compiler ? ghc967
320+ then "ghc967"
321+ else if pkgsBuildBuild . haskell . compiler ? ghc966
319322 then "ghc966"
320- else if buildPackages . haskell . compiler ? ghc964
323+ else if pkgsBuildBuild . haskell . compiler ? ghc964
321324 then "ghc964"
322325 else "ghc962" ;
323326 in
324- buildPackages . haskell-nix . cabalProject' ( {
327+ pkgsBuildBuild . haskell-nix . cabalProject' ( {
325328 inherit compiler-nix-name ;
326329 name = "hadrian" ;
327330 compilerSelection = p : p . haskell . compiler ;
343346 cabalProjectFreeze = null ;
344347 src = haskell-nix . haskellLib . cleanSourceWith {
345348 src = {
346- outPath = buildPackages . srcOnly {
347- stdenv = buildPackages . stdenvNoCC ;
349+ outPath = pkgsBuildBuild . srcOnly {
350+ stdenv = pkgsBuildBuild . stdenvNoCC ;
348351 name = "hadrian" ;
349352 inherit src ;
350353 } ;
354357 includeSiblings = true ;
355358 } ;
356359 # When building the plan we do not need a patched version
357- # of the source and `buildPackages .srcOnly` requires introduces
360+ # of the source and `pkgsBuildBuild .srcOnly` requires introduces
358361 # a dependency on a build machine.
359362 evalSrc = haskell-nix . haskellLib . cleanSourceWith {
360363 src = {
@@ -615,7 +618,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
615618 if builtins . compareVersions ghc-version "9.13" < 0
616619 then "--experimental-wasm-type-reflection"
617620 else "--max-old-space-size=65536" } --no-turbo-fast-api-calls --wasm-lazy-validation" \
618- "${ buildPackages . writeShellScriptBin "node" ''
621+ "${ pkgsBuildBuild . writeShellScriptBin "node" ''
619622 SCRIPT=$1
620623 shift
621624 LIB_WASM=$1
@@ -853,11 +856,6 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
853856 for a in libraries/*/*.cabal.in utils/*/*.cabal.in compiler/ghc.cabal.in; do
854857 ${ hadrian } /bin/hadrian ${ hadrianArgs } "'' ${a%.*}"
855858 done
856- '' + lib . optionalString ( ghc-version == "9.8.20230704" ) ''
857- for a in bytearray-access-ops.txt.pp addr-access-ops.txt.pp primops.txt; do
858- ${ hadrian } /bin/hadrian ${ hadrianArgs } _build/stage0/compiler/build/$a
859- cp _build/stage0/compiler/build/$a compiler/GHC/Builtin/$a
860- done
861859 '' + lib . optionalString ( stdenv . isDarwin && ( __tryEval libcxxabi ) . success ) ''
862860 substituteInPlace mk/system-cxx-std-lib-1.0.conf \
863861 --replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${ libcxx } /lib ${ libcxxabi } /lib'
@@ -950,6 +948,10 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
950948 export XATTR=$(mktemp -d)/nothing
951949 '' ;
952950} // lib . optionalAttrs useHadrian {
951+ preUnpack = ''
952+ mkdir -p $out/build
953+ cd $out/build
954+ '' ;
953955 postConfigure = lib . optionalString ( stdenv . isDarwin && ( __tryEval libcxxabi ) . success ) ''
954956 substituteInPlace mk/system-cxx-std-lib-1.0.conf \
955957 --replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${ libcxx } /lib ${ libcxxabi } /lib'
@@ -992,7 +994,6 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
992994 installPhase =
993995 if installStage1
994996 then ''
995- mkdir $out
996997 cp -r _build/stage1/bin $out
997998 # let's assume that if we find a non-prefixed genprimop,
998999 # we also find a non-prefixed deriveConstants
@@ -1009,6 +1010,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
10091010 mkdir $doc
10101011 cp -r _build/stage1/share $doc
10111012 runHook postInstall
1013+ cd $out
1014+ rm -rf $out/build
10121015 ''
10131016 # there appears to be a bug in GHCs configure script not properly passing dllwrap, and windres to the
10141017 # generated settings file. Hence we patch it back in here.
@@ -1039,6 +1042,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
10391042 make install
10401043 cd ../../..
10411044 runHook postInstall
1045+ cd $out
1046+ rm -rf $out/build
10421047 '' ;
10431048} ) ) ;
10441049in self
0 commit comments