Skip to content

Commit 0cc3670

Browse files
hamishmackangerman
authored andcommitted
Adds ghcjs and Asterius as cross compilers (#106)
This adds ghcjs and asterius cross compiler support to haskell.nix. For proper ghcjs/asterius cross compiler you'll need to add them to nixpkgs.
1 parent fca5ef8 commit 0cc3670

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

builder/comp-builder.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ let
157157
"--with-ghc=${ghc.targetPrefix}ghc"
158158
"--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
159159
"--with-hsc2hs=${ghc.targetPrefix}hsc2hs"
160-
# CC
160+
] ++ lib.optionals (stdenv.cc != null)
161+
[ # CC
161162
"--with-gcc=${stdenv.cc.targetPrefix}cc"
162163
# BINTOOLS
163164
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
164165
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
165166
"--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
166-
# other flags
167+
] ++ [ # other flags
167168
(if dontStrip then "--disable-executable-stripping" else "--enable-executable-stripping")
168169
(if dontStrip then "--disable-library-stripping" else "--enable-library-stripping")
169170
] ++ lib.optional doHaddock' "--docdir=${docdir "$doc"}"

lib/host-map.nix

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
stdenv: with stdenv.hostPlatform; {
1+
stdenv:
2+
# set a few default values so we don't depend on what's exported from
3+
# hostPlatform from whatever nixpkgs set we are working against.
4+
with { isLinux = false; isWindows = false; isDarwin = false; isFreeBSD = false;
5+
isOpenBSD = false; isNetBSD = false; isiOS = false; isAndroid = false;
6+
isGhcjs = false; isAsterius = false; isHurd = false;
7+
isx86 = false; isPowerPC = false; isAarch32 = false; isAarch64 = false;
8+
isMips = false; isWasm = false; isJavaScript = false;
9+
is32bit = false; is64bit = false; };
10+
with stdenv.hostPlatform; {
211
os = if isLinux then "Linux" else
312
if isWindows then "Windows" else
4-
if isDarwin then "Osx" else
13+
if isDarwin then "Osx" else
514
if isFreeBSD then "Freebsd" else
615
if isOpenBSD then "Openbsd" else
716
if isNetBSD then "Netbsd" else
817
if isHurd then "Hurd" else
918
if isiOS then "Ios" else
1019
if isAndroid then "Android" else
20+
if isGhcjs then "Ghcjs" else
21+
if isAsterius then "Asterius" else
1122
throw "Unknown OS";
1223
arch = if isx86 && is32bit then "I386" else
1324
if isx86 && is64bit then "X86_64" else
@@ -16,5 +27,8 @@ stdenv: with stdenv.hostPlatform; {
1627
if isAarch32 then "Arm" else
1728
if isAarch64 then "Aarch64" else
1829
if isMips then "Mips" else
30+
if isWasm && is32bit then "Wasm32" else
31+
if isWasm && is64bit then "Wasm64" else
32+
if isJavaScript then "JavaScript" else
1933
throw "Unknown Arch";
2034
}

0 commit comments

Comments
 (0)