summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/generic-builder.nix
diff options
context:
space:
mode:
authorCharles Strahan <charles.c.strahan@gmail.com>2016-02-17 22:07:32 -0500
committerCharles Strahan <charles.c.strahan@gmail.com>2016-02-18 03:15:59 -0500
commitbbce88302a98338f014e7978e128f438dec3cc2d (patch)
tree62c11184718051543c5b7fe915e7611eef221b0e /pkgs/development/haskell-modules/generic-builder.nix
parentde5a233a71213101ccb3e06bad6a33d088f9e7f9 (diff)
downloadnixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar.gz
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar.bz2
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar.lz
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar.xz
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.tar.zst
nixlib-bbce88302a98338f014e7978e128f438dec3cc2d.zip
ghcjs: fix building with cabal-install-1.22.8.0
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index e3847528ad00..d05980192831 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -36,6 +36,7 @@
 , testDepends ? [], testHaskellDepends ? [], testSystemDepends ? []
 , testTarget ? ""
 , broken ? false
+, preCompileBuildDriver ? "", postCompileBuildDriver ? ""
 , preUnpack ? "", postUnpack ? ""
 , patches ? [], patchPhase ? "", prePatch ? "", postPatch ? ""
 , preConfigure ? "", postConfigure ? ""
@@ -56,6 +57,7 @@ let
                        concatStringsSep enableFeature optionalAttrs toUpper;
 
   isGhcjs = ghc.isGhcjs or false;
+  nativeGhc = if isGhcjs then ghc.nativeGhc else ghc;
 
   newCabalFileUrl = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal";
   newCabalFile = fetchurl {
@@ -123,7 +125,15 @@ let
 
   ghcEnv = ghc.withPackages (p: haskellBuildInputs);
 
-  setupCommand = if isGhcjs then "${ghc.nodejs}/bin/node ./Setup.jsexe/all.js" else "./Setup";
+  setupBuilder = if isGhcjs
+                 then (if !(builtins.elem pname ["Cabal" "hscolour"])
+                       then ghcCommand
+                       else "${nativeGhc}/bin/ghc")
+                 else ghcCommand;
+
+  setupCommand = if isGhcjs && !(builtins.elem pname ["Cabal" "hscolour"])
+                 then "${ghc.nodejs}/bin/node ./Setup.jsexe/all.js"
+                 else "./Setup";
   ghcCommand = if isGhcjs then "ghcjs" else "ghc";
   ghcCommandCaps = toUpper ghcCommand;
 
@@ -199,7 +209,7 @@ stdenv.mkDerivation ({
     done
 
     echo setupCompileFlags: $setupCompileFlags
-    ${ghcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
+    ${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
 
     runHook postCompileBuildDriver
   '';
@@ -295,6 +305,8 @@ stdenv.mkDerivation ({
          ;
 
 }
+// optionalAttrs (preCompileBuildDriver != "")  { inherit preCompileBuildDriver; }
+// optionalAttrs (postCompileBuildDriver != "") { inherit postCompileBuildDriver; }
 // optionalAttrs (preUnpack != "")      { inherit preUnpack; }
 // optionalAttrs (postUnpack != "")     { inherit postUnpack; }
 // optionalAttrs (configureFlags != []) { inherit configureFlags; }