Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wasm cross compilation #658

Merged
merged 7 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ let iosSupport = system == "x86_64-darwin";

inherit (nixpkgs) lib fetchurl fetchgit fetchgitPrivate fetchFromGitHub fetchFromBitbucket;

wasmCross = fetchgit {
url = "https://github.com/WebGHC/wasm-cross.git";
rev = "ab650bf145a6ea269caee34b7cb0ec8745fde26a";
sha256 = "1c5icqiwyhmsm6f3fzhp685wriznb1gybz56rmi1vd8bxk0g5a9m";
};
webGhcSrc = fetchgit {
url = "https://github.com/WebGHC/ghc.git";
rev = "746a6e61c69f57ba6441a922bd7b6fe807b2dd2f";
sha256 = "0ghza2ix9lp5di7mgqzahlbxm9i0w4l10nxi99ls2n6xm2g231j3";
fetchSubmodules = true;
};
3noch marked this conversation as resolved.
Show resolved Hide resolved
nixpkgsCross = {
android = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec {
aarch64 = {
Expand Down Expand Up @@ -149,6 +160,9 @@ let iosSupport = system == "x86_64-darwin";
ghcjs = nixpkgsFunc (nixpkgsArgs // {
crossSystem = lib.systems.examples.ghcjs;
});
wasm = nixpkgsFunc (nixpkgsArgs //
(import wasmCross { inherit nixpkgsFunc; }).nixpkgsCrossArgs webGhcSrc "8.6.5"
);
};

haskellLib = nixpkgs.haskell.lib;
Expand Down Expand Up @@ -205,6 +219,14 @@ let iosSupport = system == "x86_64-darwin";
overrides = nixpkgsCross.ghcjs.haskell.overlays.combined;
};

wasm = ghcWasm32-8_6;
ghcWasm32-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable (nixpkgsCross.wasm.haskell.packages.ghcWasm.override (old: {
# Due to the splices changes the parallel build fails while building the libraries
ghc = old.ghc.overrideAttrs (drv: { enableParallelBuilding = false; });
}))).override {
overrides = nixpkgsCross.wasm.haskell.overlays.combined;
});

ghc = ghc8_6;
ghcHEAD = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghcHEAD).override {
overrides = nixpkgs.haskell.overlays.combined;
Expand Down Expand Up @@ -299,6 +321,7 @@ in let this = rec {
iosAarch32
iosAarch64
iosWithHaskellPackages
wasm
;

# Back compat
Expand Down
6 changes: 6 additions & 0 deletions haskell-overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ rec {

(optionalExtension (nixpkgs.stdenv.hostPlatform.useAndroidPrebuilt or false) android)
(optionalExtension (nixpkgs.stdenv.hostPlatform.isiOS or false) ios)
(optionalExtension (nixpkgs.stdenv.hostPlatform.isWasm or false) wasm)

user-custom-post
] self super;
Expand Down Expand Up @@ -156,6 +157,11 @@ rec {
inherit thunkSet;
};

wasm = import ./wasm {
inherit haskellLib;
inherit thunkSet;
};

user-custom-pre = foldExtensions haskellOverlaysPre;
user-custom-post = foldExtensions haskellOverlaysPost;
}
6 changes: 5 additions & 1 deletion haskell-overlays/reflex-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ in
])) {})
(drv: {
# Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ stdenv.lib.optionals (with stdenv.hostPlatform; isAndroid && is32bit) [
libraryHaskellDepends = (drv.libraryHaskellDepends or [])
++ stdenv.lib.optionals (with stdenv.hostPlatform; isAndroid && is32bit) [
self.android-activity
] ++ stdenv.lib.optionals (with stdenv.hostPlatform; isWasm && is32bit) [
self.jsaddle-wasm
];
});

Expand Down Expand Up @@ -129,6 +132,7 @@ in
jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" (jsaddleSrc + /jsaddle-warp) {});

jsaddle-dom = self.callCabal2nix "jsaddle-dom" self._dep.jsaddle-dom {};
jsaddle-wasm = self.callCabal2nix "jsaddle-wasm" self._dep.jsaddle-wasm {};
ghcjs-dom = self.callCabal2nix "ghcjs-dom" (self._dep.ghcjs-dom + "/ghcjs-dom") {};
ghcjs-dom-jsaddle = self.callCabal2nix "ghcjs-dom-jsaddle" (self._dep.ghcjs-dom + "/ghcjs-dom-jsaddle") {};
ghcjs-dom-jsffi = self.callCabal2nix "ghcjs-dom-jsffi" (self._dep.ghcjs-dom + "/ghcjs-dom-jsffi") {};
Expand Down
6 changes: 6 additions & 0 deletions haskell-overlays/reflex-packages/dep/jsaddle-wasm/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"owner": "WebGHC",
"repo": "jsaddle-wasm",
"rev": "54c66ac302942ff3d420f400d66a19b88044a964",
"sha256": "0qbwzpgzrswbmjzfdk4zhkh6q1fwpkw9qbcpgjqqcacs9ymyspni"
}
7 changes: 3 additions & 4 deletions haskell-overlays/reflex-packages/dep/reflex-dom/github.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"owner": "reflex-frp",
"owner": "dfordivam",
3noch marked this conversation as resolved.
Show resolved Hide resolved
"repo": "reflex-dom",
"branch": "master",
"rev": "94c26076a71f229b5bd27128cf6fc0dbcba011ac",
"sha256": "00sx5x51jv1j24qlhrbp5sqnqcyz1iy2sgjap0y97c4dkzxi3wd3"
"rev": "6699aa18f11ff8f18288d0944915ba188e28e2b0",
"sha256": "0dlvfs3zk9cv6mzh7024kpgw2kwsin73gmznaf4fdbg6ys9h9bj3"
}
23 changes: 23 additions & 0 deletions haskell-overlays/wasm/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ haskellLib
, thunkSet
}:
with haskellLib;
let
localDeps = thunkSet ./dep;
in self: super: {
# _dep = super._dep or {} // localDeps;
3noch marked this conversation as resolved.
Show resolved Hide resolved
jsaddle-warp = null;
jsaddle-webkitgtk = null;
jsaddle-webkit2gtk = null;
jsaddle-wkwebview = null;
mkDerivation = args: super.mkDerivation (args // {
dontStrip = true;
enableSharedExecutables = false;
enableSharedLibraries = false;
enableDeadCodeElimination = false;
doHaddock = false;
doCheck = false;
enableLibraryProfiling = false;
});
}

8 changes: 4 additions & 4 deletions nixpkgs/github.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"owner": "nixos",
"owner": "WebGHC",
"repo": "nixpkgs",
"branch": "release-19.09",
"rev": "49550f29cd9d6ed27f4a76ba3c3fe30edf882eb7",
"sha256": "003fpkrcc5mw33q670q4z865zpr430cllbxhyzj8k9p4hbc8yqda"
"branch": "wasm-r-p-1909-integ",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this? can this get merged to a main branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes like (lib/systems/doubles.nix) which cannot be put in upstream, neither can they be done via overlay, so we will have to use a fork.

Copy link
Member

@Ericson2314 Ericson2314 May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lib/systems/doubles.nix change looks good to upstream to me. Did someone say otherwise?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get a PR up make a ticket to check back on it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ericson2314 yes, now I realized that it should be possible to upstream that, even though the cross-compilation to wasm will still happen by overlays.

"rev": "423fa4adb6276298cde0c12205efeb7bf1cbe805",
"sha256": "0ssvc5j0p7nip0qsrdbfgc6wihzwyxa23hbr80dmjbfizywz7nzg"
}