@@ -47,6 +47,7 @@ let self =
4747 # ghc's internal linker seems to be broken on x86.
4848 && !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86)
4949, enableDeadCodeElimination ? component.enableDeadCodeElimination
50+, writeHieFiles ? component.writeHieFiles
5051
5152, ghcOptions ? component.ghcOptions
5253
@@ -143,7 +144,15 @@ let
143144
144145 finalConfigureFlags = lib.concatStringsSep " " (
145146 [ "--prefix=$out"
146− ] ++ (
147+ ] ++
148+ # We don't specify this in 'commonConfigureFlags', as these are also
149+ # used by haddock-builder.nix. If we do specify these options in
150+ # commonConfigureFlags, then the haddock-builder will fail, because it
151+ # sets its own outputs which *don't* include $hie
152+ lib.optionals writeHieFiles [
153+ "--ghc-option=-fwrite-ide-info" "--ghc-option=-hiedir$hie"
154+ ] ++
155+ (
147156 # If configureAllComponents is set we should not specify the component
148157 # and Setup will attempt to configure them all.
149158 if configureAllComponents
@@ -345,7 +354,8 @@ let
345354
346355 outputs = ["out" ]
347356 ++ (lib.optional enableSeparateDataOutput "data")
348− ++ (lib.optional keepSource "source");
357+ ++ (lib.optional keepSource "source")
358+ ++ (lib.optional writeHieFiles "hie");
349359
350360 prePatch =
351361 # emcc is very slow if it cannot cache stuff in $HOME