@@ -106,24 +106,42 @@ let
106106in rec {
107107 ghc-boot-packages-src-and-nix = builtins.mapAttrs
108108 (ghcName: ghc: builtins.mapAttrs
109− (pkgName: dir: rec {
109+ (pkgName: subDir: rec {
110110 src =
111111 # Add in the generated files needed by ghc-boot
112− if dir == "libraries/ghc-boot"
113− then final.evalPackages.runCommand "ghc-boot-src" {} ''
114− cp -Lr ${ghc.passthru.configured-src}/${dir} $out
115− chmod -R +w $out
116− cp -Lr ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC
112+ if subDir == "libraries/ghc-boot"
113+ then final.evalPackages.runCommand "ghc-boot-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
114+ mkdir $out
115+ lndir -silent ${ghc.passthru.configured-src}/${subDir} $out
116+ lndir -silent ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC $out/GHC
117117 ''
118− else if dir == "compiler"
119− then final.evalPackages.runCommand "ghc-src" {} ''
120− cp -Lr ${ghc.passthru.configured-src}/${dir} $out
121− chmod -R +w $out
122− if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
123− cp -Lr ${ghc.generated}/compiler/stage2/build/Config.hs $out
124− fi
125− ''
126− else "${ghc.passthru.configured-src}/${dir}";
118+ else if subDir == "compiler"
119+ then final.haskell-nix.haskellLib.cleanSourceWith {
120+ src = final.evalPackages.runCommand "ghc-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
121+ mkdir $out
122+ lndir -silent ${ghc.passthru.configured-src} $out
123+ if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then
124+ ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs $out/libraries/ghc-boot/GHC
125+ fi
126+ if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then
127+ ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $out/libraries/ghc-boot/GHC/Platform
128+ fi
129+ if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
130+ ln -s ${ghc.generated}/compiler/stage2/build/Config.hs $out/compiler
131+ fi
132+ if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs ]]; then
133+ ln -s ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs $out/compiler/GHC/Platform
134+ fi
135+ if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs ]]; then
136+ ln -s ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs $out/compiler/GHC/Settings
137+ fi
138+ ln -s ${ghc.generated}/includes/dist-derivedconstants/header/* $out/compiler
139+ ln -s ${ghc.generated}/compiler/stage2/build/*.hs-incl $out/compiler
140+ '';
141+ inherit subDir;
142+ includeSiblings = true;
143+ }
144+ else "${ghc.passthru.configured-src}/${subDir}";
127145 nix = callCabal2Nix ghcName "${ghcName}-${pkgName}" src;
128146 }) (ghc-extra-pkgs ghc.version))
129147 final.buildPackages.haskell-nix.compiler;