mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-17 01:24:47 +00:00
Back-port Haskell-related improvements from stdenv-updates.
* There now is full support for building Haskell packages as shared libraries for GHC versions 7.4.2 or later. The Cabal builder recognizes the following attributes: - enableSharedLibraries configures Cabal to build of shared libraries in addition to static ones. This option requires that all dependencies of the package have been compiled for use in shared libraries, too. - enableSharedExecutables configures Cabal to prefer shared libraries when linking executables. The default values for these attributes are arguments to the haskellPackages expression. * Haskell builds now run in a LANG="en_US.UTF-8" environment to avoid plenty of build and test suite errors. Without this setting, GHC seems unable to deal with the UTF-8 character encoding that's generally considered standard in the Haskell world. * The Cabal builder supports a new attribute 'testTarget' to specify the exact set of tests to be run during the check phase. * The ghc-wrapper attribute ghcVersion has been removed. Instead, we use the ghc.version attribute, which exists in unwrapped GHC derivations, too.
This commit is contained in:
parent
5580abd60a
commit
d64917ad17
@ -1,12 +1,29 @@
|
||||
# generic builder for Cabal packages
|
||||
|
||||
{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal
|
||||
{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
|
||||
, enableLibraryProfiling ? false
|
||||
, enableCheckPhase ? true
|
||||
, enableSharedLibraries ? false
|
||||
, enableSharedExecutables ? false
|
||||
, enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
|
||||
}:
|
||||
|
||||
# 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;
|
||||
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;
|
||||
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;
|
||||
|
||||
{
|
||||
mkDerivation =
|
||||
@ -23,8 +40,8 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
# in the interest of keeping hashes stable.
|
||||
postprocess =
|
||||
x : (removeAttrs x internalAttrs) // {
|
||||
buildInputs = stdenv.lib.filter (y : ! (y == null)) x.buildInputs;
|
||||
propagatedBuildInputs = stdenv.lib.filter (y : ! (y == null)) x.propagatedBuildInputs;
|
||||
buildInputs = filter (y : ! (y == null)) x.buildInputs;
|
||||
propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
|
||||
doCheck = enableCheckPhase && x.doCheck;
|
||||
};
|
||||
|
||||
@ -42,8 +59,12 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
# if that is not desired (for applications), name can be set to
|
||||
# fname.
|
||||
name = if self.isLibrary then
|
||||
if enableLibraryProfiling 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
|
||||
@ -63,7 +84,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
# but often propagatedBuildInputs is preferable anyway
|
||||
buildInputs = [ghc Cabal] ++ self.extraBuildInputs;
|
||||
extraBuildInputs = self.buildTools ++
|
||||
(stdenv.lib.optionals self.doCheck self.testDepends) ++
|
||||
(optionals self.doCheck self.testDepends) ++
|
||||
(if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
|
||||
(if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
|
||||
|
||||
@ -80,6 +101,9 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
# 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 = [];
|
||||
|
||||
@ -96,42 +120,61 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
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
|
||||
|| stdenv.lib.versionOlder "7.6.99" ghc.ghcVersion # -fsplit-ojbs is broken in 7.7 snapshot
|
||||
enableSplitObjs = !( stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013
|
||||
|| versionOlder "7.6.99" ghc.version # -fsplit-ojbs is broken in 7.7 snapshot
|
||||
);
|
||||
|
||||
# pass the '--enable-tests' flag to cabal in the configure stage
|
||||
# and run any regression test suites the package might have
|
||||
doCheck = enableCheckPhase;
|
||||
|
||||
# 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 = [
|
||||
(stdenv.lib.enableFeature enableLibraryProfiling "library-profiling")
|
||||
(stdenv.lib.enableFeature self.enableSplitObjs "split-objs")
|
||||
] ++ stdenv.lib.optional (stdenv.lib.versionOlder "7" ghc.ghcVersion) (stdenv.lib.enableFeature self.doCheck "tests");
|
||||
(enableFeature self.enableSplitObjs "split-objs")
|
||||
(enableFeature enableLibraryProfiling "library-profiling")
|
||||
(enableFeature self.enableSharedLibraries "shared")
|
||||
(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"
|
||||
|
||||
${lib.optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
|
||||
${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
|
||||
|
||||
for i in Setup.hs Setup.lhs; do
|
||||
test -f $i && ghc --make $i
|
||||
done
|
||||
|
||||
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-dir=$p/include"
|
||||
extraConfigureFlags+=" --extra-include-dirs=$p/include"
|
||||
fi
|
||||
for d in lib{,64}; do
|
||||
if [ -d "$p/$d" ]; then
|
||||
extraConfigureFlags+=" --extra-lib-dir=$p/$d"
|
||||
extraConfigureFlags+=" --extra-lib-dirs=$p/$d"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "configure flags: $extraConfigureFlags $configureFlags"
|
||||
./Setup configure --verbose --prefix="$out" $extraConfigureFlags $configureFlags
|
||||
./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' --libsubdir='$pkgid' $extraConfigureFlags $configureFlags
|
||||
|
||||
eval "$postConfigure"
|
||||
'';
|
||||
@ -142,16 +185,16 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
|
||||
./Setup build
|
||||
|
||||
export GHC_PACKAGE_PATH=$(ghc-packages)
|
||||
[ -n "$noHaddock" ] || ./Setup haddock
|
||||
export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
|
||||
test -n "$noHaddock" || ./Setup haddock
|
||||
|
||||
eval "$postBuild"
|
||||
'';
|
||||
|
||||
checkPhase = stdenv.lib.optional self.doCheck ''
|
||||
checkPhase = optional self.doCheck ''
|
||||
eval "$preCheck"
|
||||
|
||||
./Setup test
|
||||
./Setup test ${self.testTarget}
|
||||
|
||||
eval "$postCheck"
|
||||
'';
|
||||
@ -166,7 +209,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
|
||||
ensureDir $out/bin # necessary to get it added to PATH
|
||||
|
||||
local confDir=$out/lib/ghc-pkgs/ghc-${ghc.ghc.version}
|
||||
local confDir=$out/lib/ghc-${ghc.ghc.version}/package.conf.d
|
||||
local installedPkgConf=$confDir/${self.fname}.installedconf
|
||||
local pkgConf=$confDir/${self.fname}.conf
|
||||
ensureDir $confDir
|
||||
@ -176,13 +219,11 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
|
||||
GHC_PACKAGE_PATH=$installedPkgConf ghc-pkg --global register $pkgConf --force
|
||||
fi
|
||||
|
||||
eval "$postInstall"
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
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
|
||||
|
||||
eval "$postInstall"
|
||||
'';
|
||||
|
||||
# We inherit stdenv and ghc so that they can be used
|
||||
|
@ -36,10 +36,10 @@ stdenv.mkDerivation rec {
|
||||
''
|
||||
mkdir "$TMP/bin"
|
||||
for i in strip; do
|
||||
echo '#!/bin/sh' >> "$TMP/bin/$i"
|
||||
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
|
||||
chmod +x "$TMP/bin/$i"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
done
|
||||
PATH="$TMP/bin:$PATH"
|
||||
'' +
|
||||
# On Linux, use patchelf to modify the executables so that they can
|
||||
# find editline/gmp.
|
||||
|
@ -30,10 +30,10 @@ stdenv.mkDerivation rec {
|
||||
''
|
||||
mkdir "$TMP/bin"
|
||||
for i in strip; do
|
||||
echo '#!/bin/sh' >> "$TMP/bin/$i"
|
||||
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
|
||||
chmod +x "$TMP/bin/$i"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
done
|
||||
PATH="$TMP/bin:$PATH"
|
||||
'' +
|
||||
# On Linux, use patchelf to modify the executables so that they can
|
||||
# find editline/gmp.
|
||||
|
@ -28,10 +28,10 @@ stdenv.mkDerivation rec {
|
||||
''
|
||||
mkdir "$TMP/bin"
|
||||
for i in strip; do
|
||||
echo '#!/bin/sh' >> "$TMP/bin/$i"
|
||||
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
|
||||
chmod +x "$TMP/bin/$i"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
done
|
||||
PATH="$TMP/bin:$PATH"
|
||||
'' +
|
||||
# We have to patch the GMP paths for the integer-gmp package.
|
||||
''
|
||||
|
@ -38,10 +38,10 @@ stdenv.mkDerivation rec {
|
||||
''
|
||||
mkdir "$TMP/bin"
|
||||
for i in strip; do
|
||||
echo '#!/bin/sh' >> "$TMP/bin/$i"
|
||||
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
|
||||
chmod +x "$TMP/bin/$i"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
done
|
||||
PATH="$TMP/bin:$PATH"
|
||||
'' +
|
||||
# We have to patch the GMP paths for the integer-gmp package.
|
||||
''
|
||||
|
@ -38,10 +38,10 @@ stdenv.mkDerivation rec {
|
||||
''
|
||||
mkdir "$TMP/bin"
|
||||
for i in strip; do
|
||||
echo '#!/bin/sh' >> "$TMP/bin/$i"
|
||||
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
|
||||
chmod +x "$TMP/bin/$i"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
done
|
||||
PATH="$TMP/bin:$PATH"
|
||||
'' +
|
||||
# We have to patch the GMP paths for the integer-gmp package.
|
||||
''
|
||||
|
@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
|
||||
preConfigure = ''
|
||||
echo "${buildMK}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
|
||||
'';
|
||||
|
||||
configureFlags=[
|
||||
|
@ -22,11 +22,10 @@ stdenv.mkDerivation rec {
|
||||
preConfigure = ''
|
||||
echo "${buildMK}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"--with-gcc=${stdenv.gcc}/bin/gcc"
|
||||
];
|
||||
configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc";
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
|
@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
|
||||
preConfigure = ''
|
||||
echo "${buildMK}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
|
||||
'';
|
||||
|
||||
configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc";
|
||||
|
@ -1,127 +1,42 @@
|
||||
{stdenv, ghc, packages ? [], makeWrapper}:
|
||||
{ stdenv, ghc, packages, buildEnv, makeWrapper }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
assert packages != [];
|
||||
|
||||
let
|
||||
ghc761OrLater = stdenv.lib.versionOlder "7.6.1" ghc.version;
|
||||
packageDBFlag = if ghc761OrLater then "--package-db" else "--package-conf";
|
||||
libDir = "$out/lib/ghc-${ghc.version}";
|
||||
packageCfgDir = "${libDir}/package.conf.d";
|
||||
in
|
||||
buildEnv {
|
||||
name = "haskell-env-${ghc.name}";
|
||||
|
||||
allPackages = stdenv.lib.closePropagation packages;
|
||||
buildInputs = allPackages ++ [makeWrapper];
|
||||
propagatedBuildInputs = packages;
|
||||
|
||||
unpackPhase = "true";
|
||||
|
||||
installPhase = ''
|
||||
numversion=$(${ghc}/bin/ghc --numeric-version)
|
||||
majorversion=''${numversion%%.*}
|
||||
minorversion=''${numversion#*.}
|
||||
minorversion=''${minorversion%%.*}
|
||||
|
||||
if [[ $majorversion -gt 6 ]] && [[ $minorversion -gt 4 ]]; then
|
||||
globalConf="--global-package-db"
|
||||
else
|
||||
globalConf="--global-conf"
|
||||
fi
|
||||
|
||||
originalTopDir="${ghc}/lib/ghc-${ghc.version}"
|
||||
originalPkgDir="$originalTopDir/package.conf.d"
|
||||
linkedTopDir="$out/lib"
|
||||
linkedPkgDir="$linkedTopDir/package.conf.d"
|
||||
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $linkedTopDir
|
||||
mkdir -p $linkedPkgDir
|
||||
|
||||
echo "Linking GHC core libraries:"
|
||||
|
||||
echo -n "Linking $originalTopDir "
|
||||
for f in "$originalTopDir/"*; do
|
||||
if test -f $f; then
|
||||
ln -s $f $linkedTopDir
|
||||
echo -n .
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
echo -n "Linking $originalPkgDir "
|
||||
for f in "$originalPkgDir/"*.conf; do
|
||||
ln -s $f $linkedPkgDir
|
||||
echo -n .
|
||||
done
|
||||
echo
|
||||
|
||||
echo "Linking selected packages and dependencies:"
|
||||
|
||||
for currentPath in ${stdenv.lib.concatStringsSep " " allPackages}; do
|
||||
currentPkgDir="$currentPath/lib/ghc-pkgs/ghc-${ghc.version}"
|
||||
# Check if current path is a Cabal package for the current GHC
|
||||
if test -d $currentPkgDir; then
|
||||
echo -n "Linking $currentPath "
|
||||
for f in "$currentPath/bin/"*; do
|
||||
ln -s $f $out/bin
|
||||
echo -n .
|
||||
done
|
||||
for f in "$currentPath/etc/bash_completion.d/"*; do
|
||||
mkdir -p $out/etc/bash_completion.d
|
||||
ln -s $f $out/etc/bash_completion.d/
|
||||
echo -n .
|
||||
done
|
||||
for s in 1 2 3 4 5 6 7 8 9; do
|
||||
for f in "$currentPath/share/man/man$s/"*; do
|
||||
mkdir -p $out/share/man/man$s
|
||||
ln -sv $f $out/share/man/man$s/
|
||||
echo -n .
|
||||
done
|
||||
done
|
||||
for f in "$currentPath/share/emacs/site-lisp/"*; do
|
||||
mkdir -p $out/share/emacs/site-lisp
|
||||
ln -s $f $out/share/emacs/site-lisp/
|
||||
echo -n .
|
||||
done
|
||||
for f in "$currentPath/share/ghci/"*; do
|
||||
mkdir -p $out/share/ghci
|
||||
ln -s $f $out/share/ghci/
|
||||
echo -n .
|
||||
done
|
||||
for f in "$currentPkgDir/"*.conf; do
|
||||
ln -s $f $linkedPkgDir
|
||||
echo -n .
|
||||
done
|
||||
echo
|
||||
fi
|
||||
done
|
||||
|
||||
echo -n "Generating package cache "
|
||||
${ghc}/bin/ghc-pkg $globalConf $linkedPkgDir recache
|
||||
echo .
|
||||
|
||||
echo -n "Generating wrappers "
|
||||
paths = stdenv.lib.filter (x: x ? ghc) (stdenv.lib.closePropagation (packages ++ [ghc]));
|
||||
postBuild = ''
|
||||
. ${makeWrapper}/nix-support/setup-hook
|
||||
|
||||
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
||||
# The NIX env-vars are picked up by our patched version of ghc-paths.
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
||||
--add-flags "-B$linkedTopDir" \
|
||||
--set "NIX_GHC" "$out/bin/ghc" \
|
||||
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
||||
--set "NIX_GHC_LIBDIR" "$linkedTopDir"
|
||||
echo -n .
|
||||
rm -f $out/bin/$prg
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
||||
--add-flags '"-B$NIX_GHC_LIBDIR"' \
|
||||
--set "NIX_GHC" "$out/bin/ghc" \
|
||||
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
||||
--set "NIX_GHC_LIBDIR" "${libDir}"
|
||||
done
|
||||
|
||||
for prg in runghc runhaskell; do
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "-f $out/bin/ghc"
|
||||
echo -n .
|
||||
rm -f $out/bin/$prg
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
||||
--add-flags "-f $out/bin/ghc" \
|
||||
--set "NIX_GHC" "$out/bin/ghc" \
|
||||
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
||||
--set "NIX_GHC_LIBDIR" "${libDir}"
|
||||
done
|
||||
|
||||
for prg in ghc-pkg ghc-pkg-${ghc.version}; do
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "$globalConf $linkedPkgDir"
|
||||
echo -n .
|
||||
rm -f $out/bin/$prg
|
||||
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag} ${packageCfgDir}"
|
||||
done
|
||||
|
||||
for prg in hp2ps hpc hasktags hsc2hs haddock haddock-${ghc.version}; do
|
||||
if test -x ${ghc}/bin/$prg -a ! -x $out/bin/$prg; then
|
||||
ln -s ${ghc}/bin/$prg $out/bin/$prg && echo -n .
|
||||
fi
|
||||
done
|
||||
echo
|
||||
$out/bin/ghc-pkg recache
|
||||
'';
|
||||
|
||||
meta = ghc.meta;
|
||||
}
|
||||
|
@ -1,10 +1,53 @@
|
||||
{ stdenv, ghc, makeWrapper, coreutils, forUserEnv ? false }:
|
||||
{ stdenv, ghc, makeWrapper, coreutils, writeScript }:
|
||||
|
||||
let
|
||||
ghc761OrLater = !stdenv.lib.versionOlder ghc.version "7.6.1";
|
||||
packageDBFlag = if ghc761OrLater then "-package-db" else "-package-conf";
|
||||
|
||||
GHCGetPackages = writeScript "ghc-get-packages.sh" ''
|
||||
#! ${stdenv.shell}
|
||||
# Usage:
|
||||
# $1: version of GHC
|
||||
# $2: invocation path of GHC
|
||||
# $3: prefix
|
||||
version="$1"
|
||||
if test -z "$3"; then
|
||||
prefix="${packageDBFlag} "
|
||||
else
|
||||
prefix="$3"
|
||||
fi
|
||||
PATH="$2:$PATH"
|
||||
IFS=":"
|
||||
for p in $PATH; do
|
||||
PkgDir="$p/../lib/ghc-$version/package.conf.d"
|
||||
for i in "$PkgDir/"*.installedconf; do
|
||||
# output takes place here
|
||||
test -f $i && echo -n " $prefix$i"
|
||||
done
|
||||
done
|
||||
test -f "$2/../lib/ghc-$version/package.conf" && echo -n " $prefix$2/../lib/ghc-$version/package.conf"
|
||||
'';
|
||||
|
||||
GHCPackages = writeScript "ghc-packages.sh" ''
|
||||
#! ${stdenv.shell} -e
|
||||
declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
|
||||
|
||||
for arg in $(${GHCGetPackages} ${ghc.version} "$(dirname $0)"); do
|
||||
case "$arg" in
|
||||
${packageDBFlag}) ;;
|
||||
*)
|
||||
CANONICALIZED="$(${coreutils}/bin/readlink -f -- "$arg")"
|
||||
GHC_PACKAGES_HASH["$CANONICALIZED"]= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
for path in ''${!GHC_PACKAGES_HASH[@]}; do
|
||||
echo -n "$path:"
|
||||
done
|
||||
'';
|
||||
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
stdenv.mkDerivation {
|
||||
name = "ghc-${ghc.version}-wrapper";
|
||||
|
||||
buildInputs = [makeWrapper];
|
||||
@ -12,53 +55,32 @@ stdenv.mkDerivation ({
|
||||
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp $GHCGetPackages $out/bin/ghc-get-packages.sh
|
||||
chmod 755 $out/bin/ghc-get-packages.sh
|
||||
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\")"
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\")"
|
||||
done
|
||||
for prg in runghc runhaskell; do
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" \" ${packageDBFlag} --ghc-arg=\")"
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\" \" ${packageDBFlag} --ghc-arg=\")"
|
||||
done
|
||||
for prg in ghc-pkg ghc-pkg-${ghc.version}; do
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" -${packageDBFlag}=)"
|
||||
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\" -${packageDBFlag}=)"
|
||||
done
|
||||
for prg in hp2ps hpc hasktags hsc2hs; do
|
||||
test -x $ghc/bin/$prg && ln -s $ghc/bin/$prg $out/bin/$prg
|
||||
done
|
||||
cat >> $out/bin/ghc-packages << EOF
|
||||
#! /bin/bash -e
|
||||
declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
|
||||
|
||||
for arg in \$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\"); do
|
||||
case "\$arg" in
|
||||
${packageDBFlag}) ;;
|
||||
*)
|
||||
CANONICALIZED="\$(${stdenv.lib.optionalString stdenv.isDarwin "${coreutils}/bin/"}readlink -f "\$arg")"
|
||||
GHC_PACKAGES_HASH["\$CANONICALIZED"]= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
for path in \''${!GHC_PACKAGES_HASH[@]}; do
|
||||
echo -n "\$path:"
|
||||
done
|
||||
EOF
|
||||
chmod +x $out/bin/ghc-packages
|
||||
mkdir -p $out/nix-support
|
||||
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
|
||||
|
||||
mkdir -p $out/share/doc
|
||||
ln -s $ghc/lib $out/lib
|
||||
ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghc.version}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
GHCGetPackages = ./ghc-get-packages.sh;
|
||||
|
||||
inherit ghc;
|
||||
inherit (ghc) meta;
|
||||
ghcVersion = ghc.version;
|
||||
} // (stdenv.lib.optionalAttrs ghc761OrLater { preFixup = "sed -i -e 's|-package-conf|${packageDBFlag}|' $out/bin/ghc-get-packages.sh"; })
|
||||
// (stdenv.lib.optionalAttrs forUserEnv {
|
||||
postFixup= ''
|
||||
ln -s $ghc/lib $out/lib;
|
||||
mkdir -p $out/share/doc
|
||||
ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghc.version}
|
||||
'';
|
||||
}))
|
||||
inherit ghc GHCGetPackages GHCPackages;
|
||||
inherit (ghc) meta version;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
# this check won't be needed anymore after ghc-wrapper is fixed
|
||||
# to show ghc-builtin packages in "ghc-pkg list" output.
|
||||
let binaryIsBuiltIn = builtins.compareVersions "7.2.1" ghc.ghcVersion != 1;
|
||||
let binaryIsBuiltIn = builtins.compareVersions "7.2.1" ghc.version != 1;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "uhc-svn-git20120502";
|
||||
|
@ -5,7 +5,6 @@ cabal.mkDerivation (self: {
|
||||
version = "1.0.3";
|
||||
sha256 = "1v9cl7d4fcchbdrpbgjj4ilg79cj241vzijiifdsgkq30ikv2yxs";
|
||||
buildDepends = [ terminalProgressBar time ];
|
||||
noHaddock = true;
|
||||
meta = {
|
||||
homepage = "http://github.com/acw/bytestring-progress";
|
||||
description = "A library for tracking the consumption of a lazy ByteString";
|
||||
|
@ -15,7 +15,7 @@ cabal.mkDerivation (self: {
|
||||
attoparsec attoparsecConduit binary blazeBuilder conduit doctest
|
||||
hspec iproute mtl network networkConduit random
|
||||
];
|
||||
doCheck = false;
|
||||
testTarget = "spec";
|
||||
meta = {
|
||||
description = "DNS library in Haskell";
|
||||
license = self.stdenv.lib.licenses.bsd3;
|
||||
|
@ -30,7 +30,7 @@ cabal.mkDerivation (self: {
|
||||
#!/bin/sh
|
||||
COMMAND=\$1
|
||||
shift
|
||||
eval exec $out/ghc-mod \$COMMAND \$( ${self.ghc.GHCGetPackages} ${self.ghc.ghcVersion} | tr " " "\n" | tail -n +2 | paste -d " " - - | sed 's/.*/-g "&"/' | tr "\n" " ") "\$@"
|
||||
eval exec $out/ghc-mod \$COMMAND \$( ${self.ghc.GHCGetPackages} ${self.ghc.version} | tr " " "\n" | tail -n +2 | paste -d " " - - | sed 's/.*/-g "&"/' | tr "\n" " ") "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/ghc-mod
|
||||
'';
|
||||
|
@ -4,7 +4,6 @@ cabal.mkDerivation (self: {
|
||||
pname = "modular-arithmetic";
|
||||
version = "1.0.1.1";
|
||||
sha256 = "14n83kjmz8mqjivjhwxk1zckms5z3gn77yq2hsw2yybzff2vkdkd";
|
||||
noHaddock = true;
|
||||
meta = {
|
||||
description = "A type for integers modulo some constant";
|
||||
license = self.stdenv.lib.licenses.bsd3;
|
||||
|
@ -4,7 +4,6 @@ cabal.mkDerivation (self: {
|
||||
pname = "multirec";
|
||||
version = "0.7.3";
|
||||
sha256 = "0k1wbjsvkl08nwjikflc8yyalk654mf8bvi1rhm28i4na52myi5y";
|
||||
noHaddock = true;
|
||||
meta = {
|
||||
homepage = "http://www.cs.uu.nl/wiki/GenericProgramming/Multirec";
|
||||
description = "Generic programming for families of recursive datatypes";
|
||||
|
@ -6,7 +6,6 @@ cabal.mkDerivation (self: {
|
||||
sha256 = "1bh20i1rb8ng0ni1v98nm8qv5wni19dvxwf5i3ijxhrxqdq4i7p6";
|
||||
buildDepends = [ wxdirect ];
|
||||
extraLibraries = [ libX11 mesa wxGTK ];
|
||||
noHaddock = true;
|
||||
postInstall = ''
|
||||
cp -v dist/build/libwxc.so.${self.version} $out/lib/libwxc.so
|
||||
'';
|
||||
|
@ -10,7 +10,7 @@ cabal.mkDerivation (self : {
|
||||
doCheck = false;
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/haddock --add-flags "\$(${self.ghc.GHCGetPackages} ${self.ghc.ghcVersion} \"\$(dirname \$0)\" \"--optghc=-package-conf --optghc=\")"
|
||||
wrapProgram $out/bin/haddock --add-flags "\$(${self.ghc.GHCGetPackages} ${self.ghc.version} \"\$(dirname \$0)\" \"--optghc=-package-conf --optghc=\")"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
@ -10,7 +10,7 @@ cabal.mkDerivation (self : {
|
||||
doCheck = false;
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/haddock --add-flags "\$(${self.ghc.GHCGetPackages} ${self.ghc.ghcVersion} \"\$(dirname \$0)\" \"--optghc=-package-conf --optghc=\")"
|
||||
wrapProgram $out/bin/haddock --add-flags "\$(${self.ghc.GHCGetPackages} ${self.ghc.version} \"\$(dirname \$0)\" \"--optghc=-package-conf --optghc=\")"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
@ -58,7 +58,12 @@
|
||||
#
|
||||
# For most packages, however, we keep only one version, and use default.nix.
|
||||
|
||||
{pkgs, newScope, ghc, prefFun, enableLibraryProfiling ? false, modifyPrio ? (x : x)}:
|
||||
{ pkgs, newScope, ghc, prefFun, modifyPrio ? (x : x)
|
||||
, enableLibraryProfiling ? false
|
||||
, enableSharedLibraries ? false
|
||||
, enableSharedExecutables ? false
|
||||
, enableCheckPhase ? pkgs.stdenv.lib.versionOlder "7.4" ghc.version
|
||||
}:
|
||||
|
||||
# We redefine callPackage to take into account the new scope. The optional
|
||||
# modifyPrio argument can be set to lowPrio to make all Haskell packages have
|
||||
@ -91,16 +96,6 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
|
||||
ghc = ghc; # refers to ghcPlain
|
||||
};
|
||||
|
||||
# The normal GHC wrapper doesn't create links to the documentation in
|
||||
# ~/.nix-profile. Having this second wrapper allows us to remedy the
|
||||
# situation without re-building all Haskell packages. At the next
|
||||
# stdenv-updates merge, this second wrapper will go away.
|
||||
|
||||
ghcUserEnvWrapper = pkgs.appendToName "new" (callPackage ../development/compilers/ghc/wrapper.nix {
|
||||
ghc = ghc; # refers to ghcPlain
|
||||
forUserEnv = true;
|
||||
});
|
||||
|
||||
# An experimental wrapper around ghcPlain that does not automatically
|
||||
# pick up packages from the profile, but instead has a fixed set of packages
|
||||
# in its global database. The set of packages can be specified as an
|
||||
@ -115,8 +110,11 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
|
||||
# packages. It isn't the Cabal library, which is spelled "Cabal".
|
||||
|
||||
cabal = callPackage ../build-support/cabal {
|
||||
enableLibraryProfiling = enableLibraryProfiling;
|
||||
enableCheckPhase = pkgs.stdenv.lib.versionOlder "7.4" self.ghc.ghcVersion;
|
||||
inherit enableLibraryProfiling;
|
||||
inherit enableSharedLibraries;
|
||||
inherit enableSharedExecutables;
|
||||
inherit enableCheckPhase;
|
||||
glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null;
|
||||
};
|
||||
|
||||
# A variant of the cabal build driver that disables unit testing.
|
||||
|
Loading…
Reference in New Issue
Block a user