@@ -127,7 +127,22 @@ in
127 nativeBuildInputs = [ ghcEnv ]
127 nativeBuildInputs = [ ghcEnv ]
128 ++ nativeBuildInputs
128 ++ nativeBuildInputs
129 ++ mkDrvArgs.nativeBuildInputs or []
129 ++ 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" ''
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 \
143+ ''} $(builtin type -P "${ghcEnv.targetPrefix}pkg-config" &> /dev/null && echo "--with-pkg-config=${ghcEnv.targetPrefix}pkg-config") \
131 phases = ["installPhase"];
146 phases = ["installPhase"];
132 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
147 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
133 LANG = "en_US.UTF-8";
148 LANG = "en_US.UTF-8";