summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2015-01-13 22:15:29 +0100
committerPeter Simons <simons@cryp.to>2015-01-13 22:33:17 +0100
commit007628fd49bf005c90a721f70276db70fc207637 (patch)
tree2d97d2e9893359fefa6ecb94fe12f8cf43609024
parent67312f83ad8171579e25772e577c81b3fb8abdb9 (diff)
downloadnixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar.gz
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar.bz2
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar.lz
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar.xz
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.tar.zst
nixpkgs-007628fd49bf005c90a721f70276db70fc207637.zip
haskell-generic-builder: use cpphs pre-processor by default on Darwin
Allegedly, the cpp implementation of Clang is weird and causes errors.
-rw-r--r--pkgs/development/haskell-modules/default.nix11
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix8
2 files changed, 17 insertions, 2 deletions
diff --git a/pkgs/development/haskell-modules/default.nix b/pkgs/development/haskell-modules/default.nix
index ecfb5cf5c4e..8978486e930 100644
--- a/pkgs/development/haskell-modules/default.nix
+++ b/pkgs/development/haskell-modules/default.nix
@@ -25,6 +25,17 @@ let
           hyperlinkSource = false;      # Avoid depending on hscolour for this build.
           postFixup = "rm -rf $out/lib $out/share $out/nix-support";
         });
+        cpphs = overrideCabal (self.cpphs.overrideScope (self: super: {
+          mkDerivation = drv: super.mkDerivation (drv // {
+            enableSharedExecutables = false;
+            enableSharedLibraries = false;
+            noHaddock = true;
+            useCpphs = false;
+          });
+        })) (drv: {
+            isLibrary = false;
+            postFixup = "rm -rf $out/lib $out/share $out/nix-support";
+        });
       };
 
       overrideCabal = drv: f: drv.override (args: args // {
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index f8cca65aeb6..7290bb947e1 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused
-, jailbreak-cabal, hscolour
+, jailbreak-cabal, hscolour, cpphs
 }:
 
 { pname
@@ -39,7 +39,8 @@
 , preInstall ? "", postInstall ? ""
 , checkPhase ? "", preCheck ? "", postCheck ? ""
 , preFixup ? "", postFixup ? ""
-, coreSetup ? false # Use core packages to build Setup.hs
+, coreSetup ? false # Use only core packages to build Setup.hs.
+, useCpphs ? stdenv.isDarwin
 }:
 
 assert pkgconfigDepends != [] -> pkgconfig != null;
@@ -119,6 +120,9 @@ stdenv.mkDerivation ({
       setupCompileFlags="-j$NIX_BUILD_CORES"
     ''}${optionalString stdenv.isDarwin ''
       configureFlags+=" --with-gcc=$CC"  # Cabal won't find clang without help.
+    ''}${optionalString useCpphs ''
+      configureFlags+=" --with-cpphs=${cpphs}/bin/cpphs"
+      configureFlags+=" --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp"
     ''}
 
     packageConfDir="$TMP/package.conf.d"