From 241f01ea4c645c6220e6e04bd145f4f33b02d1d5 Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Wed, 24 Jul 2019 22:42:12 +0100 Subject: [PATCH 1/2] Workaround for ghcjs hardcoding to linux --- default.nix | 1 + haskell-overlays/default.nix | 5 +++-- haskell-overlays/ghcjs.nix | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index ccb5a6e02..a13103e3b 100644 --- a/default.nix +++ b/default.nix @@ -43,6 +43,7 @@ let iosSupport = system == "x86_64-darwin"; inherit (self) lib; haskellLib = self.haskell.lib; inherit + system useFastWeak useReflexOptimizer enableLibraryProfiling enableTraceReflexEvents useTextJSString enableExposeAllUnfoldings haskellOverlays; diff --git a/haskell-overlays/default.nix b/haskell-overlays/default.nix index ca4a29d1f..ffff922ea 100644 --- a/haskell-overlays/default.nix +++ b/haskell-overlays/default.nix @@ -1,4 +1,5 @@ -{ lib +{ system +, lib , haskellLib , nixpkgs , useFastWeak, useReflexOptimizer, enableLibraryProfiling, enableTraceReflexEvents @@ -112,7 +113,7 @@ rec { # Just for GHCJS ghcjs = import ./ghcjs.nix { - inherit lib haskellLib nixpkgs fetchgit fetchFromGitHub useReflexOptimizer; + inherit system lib haskellLib nixpkgs fetchgit fetchFromGitHub useReflexOptimizer; }; ghcjs-fast-weak = import ./ghcjs-fast-weak { inherit lib; diff --git a/haskell-overlays/ghcjs.nix b/haskell-overlays/ghcjs.nix index ffe2c9303..74e2d8de9 100644 --- a/haskell-overlays/ghcjs.nix +++ b/haskell-overlays/ghcjs.nix @@ -1,8 +1,18 @@ -{ lib, haskellLib, nixpkgs, fetchgit, fetchFromGitHub, useReflexOptimizer }: +{ system, lib, haskellLib, nixpkgs, fetchgit, fetchFromGitHub, useReflexOptimizer }: with haskellLib; -self: super: { +self: super: + +let dontHardcodeLinux = package: cabalFile: + if ! self.ghc.isGhcjs then package + else nixpkgs.haskell.lib.overrideCabal package (drv: { + postPatch = (drv.postPatch or "") + nixpkgs.lib.optionalString (system == "x86_64-darwin") '' + substituteInPlace ${cabalFile}.cabal --replace 'if os(linux)' 'if os(linux) && !impl(ghcjs)' + substituteInPlace ${cabalFile}.cabal --replace 'if os(osx)' 'if os(linux) && impl(ghcjs)' + ''; + }); +in { _dep = super._dep or {} // { ghcjsBaseSrc = fetchgit { url = "https://github.com/ghcjs/ghcjs-base.git"; @@ -82,4 +92,6 @@ self: super: { sha256 = "1sy51nz096sv91nxqk6yk7b92b5a40axv9183xakvki2nc09yhqg"; }; })); + + foundation = dontHardcodeLinux super.foundation "foundation"; } From 2a07b9af75bf926177fd9f25fc109cabc8653ab0 Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Wed, 24 Jul 2019 23:02:04 +0100 Subject: [PATCH 2/2] Explain workaround in comment --- haskell-overlays/ghcjs.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/haskell-overlays/ghcjs.nix b/haskell-overlays/ghcjs.nix index 74e2d8de9..3bdec99a9 100644 --- a/haskell-overlays/ghcjs.nix +++ b/haskell-overlays/ghcjs.nix @@ -4,6 +4,8 @@ with haskellLib; self: super: +# Workaround for https://github.com/ghcjs/ghcjs/issues/674 +# 'os (osx)' will always evaluate to 'false' let dontHardcodeLinux = package: cabalFile: if ! self.ghc.isGhcjs then package else nixpkgs.haskell.lib.overrideCabal package (drv: {