@@ -127,7 +127,22 @@ in
127127 nativeBuildInputs = [ ghcEnv ]
128128 ++ nativeBuildInputs
129129 ++ mkDrvArgs.nativeBuildInputs or []
130− ++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools);
130+ ++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
131+ # If this shell is a cross compilation shell include
132+ # wrapper script for running cabal build with appropriate args.
133+ ++ lib.optional (ghcEnv.targetPrefix != "") (
134+ buildPackages.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" ''
135+ exec cabal \
136+ --with-ghc=${ghcEnv.targetPrefix}ghc \
137+ --with-ghc-pkg=${ghcEnv.targetPrefix}ghc-pkg \
138+ --with-hsc2hs=${ghcEnv.targetPrefix}hsc2hs \
139+ ${lib.optionalString (ghcEnv.targetPrefix == "js-unknown-ghcjs-") ''
140+ --with-ghcjs=${ghcEnv.targetPrefix}ghc \
141+ --with-ghcjs-pkg=${ghcEnv.targetPrefix}ghc-pkg \
142+ --ghcjs \
143+ ''} $(builtin type -P "${ghcEnv.targetPrefix}pkg-config" &> /dev/null && echo "--with-pkg-config=${ghcEnv.targetPrefix}pkg-config") \
144+ "$@"
145+ '');
131146 phases = ["installPhase"];
132147 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
133148 LANG = "en_US.UTF-8";