@@ -277,7 +277,7 @@ in let configured-src = stdenv.mkDerivation (rec {
277 enableParallelBuilding = true;
277 enableParallelBuilding = true;
278 postPatch = "patchShebangs .";
278 postPatch = "patchShebangs .";
280− outputs = [ "out" "doc" ];
280+ outputs = [ "out" "doc" "generated" ];
282 # Make sure we never relax`$PATH` and hooks support for compatability.
282 # Make sure we never relax`$PATH` and hooks support for compatability.
283 strictDeps = true;
283 strictDeps = true;
@@ -330,6 +330,32 @@ in let configured-src = stdenv.mkDerivation (rec {
330 -e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \
330 -e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \
334+ # Save generated files for needed when building ghcjs
335+ mkdir -p $generated/includes/dist-derivedconstants/header
336+ cp includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs \
337+ includes/dist-derivedconstants/header/GHCConstantsHaskellType.hs \
338+ includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs \
339+ $generated/includes/dist-derivedconstants/header
340+ if [[ -f includes/ghcplatform.h ]]; then
341+ cp includes/ghcplatform.h $generated/includes
342+ elif [[ -f includes/dist-install/build/ghcplatform.h ]]; then
343+ cp includes/dist-install/build/ghcplatform.h $generated/includes
345+ mkdir -p $generated/compiler/stage2/build
346+ cp compiler/stage2/build/Config.hs $generated/compiler/stage2/build || true
347+ mkdir -p $generated/rts/build
348+ cp rts/build/config.hs-incl $generated/rts/build || true
350+ # Save generated files for needed when building ghc-boot
351+ mkdir -p $generated/libraries/ghc-boot/dist-install/build/GHC/Platform
352+ if [[ -f libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then
353+ cp libraries/ghc-boot/dist-install/build/GHC/Version.hs $generated/libraries/ghc-boot/dist-install/build/GHC/Version.hs
355+ if [[ -f libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then
356+ cp libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $generated/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs
333 ${installDeps targetPrefix}
359 ${installDeps targetPrefix}
335 # Sanity checks for https://github.com/input-output-hk/haskell.nix/issues/660
361 # Sanity checks for https://github.com/input-output-hk/haskell.nix/issues/660