Skip to content

Commit

Permalink
Add cross compile cabal wrapper (#936)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hamishmack and rvl committed Nov 24, 2020
1 parent e4be77e commit c3f4882
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion builder/shell-for.nix
Expand Up @@ -127,7 +127,22 @@ in
nativeBuildInputs = [ ghcEnv ]
++ nativeBuildInputs
++ mkDrvArgs.nativeBuildInputs or []
++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools);
++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
# If this shell is a cross compilation shell include
# wrapper script for running cabal build with appropriate args.
++ lib.optional (ghcEnv.targetPrefix != "") (
buildPackages.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" ''
exec cabal \
--with-ghc=${ghcEnv.targetPrefix}ghc \
--with-ghc-pkg=${ghcEnv.targetPrefix}ghc-pkg \
--with-hsc2hs=${ghcEnv.targetPrefix}hsc2hs \
${lib.optionalString (ghcEnv.targetPrefix == "js-unknown-ghcjs-") ''
--with-ghcjs=${ghcEnv.targetPrefix}ghc \
--with-ghcjs-pkg=${ghcEnv.targetPrefix}ghc-pkg \
--ghcjs \
''} $(builtin type -P "${ghcEnv.targetPrefix}pkg-config" &> /dev/null && echo "--with-pkg-config=${ghcEnv.targetPrefix}pkg-config") \
"$@"
'');
phases = ["installPhase"];
installPhase = "echo $nativeBuildInputs $buildInputs > $out";
LANG = "en_US.UTF-8";
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
@@ -1,6 +1,10 @@
This file contains a summary of changes to Haskell.nix and `nix-tools`
that will impact users.

## Nov 24, 2020
* Added `${targetPrefix}cabal` wrapper script for running cross
compilers in `shellFor`.

## Oct 31, 2020
* Passing `tools.hoogle` to `shellFor` with a value suitable for `haskel-nix.tool` will
use the specified `hoogle` inside `shellFor`. This allows for materialization
Expand Down

0 comments on commit c3f4882

Please sign in to comment.