nixpkgs/pkgs/build-support/cabal/default.nix

295 lines
13 KiB
Nix
Raw Normal View History

# generic builder for Cabal packages
{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
, gnugrep, coreutils, hscolour
haskell-packages.nix: fix the implementation of 'cabalNoTest' The previous implementation used the following tying-the-knot trickery to override 'doCheck' to false for the given build: cabalNoTest = { mkDerivation = x: rec { final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); }.final; }; That seemed to work, but for some reason it caused trouble with some builds -- not all -- that use jailbreakCabal. The problem was the 'stdenv' attribute couldn't be evaluated properly anymore: $ nix-build ~/pkgs/top-level/release-haskell.nix -A optparseApplicative.ghc6104.x86_64-linux --show-trace error: while evaluating the attribute `drvPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:19:9': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `haskell-optparse-applicative-ghc6.10.4-0.5.2.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `configurePhase' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:107:13': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/strings.nix:55:26': while evaluating the attribute `outPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:18:9': while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `jailbreak-cabal-1.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `nativeBuildInputs' at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:76:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/lists.nix:135:21': while evaluating the attribute `buildInputs' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:17': while evaluating the builtin function `filter': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:60': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:119:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:61:22': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:56:24': while evaluating the builtin function `isAttrs': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:1:1': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:113:20': while evaluating the attribute `final' at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:114:7': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:9:5': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:51:24': while evaluating the attribute `meta.license' at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:17:5': infinite recursion encountered I tried to figure out why this happens, but eventually gave up. The new implementation passes an argument called 'enableCheckPhase' to the Cabal builder, which determines whether the user-specified doCheck value has any effect or not. Now, a normal override can be used to disable unit testing.
2013-04-19 10:31:08 +02:00
, enableLibraryProfiling ? false
, enableSharedLibraries ? false
, enableSharedExecutables ? false
, enableStaticLibraries ? true
, enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
, enableHyperlinkSource ? true
Re-write the Haskell Platform out of haskell-defaults.nix. 1) Packages formerly called haskell-haskell-platform-ghcXYZ-VVVV.X.Y.Z are now called haskell-platform-VVVV.X.Y.Z. The latest version can be installed by running "nix-env -i haskell-platform". 2) The attributes haskellPackages_ghcXYZ.haskellPlatform no longer exist. Instead, we have attributes like haskellPlatformPackages."2012_4_0_0". (The last numeric bit must be quoted when used in a Nix file, but not on the command line to nix-env, nix-build, etc.) The latest Platform has a top-level alias called simply haskellPlatform. 3) The haskellPackages_ghcXYZ package sets offer the latest version of every library that GHC x.y.z can compile. For example, if 2.7 is the latest version of QuickCheck and if GHC 7.0.4 can compile that version, then haskellPackages_ghc704.QuickCheck refers to version 2.7. 4) All intermediate GHC releases were dropped from all-packages.nix to simplify our configuration. What remains is a haskellPackages_ghcXYZ set for the latest version of every major release branch, i.e. GHC 6.10.4, 6.12.3, 7.0.4, 7.2.2, 7.4.2, 7.6.3, 7.8.2, and 7.9.x (HEAD snapshot). 5) The ghcXYZPrefs functions in haskell-defaults.nix now inherit overrides from newer to older compilers, i.e. an override configured for GHC 7.0.4 will automatically apply to GHC 6.12.3 and 6.10.4, too. This change has reduced the redundancy in those configuration functions. The downside is that overriding an attribute for only one particular GHC version has become more difficult. In practice, this case doesn't occur much, though. 6) The 'cabal' builder has a brand-new argument called 'extension'. That function is "self : super : {}" by default and users can override it to mess with the attribute set passed to cabal.mkDerivation. An example use would be the definition of darcs in all-packages.nix: | darcs = haskellPackages.darcs.override { | cabal = haskellPackages.cabal.override { | extension = self : super : { | isLibrary = false; | configureFlags = "-f-library " + super.configureFlags or ""; | }; | }; | }; In this case, extension disables building the library part of the package to give us an executable-only version that has no dependencies on GHC or any other Haskell packages. The 'self' argument refers to the final version of the attribute set and 'super' refers to the original attribute set. Note that ... - Haskell Platform packages always provide the Haddock binary that came with the compiler. - Haskell Platform 2009.2.0.2 is broken because of build failures in cgi and cabal-install. - Haskell Platform 2010.1.0.0 is broken becasue of build failures in cgi.
2014-05-07 19:36:45 +02:00
, extension ? (self : super : {})
haskell-packages.nix: fix the implementation of 'cabalNoTest' The previous implementation used the following tying-the-knot trickery to override 'doCheck' to false for the given build: cabalNoTest = { mkDerivation = x: rec { final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); }.final; }; That seemed to work, but for some reason it caused trouble with some builds -- not all -- that use jailbreakCabal. The problem was the 'stdenv' attribute couldn't be evaluated properly anymore: $ nix-build ~/pkgs/top-level/release-haskell.nix -A optparseApplicative.ghc6104.x86_64-linux --show-trace error: while evaluating the attribute `drvPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:19:9': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `haskell-optparse-applicative-ghc6.10.4-0.5.2.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `configurePhase' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:107:13': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/strings.nix:55:26': while evaluating the attribute `outPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:18:9': while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `jailbreak-cabal-1.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `nativeBuildInputs' at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:76:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/lists.nix:135:21': while evaluating the attribute `buildInputs' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:17': while evaluating the builtin function `filter': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:60': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:119:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:61:22': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:56:24': while evaluating the builtin function `isAttrs': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:1:1': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:113:20': while evaluating the attribute `final' at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:114:7': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:9:5': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:51:24': while evaluating the attribute `meta.license' at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:17:5': infinite recursion encountered I tried to figure out why this happens, but eventually gave up. The new implementation passes an argument called 'enableCheckPhase' to the Cabal builder, which determines whether the user-specified doCheck value has any effect or not. Now, a normal override can be used to disable unit testing.
2013-04-19 10:31:08 +02:00
}:
let
enableFeature = stdenv.lib.enableFeature;
versionOlder = stdenv.lib.versionOlder;
optional = stdenv.lib.optional;
optionals = stdenv.lib.optionals;
optionalString = stdenv.lib.optionalString;
filter = stdenv.lib.filter;
defaultSetupHs = builtins.toFile "Setup.hs" ''
import Distribution.Simple
main = defaultMain
'';
in
# Cabal shipped with GHC 6.12.4 or earlier doesn't know the "--enable-tests configure" flag.
assert enableCheckPhase -> versionOlder "7" ghc.version;
# GHC prior to 7.4.x doesn't know the "--enable-executable-dynamic" flag.
assert enableSharedExecutables -> versionOlder "7.4" ghc.version;
# Our GHC 6.10.x builds do not provide sharable versions of their core libraries.
assert enableSharedLibraries -> versionOlder "6.12" ghc.version;
haskell-packages.nix: fix the implementation of 'cabalNoTest' The previous implementation used the following tying-the-knot trickery to override 'doCheck' to false for the given build: cabalNoTest = { mkDerivation = x: rec { final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); }.final; }; That seemed to work, but for some reason it caused trouble with some builds -- not all -- that use jailbreakCabal. The problem was the 'stdenv' attribute couldn't be evaluated properly anymore: $ nix-build ~/pkgs/top-level/release-haskell.nix -A optparseApplicative.ghc6104.x86_64-linux --show-trace error: while evaluating the attribute `drvPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:19:9': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `haskell-optparse-applicative-ghc6.10.4-0.5.2.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `configurePhase' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:107:13': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/strings.nix:55:26': while evaluating the attribute `outPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:18:9': while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `jailbreak-cabal-1.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `nativeBuildInputs' at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:76:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/lists.nix:135:21': while evaluating the attribute `buildInputs' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:17': while evaluating the builtin function `filter': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:60': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:119:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:61:22': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:56:24': while evaluating the builtin function `isAttrs': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:1:1': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:113:20': while evaluating the attribute `final' at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:114:7': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:9:5': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:51:24': while evaluating the attribute `meta.license' at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:17:5': infinite recursion encountered I tried to figure out why this happens, but eventually gave up. The new implementation passes an argument called 'enableCheckPhase' to the Cabal builder, which determines whether the user-specified doCheck value has any effect or not. Now, a normal override can be used to disable unit testing.
2013-04-19 10:31:08 +02:00
2014-07-10 13:17:21 +02:00
# Pure shared library builds don't work before GHC 7.8.x.
assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
{
mkDerivation =
args : # arguments for the individual package, can modify the defaults
let # These attributes are removed in the end. This is in order not to spoil the build
# environment overly, but also to keep hash-backwards-compatible with the old cabal.nix.
internalAttrs = [
"internalAttrs" "buildDepends" "buildTools" "extraLibraries" "pkgconfigDepends"
"isLibrary" "isExecutable" "testDepends"
];
# Stuff happening after the user preferences have been processed. We remove
# internal attributes and strip null elements from the dependency lists, all
# in the interest of keeping hashes stable.
postprocess =
x : (removeAttrs x internalAttrs) // {
buildInputs = filter (y : ! (y == null)) x.buildInputs;
propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
haskell-packages.nix: fix the implementation of 'cabalNoTest' The previous implementation used the following tying-the-knot trickery to override 'doCheck' to false for the given build: cabalNoTest = { mkDerivation = x: rec { final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); }.final; }; That seemed to work, but for some reason it caused trouble with some builds -- not all -- that use jailbreakCabal. The problem was the 'stdenv' attribute couldn't be evaluated properly anymore: $ nix-build ~/pkgs/top-level/release-haskell.nix -A optparseApplicative.ghc6104.x86_64-linux --show-trace error: while evaluating the attribute `drvPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:19:9': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `haskell-optparse-applicative-ghc6.10.4-0.5.2.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `configurePhase' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:107:13': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/strings.nix:55:26': while evaluating the attribute `outPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:18:9': while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `jailbreak-cabal-1.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `nativeBuildInputs' at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:76:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/lists.nix:135:21': while evaluating the attribute `buildInputs' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:17': while evaluating the builtin function `filter': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:60': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:119:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:61:22': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:56:24': while evaluating the builtin function `isAttrs': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:1:1': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:113:20': while evaluating the attribute `final' at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:114:7': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:9:5': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:51:24': while evaluating the attribute `meta.license' at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:17:5': infinite recursion encountered I tried to figure out why this happens, but eventually gave up. The new implementation passes an argument called 'enableCheckPhase' to the Cabal builder, which determines whether the user-specified doCheck value has any effect or not. Now, a normal override can be used to disable unit testing.
2013-04-19 10:31:08 +02:00
doCheck = enableCheckPhase && x.doCheck;
hyperlinkSource = enableHyperlinkSource && x.hyperlinkSource;
};
defaults =
self : { # self is the final version of the attribute set
# pname should be defined by the client to be the package basename
# version should be defined by the client to be the package version
# fname is the internal full name of the package
fname = "${self.pname}-${self.version}";
# name is the external full name of the package; usually we prefix
# all packages with haskell- to avoid name clashes for libraries;
# if that is not desired (for applications), name can be set to
# fname.
name = if self.isLibrary then
if enableLibraryProfiling && self.enableSharedLibraries then
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling-shared"
else if enableLibraryProfiling && !self.enableSharedLibraries then
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling"
else if !enableLibraryProfiling && self.enableSharedLibraries then
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-shared"
else
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}"
else
"${self.pname}-${self.version}";
# the default download location for Cabal packages is Hackage,
# you still have to specify the checksum
src = fetchurl {
url = "mirror://hackage/${self.pname}/${self.fname}.tar.gz";
inherit (self) sha256;
};
# default buildInputs are just ghc, if more buildInputs are required
# buildInputs can be extended by the client by using extraBuildInputs,
# but often propagatedBuildInputs is preferable anyway
buildInputs = [ghc Cabal] ++ self.extraBuildInputs;
extraBuildInputs = self.buildTools ++
(optionals self.doCheck self.testDepends) ++
(optional self.hyperlinkSource hscolour) ++
(if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
(if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
# we make sure that propagatedBuildInputs is defined, so that we don't
# have to check for its existence
propagatedBuildInputs = if self.isLibrary then self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends else [];
# By default, also propagate all dependencies to the user environment. This is required, otherwise packages would be broken, because
# GHC also needs all dependencies to be available.
propagatedUserEnvPkgs = if self.isLibrary then self.buildDepends else [];
# library directories that have to be added to the Cabal files
extraLibDirs = [];
# build-depends Cabal field
buildDepends = [];
# target(s) passed to the cabal build phase as an argument
buildTarget = "";
# build-depends Cabal fields stated in test-suite stanzas
testDepends = [];
# target(s) passed to the cabal test phase as an argument
testTarget = "";
# build-tools Cabal field
buildTools = [];
# extra-libraries Cabal field
extraLibraries = [];
# pkgconfig-depends Cabal field
pkgconfigDepends = [];
isLibrary = ! self.isExecutable;
isExecutable = false;
# ignore version restrictions on the build inputs that the cabal file might specify
jailbreak = false;
# pass the '--enable-split-objs' flag to cabal in the configure stage
enableSplitObjs = !stdenv.isDarwin; # http://hackage.haskell.org/trac/ghc/ticket/4013
# pass the '--enable-tests' flag to cabal in the configure stage
# and run any regression test suites the package might have
haskell-packages.nix: fix the implementation of 'cabalNoTest' The previous implementation used the following tying-the-knot trickery to override 'doCheck' to false for the given build: cabalNoTest = { mkDerivation = x: rec { final = self.cabal.mkDerivation (self: (x final) // { doCheck = false; }); }.final; }; That seemed to work, but for some reason it caused trouble with some builds -- not all -- that use jailbreakCabal. The problem was the 'stdenv' attribute couldn't be evaluated properly anymore: $ nix-build ~/pkgs/top-level/release-haskell.nix -A optparseApplicative.ghc6104.x86_64-linux --show-trace error: while evaluating the attribute `drvPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:19:9': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `haskell-optparse-applicative-ghc6.10.4-0.5.2.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `configurePhase' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:107:13': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/strings.nix:55:26': while evaluating the attribute `outPath' at `/nix/store/qkj5cxknwspz8ak0ganm97zfr2bhksgn-nix-1.5.2pre3082_2398417/share/nix/corepkgs/derivation.nix:18:9': while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `jailbreak-cabal-1.1' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:40:13': while evaluating the derivation attribute `nativeBuildInputs' at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:76:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/lists.nix:135:21': while evaluating the attribute `buildInputs' at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:17': while evaluating the builtin function `filter': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:22:60': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:119:17': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:61:22': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/lib/customisation.nix:56:24': while evaluating the builtin function `isAttrs': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:1:1': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:113:20': while evaluating the attribute `final' at `/home/simons/.nix-defexpr/pkgs/top-level/haskell-packages.nix:114:7': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/build-support/cabal/default.nix:9:5': while evaluating the function at `/home/simons/.nix-defexpr/pkgs/stdenv/generic/default.nix:51:24': while evaluating the attribute `meta.license' at `/home/simons/.nix-defexpr/pkgs/development/libraries/haskell/Cabal/1.14.0.nix:17:5': infinite recursion encountered I tried to figure out why this happens, but eventually gave up. The new implementation passes an argument called 'enableCheckPhase' to the Cabal builder, which determines whether the user-specified doCheck value has any effect or not. Now, a normal override can be used to disable unit testing.
2013-04-19 10:31:08 +02:00
doCheck = enableCheckPhase;
# pass the '--hyperlink-source' flag to ./Setup haddock
hyperlinkSource = enableHyperlinkSource;
# abort the build if the configure phase detects that the package
# depends on multiple versions of the same build input
strictConfigurePhase = true;
# pass the '--enable-library-vanilla' flag to cabal in the
# configure stage to enable building shared libraries
inherit enableStaticLibraries;
# pass the '--enable-shared' flag to cabal in the configure
# stage to enable building shared libraries
inherit enableSharedLibraries;
# pass the '--enable-executable-dynamic' flag to cabal in
# the configure stage to enable linking shared libraries
inherit enableSharedExecutables;
extraConfigureFlags = [
(enableFeature self.enableSplitObjs "split-objs")
(enableFeature enableLibraryProfiling "library-profiling")
(enableFeature self.enableSharedLibraries "shared")
(optional (versionOlder "7" ghc.version) (enableFeature self.enableStaticLibraries "library-vanilla"))
(optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic"))
(optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests"))
];
# GHC needs the locale configured during the Haddock phase.
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
# compiles Setup and configures
configurePhase = ''
eval "$preConfigure"
${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
for i in Setup.hs Setup.lhs ${defaultSetupHs}; do
test -f $i && break
done
ghc --make -o Setup -odir $TMPDIR $i
for p in $extraBuildInputs $propagatedNativeBuildInputs; do
if [ -d "$p/lib/ghc-${ghc.ghc.version}/package.conf.d" ]; then
# Haskell packages don't need any extra configuration.
continue;
fi
if [ -d "$p/include" ]; then
extraConfigureFlags+=" --extra-include-dirs=$p/include"
fi
for d in lib{,64}; do
if [ -d "$p/$d" ]; then
extraConfigureFlags+=" --extra-lib-dirs=$p/$d"
fi
done
done
${optionalString (self.enableSharedExecutables && self.stdenv.isLinux) ''
2014-08-16 17:37:42 +02:00
configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}"
''}
${optionalString (self.enableSharedExecutables && self.stdenv.isDarwin) ''
2014-08-16 17:37:42 +02:00
configureFlags+=" --ghc-option=-optl=-Wl,-headerpad_max_install_names"
''}
${optionalString (versionOlder "7.8" ghc.version) ''
configureFlags+=" --ghc-option=-j$NIX_BUILD_CORES"
''}
echo "configure flags: $extraConfigureFlags $configureFlags"
./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' \
--libsubdir='$pkgid' $extraConfigureFlags $configureFlags 2>&1 \
${optionalString self.strictConfigurePhase ''
| ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
if ${gnugrep}/bin/egrep -q '^Warning:.*depends on multiple versions' "$NIX_BUILD_TOP/cabal-configure.log"; then
echo >&2 "*** abort because of serious configure-time warning from Cabal"
exit 1
fi
''}
eval "$postConfigure"
'';
# builds via Cabal
buildPhase = ''
eval "$preBuild"
./Setup build ${self.buildTarget}
export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
test -n "$noHaddock" || ./Setup haddock --html --hoogle \
${optionalString self.hyperlinkSource "--hyperlink-source"}
eval "$postBuild"
'';
checkPhase = optional self.doCheck ''
eval "$preCheck"
./Setup test ${self.testTarget}
eval "$postCheck"
'';
# installs via Cabal; creates a registration file for nix-support
# so that the package can be used in other Haskell-builds; also
# adds all propagated build inputs to the user environment packages
installPhase = ''
eval "$preInstall"
./Setup copy
mkdir -p $out/bin # necessary to get it added to PATH
local confDir=$out/lib/ghc-${ghc.ghc.version}/package.conf.d
local installedPkgConf=$confDir/${self.fname}.installedconf
local pkgConf=$confDir/${self.fname}.conf
mkdir -p $confDir
./Setup register --gen-pkg-config=$pkgConf
if test -f $pkgConf; then
echo '[]' > $installedPkgConf
GHC_PACKAGE_PATH=$installedPkgConf ghc-pkg --global register $pkgConf --force
fi
if test -f $out/nix-support/propagated-native-build-inputs; then
ln -s $out/nix-support/propagated-native-build-inputs $out/nix-support/propagated-user-env-packages
fi
${optionalString (self.enableSharedExecutables && self.isExecutable && self.stdenv.isDarwin) ''
for exe in "$out/bin/"* ; do
install_name_tool -add_rpath \
$out/lib/${ghc.ghc.name}/${self.pname}-${self.version} $exe
done
''}
eval "$postInstall"
'';
# We inherit stdenv and ghc so that they can be used
# in Cabal derivations.
inherit stdenv ghc;
};
Re-write the Haskell Platform out of haskell-defaults.nix. 1) Packages formerly called haskell-haskell-platform-ghcXYZ-VVVV.X.Y.Z are now called haskell-platform-VVVV.X.Y.Z. The latest version can be installed by running "nix-env -i haskell-platform". 2) The attributes haskellPackages_ghcXYZ.haskellPlatform no longer exist. Instead, we have attributes like haskellPlatformPackages."2012_4_0_0". (The last numeric bit must be quoted when used in a Nix file, but not on the command line to nix-env, nix-build, etc.) The latest Platform has a top-level alias called simply haskellPlatform. 3) The haskellPackages_ghcXYZ package sets offer the latest version of every library that GHC x.y.z can compile. For example, if 2.7 is the latest version of QuickCheck and if GHC 7.0.4 can compile that version, then haskellPackages_ghc704.QuickCheck refers to version 2.7. 4) All intermediate GHC releases were dropped from all-packages.nix to simplify our configuration. What remains is a haskellPackages_ghcXYZ set for the latest version of every major release branch, i.e. GHC 6.10.4, 6.12.3, 7.0.4, 7.2.2, 7.4.2, 7.6.3, 7.8.2, and 7.9.x (HEAD snapshot). 5) The ghcXYZPrefs functions in haskell-defaults.nix now inherit overrides from newer to older compilers, i.e. an override configured for GHC 7.0.4 will automatically apply to GHC 6.12.3 and 6.10.4, too. This change has reduced the redundancy in those configuration functions. The downside is that overriding an attribute for only one particular GHC version has become more difficult. In practice, this case doesn't occur much, though. 6) The 'cabal' builder has a brand-new argument called 'extension'. That function is "self : super : {}" by default and users can override it to mess with the attribute set passed to cabal.mkDerivation. An example use would be the definition of darcs in all-packages.nix: | darcs = haskellPackages.darcs.override { | cabal = haskellPackages.cabal.override { | extension = self : super : { | isLibrary = false; | configureFlags = "-f-library " + super.configureFlags or ""; | }; | }; | }; In this case, extension disables building the library part of the package to give us an executable-only version that has no dependencies on GHC or any other Haskell packages. The 'self' argument refers to the final version of the attribute set and 'super' refers to the original attribute set. Note that ... - Haskell Platform packages always provide the Haddock binary that came with the compiler. - Haskell Platform 2009.2.0.2 is broken because of build failures in cgi and cabal-install. - Haskell Platform 2010.1.0.0 is broken becasue of build failures in cgi.
2014-05-07 19:36:45 +02:00
in
stdenv.mkDerivation (postprocess (let super = defaults self // args self;
self = super // extension self super;
in self));
}