2008-01-22 17:26:57 +01:00
|
|
|
# generic builder for Cabal packages
|
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
|
2015-01-08 18:55:11 +01:00
|
|
|
, gnugrep, coreutils, hscolour, cpphs
|
2013-04-19 10:31:08 +02:00
|
|
|
, enableLibraryProfiling ? false
|
2013-10-26 18:33:09 +02:00
|
|
|
, enableSharedLibraries ? false
|
|
|
|
, enableSharedExecutables ? false
|
2013-12-06 12:52:18 +01:00
|
|
|
, enableStaticLibraries ? true
|
2013-10-26 18:33:09 +02:00
|
|
|
, enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
|
2014-05-30 03:00:04 +02:00
|
|
|
, enableHyperlinkSource ? true
|
2015-01-08 18:55:11 +01:00
|
|
|
, enableCpphs ? false
|
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 : {})
|
2013-04-19 10:31:08 +02:00
|
|
|
}:
|
|
|
|
|
2013-10-26 18:33:09 +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;
|
2014-08-16 17:37:16 +02:00
|
|
|
|
|
|
|
defaultSetupHs = builtins.toFile "Setup.hs" ''
|
|
|
|
import Distribution.Simple
|
|
|
|
main = defaultMain
|
|
|
|
'';
|
2013-10-26 18:33:09 +02:00
|
|
|
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;
|
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.
|
2013-12-06 12:52:18 +01:00
|
|
|
assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
|
|
|
|
|
2008-01-22 17:26:57 +01:00
|
|
|
{
|
|
|
|
mkDerivation =
|
2011-03-12 18:28:15 +01:00
|
|
|
args : # arguments for the individual package, can modify the defaults
|
2011-08-08 16:12:07 +02:00
|
|
|
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"
|
2013-02-24 21:15:25 +01:00
|
|
|
"isLibrary" "isExecutable" "testDepends"
|
2011-08-08 16:12:07 +02:00
|
|
|
];
|
|
|
|
|
2011-08-09 16:55:53 +02:00
|
|
|
# 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) // {
|
2013-10-26 18:33:09 +02:00
|
|
|
buildInputs = filter (y : ! (y == null)) x.buildInputs;
|
|
|
|
propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
|
2013-11-17 13:09:01 +01:00
|
|
|
propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
|
2013-04-19 10:31:08 +02:00
|
|
|
doCheck = enableCheckPhase && x.doCheck;
|
2015-01-08 18:55:11 +01:00
|
|
|
useCpphs = enableCpphs && x.useCpphs;
|
2014-05-30 03:00:04 +02:00
|
|
|
hyperlinkSource = enableHyperlinkSource && x.hyperlinkSource;
|
2014-10-21 23:30:55 +02:00
|
|
|
# Disable Darwin builds: <https://github.com/NixOS/nixpkgs/issues/2689>.
|
2014-10-22 00:23:12 +02:00
|
|
|
meta = let meta = x.meta or {};
|
2014-10-21 23:30:55 +02:00
|
|
|
hydraPlatforms = meta.hydraPlatforms or meta.platforms or [];
|
|
|
|
noElem = p: ps: !stdenv.lib.elem p ps;
|
|
|
|
noDarwin = p: noElem p stdenv.lib.platforms.darwin;
|
|
|
|
in
|
|
|
|
meta // { hydraPlatforms = filter noDarwin hydraPlatforms; };
|
2011-08-09 16:55:53 +02:00
|
|
|
};
|
|
|
|
|
2011-08-08 16:12:07 +02:00
|
|
|
defaults =
|
2011-03-12 18:28:15 +01:00
|
|
|
self : { # self is the final version of the attribute set
|
2008-01-22 17:26:57 +01:00
|
|
|
|
|
|
|
# pname should be defined by the client to be the package basename
|
|
|
|
# version should be defined by the client to be the package version
|
2010-01-05 16:17:17 +01:00
|
|
|
|
2008-01-22 17:26:57 +01:00
|
|
|
# fname is the internal full name of the package
|
|
|
|
fname = "${self.pname}-${self.version}";
|
|
|
|
|
2010-01-05 16:17:17 +01:00
|
|
|
# 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.
|
2011-08-08 16:12:07 +02:00
|
|
|
name = if self.isLibrary then
|
2013-10-26 18:33:09 +02:00
|
|
|
if enableLibraryProfiling && self.enableSharedLibraries then
|
|
|
|
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling-shared"
|
|
|
|
else if enableLibraryProfiling && !self.enableSharedLibraries then
|
2011-08-08 16:12:07 +02:00
|
|
|
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling"
|
2013-10-26 18:33:09 +02:00
|
|
|
else if !enableLibraryProfiling && self.enableSharedLibraries then
|
|
|
|
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-shared"
|
2011-08-08 16:12:07 +02:00
|
|
|
else
|
|
|
|
"haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}"
|
2010-04-27 18:35:01 +02:00
|
|
|
else
|
2011-08-08 16:12:07 +02:00
|
|
|
"${self.pname}-${self.version}";
|
2008-01-22 17:26:57 +01:00
|
|
|
|
|
|
|
# the default download location for Cabal packages is Hackage,
|
|
|
|
# you still have to specify the checksum
|
2010-04-27 18:34:56 +02:00
|
|
|
src = fetchurl {
|
2014-06-28 20:01:40 +02:00
|
|
|
url = "mirror://hackage/${self.pname}/${self.fname}.tar.gz";
|
2008-01-22 17:26:57 +01:00
|
|
|
inherit (self) sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# default buildInputs are just ghc, if more buildInputs are required
|
2008-01-22 22:10:19 +01:00
|
|
|
# buildInputs can be extended by the client by using extraBuildInputs,
|
|
|
|
# but often propagatedBuildInputs is preferable anyway
|
2012-02-16 15:05:01 +01:00
|
|
|
buildInputs = [ghc Cabal] ++ self.extraBuildInputs;
|
2011-08-08 16:12:07 +02:00
|
|
|
extraBuildInputs = self.buildTools ++
|
2013-10-26 18:33:09 +02:00
|
|
|
(optionals self.doCheck self.testDepends) ++
|
2014-05-30 03:00:04 +02:00
|
|
|
(optional self.hyperlinkSource hscolour) ++
|
2015-01-08 18:55:11 +01:00
|
|
|
(optional self.useCpphs cpphs) ++
|
2011-08-08 16:12:07 +02:00
|
|
|
(if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
|
|
|
|
(if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
|
2008-01-22 17:26:57 +01:00
|
|
|
|
|
|
|
# we make sure that propagatedBuildInputs is defined, so that we don't
|
|
|
|
# have to check for its existence
|
2011-08-08 16:12:07 +02:00
|
|
|
propagatedBuildInputs = if self.isLibrary then self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends else [];
|
2008-01-22 17:26:57 +01:00
|
|
|
|
2013-11-17 13:09:01 +01:00
|
|
|
# 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 [];
|
|
|
|
|
2008-01-22 17:26:57 +01:00
|
|
|
# library directories that have to be added to the Cabal files
|
2010-01-04 08:44:32 +01:00
|
|
|
extraLibDirs = [];
|
2008-01-22 17:26:57 +01:00
|
|
|
|
2011-08-08 16:12:07 +02:00
|
|
|
# build-depends Cabal field
|
|
|
|
buildDepends = [];
|
|
|
|
|
2013-12-16 21:21:31 +01:00
|
|
|
# target(s) passed to the cabal build phase as an argument
|
|
|
|
buildTarget = "";
|
|
|
|
|
2013-02-24 21:15:25 +01:00
|
|
|
# build-depends Cabal fields stated in test-suite stanzas
|
|
|
|
testDepends = [];
|
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
# target(s) passed to the cabal test phase as an argument
|
|
|
|
testTarget = "";
|
|
|
|
|
2011-08-08 16:12:07 +02:00
|
|
|
# build-tools Cabal field
|
|
|
|
buildTools = [];
|
|
|
|
|
|
|
|
# extra-libraries Cabal field
|
|
|
|
extraLibraries = [];
|
|
|
|
|
|
|
|
# pkgconfig-depends Cabal field
|
|
|
|
pkgconfigDepends = [];
|
|
|
|
|
|
|
|
isLibrary = ! self.isExecutable;
|
|
|
|
isExecutable = false;
|
|
|
|
|
2013-02-18 12:32:15 +01:00
|
|
|
# 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
|
2014-05-07 11:56:23 +02:00
|
|
|
enableSplitObjs = !stdenv.isDarwin; # http://hackage.haskell.org/trac/ghc/ticket/4013
|
2013-02-18 12:32:15 +01:00
|
|
|
|
2013-02-24 21:15:43 +01:00
|
|
|
# pass the '--enable-tests' flag to cabal in the configure stage
|
|
|
|
# and run any regression test suites the package might have
|
2013-04-19 10:31:08 +02:00
|
|
|
doCheck = enableCheckPhase;
|
2013-02-24 21:15:43 +01:00
|
|
|
|
2015-01-08 18:55:11 +01:00
|
|
|
# force cpphs instead of the C compiler's preprocessor; sometimes
|
|
|
|
# needed due to clang's wacky behavior
|
|
|
|
useCpphs = false;
|
|
|
|
|
2014-05-30 03:00:04 +02:00
|
|
|
# pass the '--hyperlink-source' flag to ./Setup haddock
|
|
|
|
hyperlinkSource = enableHyperlinkSource;
|
|
|
|
|
2013-12-26 20:14:31 +01:00
|
|
|
# abort the build if the configure phase detects that the package
|
|
|
|
# depends on multiple versions of the same build input
|
|
|
|
strictConfigurePhase = true;
|
|
|
|
|
2013-12-06 12:52:18 +01:00
|
|
|
# pass the '--enable-library-vanilla' flag to cabal in the
|
|
|
|
# configure stage to enable building shared libraries
|
|
|
|
inherit enableStaticLibraries;
|
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
# 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;
|
|
|
|
|
2013-02-24 21:14:01 +01:00
|
|
|
extraConfigureFlags = [
|
2013-10-26 18:33:09 +02:00
|
|
|
(enableFeature self.enableSplitObjs "split-objs")
|
|
|
|
(enableFeature enableLibraryProfiling "library-profiling")
|
|
|
|
(enableFeature self.enableSharedLibraries "shared")
|
2013-12-06 12:52:18 +01:00
|
|
|
(optional (versionOlder "7" ghc.version) (enableFeature self.enableStaticLibraries "library-vanilla"))
|
2013-10-26 18:33:09 +02:00
|
|
|
(optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic"))
|
|
|
|
(optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests"))
|
2013-12-16 21:20:49 +01:00
|
|
|
];
|
2013-10-26 18:33:09 +02:00
|
|
|
|
|
|
|
# GHC needs the locale configured during the Haddock phase.
|
|
|
|
LANG = "en_US.UTF-8";
|
|
|
|
LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
|
2013-02-18 12:32:15 +01:00
|
|
|
|
2009-04-21 23:05:30 +02:00
|
|
|
# compiles Setup and configures
|
2008-01-22 17:26:57 +01:00
|
|
|
configurePhase = ''
|
|
|
|
eval "$preConfigure"
|
|
|
|
|
2014-11-25 13:22:45 +01:00
|
|
|
${let newCabalFile = fetchurl {
|
|
|
|
url = "http://hackage.haskell.org/package/${self.fname}/${self.pname}.cabal";
|
|
|
|
sha256 = self.editedCabalFile;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
optionalString (self.editedCabalFile or "" != "") ''
|
|
|
|
echo "Replace Cabal file with edited version ${newCabalFile}."
|
|
|
|
cp ${newCabalFile} ${self.pname}.cabal
|
|
|
|
''
|
|
|
|
}${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
|
2013-02-24 19:27:08 +01:00
|
|
|
|
2014-08-16 17:37:16 +02:00
|
|
|
for i in Setup.hs Setup.lhs ${defaultSetupHs}; do
|
|
|
|
test -f $i && break
|
2008-01-22 17:26:57 +01:00
|
|
|
done
|
2014-11-06 14:05:44 +01:00
|
|
|
ghc --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
|
2010-01-04 08:44:32 +01:00
|
|
|
|
2012-12-28 19:20:09 +01:00
|
|
|
for p in $extraBuildInputs $propagatedNativeBuildInputs; do
|
2013-10-26 18:33:09 +02:00
|
|
|
if [ -d "$p/lib/ghc-${ghc.ghc.version}/package.conf.d" ]; then
|
|
|
|
# Haskell packages don't need any extra configuration.
|
|
|
|
continue;
|
|
|
|
fi
|
2010-07-22 20:04:39 +02:00
|
|
|
if [ -d "$p/include" ]; then
|
2013-10-26 18:33:09 +02:00
|
|
|
extraConfigureFlags+=" --extra-include-dirs=$p/include"
|
2010-07-22 20:04:39 +02:00
|
|
|
fi
|
2010-01-04 08:44:32 +01:00
|
|
|
for d in lib{,64}; do
|
2010-07-22 20:04:39 +02:00
|
|
|
if [ -d "$p/$d" ]; then
|
2013-10-26 18:33:09 +02:00
|
|
|
extraConfigureFlags+=" --extra-lib-dirs=$p/$d"
|
2010-01-04 08:44:32 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2014-12-17 19:11:30 +01:00
|
|
|
configureFlags+=" --with-gcc=$CC"
|
|
|
|
|
2014-05-01 23:14:55 +02:00
|
|
|
${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}"
|
2014-05-01 23:14:55 +02:00
|
|
|
''}
|
2014-05-25 10:29:24 +02:00
|
|
|
${optionalString (self.enableSharedExecutables && self.stdenv.isDarwin) ''
|
2014-08-16 17:37:42 +02:00
|
|
|
configureFlags+=" --ghc-option=-optl=-Wl,-headerpad_max_install_names"
|
2014-05-25 10:29:24 +02:00
|
|
|
''}
|
2014-08-16 17:42:11 +02:00
|
|
|
${optionalString (versionOlder "7.8" ghc.version && !self.isLibrary) ''
|
|
|
|
configureFlags+=" --ghc-option=-j$NIX_BUILD_CORES"
|
|
|
|
''}
|
2015-01-08 18:55:11 +01:00
|
|
|
${optionalString self.useCpphs ''
|
|
|
|
configureFlags+=" --ghc-option=-pgmPcpphs --ghc-option=-optP--cpp"
|
|
|
|
''}
|
2014-05-01 23:14:55 +02:00
|
|
|
|
2014-08-17 22:17:13 +02:00
|
|
|
${optionalString self.stdenv.isDarwin ''
|
|
|
|
configureFlags+=" --with-gcc=clang"
|
|
|
|
''}
|
|
|
|
|
2013-02-24 21:14:01 +01:00
|
|
|
echo "configure flags: $extraConfigureFlags $configureFlags"
|
2013-12-24 17:49:48 +01:00
|
|
|
./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' \
|
|
|
|
--libsubdir='$pkgid' $extraConfigureFlags $configureFlags 2>&1 \
|
2013-12-26 20:14:31 +01:00
|
|
|
${optionalString self.strictConfigurePhase ''
|
2013-12-24 17:49:48 +01:00
|
|
|
| ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
|
2013-12-26 20:14:31 +01:00
|
|
|
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
|
|
|
|
''}
|
2008-01-22 17:26:57 +01:00
|
|
|
|
|
|
|
eval "$postConfigure"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# builds via Cabal
|
|
|
|
buildPhase = ''
|
|
|
|
eval "$preBuild"
|
|
|
|
|
2013-12-16 21:21:31 +01:00
|
|
|
./Setup build ${self.buildTarget}
|
2008-01-22 17:26:57 +01:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
|
2014-05-30 03:00:04 +02:00
|
|
|
test -n "$noHaddock" || ./Setup haddock --html --hoogle \
|
2014-11-15 18:10:23 +01:00
|
|
|
${optionalString (stdenv.lib.versionOlder "6.12" ghc.version) "--ghc-options=-optP-P"} \
|
2015-01-08 18:55:11 +01:00
|
|
|
${optionalString self.hyperlinkSource "--hyperlink-source"} \
|
|
|
|
${optionalString self.useCpphs ''
|
|
|
|
--haddock-options="--optghc=-pgmPcpphs --optghc=-optP--cpp"
|
|
|
|
''}
|
2010-01-05 16:17:17 +01:00
|
|
|
|
2008-01-22 17:26:57 +01:00
|
|
|
eval "$postBuild"
|
|
|
|
'';
|
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
checkPhase = optional self.doCheck ''
|
2013-02-24 21:48:36 +01:00
|
|
|
eval "$preCheck"
|
2013-02-24 19:27:08 +01:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
./Setup test ${self.testTarget}
|
2013-02-24 19:27:08 +01:00
|
|
|
|
2013-02-24 21:48:36 +01:00
|
|
|
eval "$postCheck"
|
2013-02-24 19:27:08 +01:00
|
|
|
'';
|
|
|
|
|
2010-01-05 16:17:17 +01:00
|
|
|
# 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
|
2008-01-22 17:26:57 +01:00
|
|
|
installPhase = ''
|
|
|
|
eval "$preInstall"
|
|
|
|
|
|
|
|
./Setup copy
|
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/bin # necessary to get it added to PATH
|
2009-04-25 16:23:00 +02:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
local confDir=$out/lib/ghc-${ghc.ghc.version}/package.conf.d
|
2009-04-25 16:23:00 +02:00
|
|
|
local installedPkgConf=$confDir/${self.fname}.installedconf
|
|
|
|
local pkgConf=$confDir/${self.fname}.conf
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $confDir
|
2009-04-25 16:23:00 +02:00
|
|
|
./Setup register --gen-pkg-config=$pkgConf
|
|
|
|
if test -f $pkgConf; then
|
|
|
|
echo '[]' > $installedPkgConf
|
|
|
|
GHC_PACKAGE_PATH=$installedPkgConf ghc-pkg --global register $pkgConf --force
|
|
|
|
fi
|
2009-04-20 16:23:50 +02:00
|
|
|
|
2012-12-28 19:20:09 +01:00
|
|
|
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
|
2010-10-12 09:26:45 +02:00
|
|
|
fi
|
2013-10-26 18:33:09 +02:00
|
|
|
|
2014-05-25 10:29:24 +02:00
|
|
|
${optionalString (self.enableSharedExecutables && self.isExecutable && self.stdenv.isDarwin) ''
|
2014-08-04 12:38:51 +02:00
|
|
|
for exe in "$out/bin/"* ; do
|
2014-05-25 10:29:24 +02:00
|
|
|
install_name_tool -add_rpath \
|
|
|
|
$out/lib/${ghc.ghc.name}/${self.pname}-${self.version} $exe
|
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
eval "$postInstall"
|
2010-10-12 09:26:45 +02:00
|
|
|
'';
|
|
|
|
|
2010-01-12 11:18:00 +01:00
|
|
|
# We inherit stdenv and ghc so that they can be used
|
|
|
|
# in Cabal derivations.
|
2010-04-27 18:34:56 +02:00
|
|
|
inherit stdenv ghc;
|
2008-01-22 17:26:57 +01:00
|
|
|
};
|
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));
|
2010-01-05 16:17:17 +01:00
|
|
|
}
|