on iko/ghcjs-patch-master help sign in
Add cross compile cabal wrapper (#936)

Adds a `${targetPrefix}cabal` script to `shellFor` that passes the necessary `--with-X` args to `cabal. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>

commitc3f4882bf7b42634a8fa61b2cb55d236b235471b authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 24 Nov 2020, 13:37 (6 years ago) parente4be77e
2 files changed+20−1
builder/shell-for.nix+16−1 changelog.md+4
builder/shell-for.nix+16−1
@@ -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";
changelog.md+4
@@ -1,6 +1,10 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that will impact users.
33
4+## Nov 24, 2020
5+* Added `${targetPrefix}cabal` wrapper script for running cross
6+ compilers in `shellFor`.
7+
48## Oct 31, 2020
59* Passing `tools.hoogle` to `shellFor` with a value suitable for `haskel-nix.tool` will
610 use the specified `hoogle` inside `shellFor`. This allows for materialization