diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix index d4c823f4a847..7706e849f504 100644 --- a/pkgs/build-support/cabal/default.nix +++ b/pkgs/build-support/cabal/default.nix @@ -1,6 +1,13 @@ # generic builder for Cabal packages -{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, enableLibraryProfiling ? false }: +{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal +, enableLibraryProfiling ? false +, enableCheckPhase ? true +}: + +# The Cabal library shipped with GHC versions older than 7.x doesn't accept the --enable-tests configure flag. +assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion; + { mkDerivation = args : # arguments for the individual package, can modify the defaults @@ -18,6 +25,7 @@ x : (removeAttrs x internalAttrs) // { buildInputs = stdenv.lib.filter (y : ! (y == null)) x.buildInputs; propagatedBuildInputs = stdenv.lib.filter (y : ! (y == null)) x.propagatedBuildInputs; + doCheck = enableCheckPhase && x.doCheck; }; defaults = @@ -92,7 +100,7 @@ # pass the '--enable-tests' flag to cabal in the configure stage # and run any regression test suites the package might have - doCheck = stdenv.lib.versionOlder "7.4" ghc.ghcVersion; + doCheck = enableCheckPhase; extraConfigureFlags = [ (stdenv.lib.enableFeature enableLibraryProfiling "library-profiling") diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 284824b8b9bf..82be9a4b7892 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -104,16 +104,13 @@ let result = let callPackage = x : y : modifyPrio (newScope result.final x y); cabal = callPackage ../build-support/cabal { enableLibraryProfiling = enableLibraryProfiling; + enableCheckPhase = pkgs.stdenv.lib.versionOlder "7.4" self.ghc.ghcVersion; }; # A variant of the cabal build driver that disables unit testing. # Useful for breaking cycles, where the unit test of a package A # depends on package B, which has A as a regular build input. - cabalNoTest = { - mkDerivation = x: rec { - final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); - }.final; - }; + cabalNoTest = self.cabal.override { enableCheckPhase = false; }; # Convenience helper function. disableTest = x: x.override { cabal = self.cabalNoTest; };