diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix index ca985181a532..9b6d8c4e80ed 100644 --- a/pkgs/build-support/cabal/default.nix +++ b/pkgs/build-support/cabal/default.nix @@ -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 diff --git a/pkgs/development/compilers/ghc/6.10.1-binary.nix b/pkgs/development/compilers/ghc/6.10.1-binary.nix index dd79ef9c8e75..e7d4d3c1946f 100644 --- a/pkgs/development/compilers/ghc/6.10.1-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.1-binary.nix @@ -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. diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix index 7effff83c69a..5af89e38c21f 100644 --- a/pkgs/development/compilers/ghc/6.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix @@ -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. diff --git a/pkgs/development/compilers/ghc/6.12.1-binary.nix b/pkgs/development/compilers/ghc/6.12.1-binary.nix index 6f3411da4af6..da4658c3829e 100644 --- a/pkgs/development/compilers/ghc/6.12.1-binary.nix +++ b/pkgs/development/compilers/ghc/6.12.1-binary.nix @@ -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. '' diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix index 455d552b91ac..2c9b11f2b654 100644 --- a/pkgs/development/compilers/ghc/7.0.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix @@ -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. '' diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index 59eb957a45f4..7000081e5dbe 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -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. '' diff --git a/pkgs/development/compilers/ghc/7.4.2.nix b/pkgs/development/compilers/ghc/7.4.2.nix index 51f3f7f9df4b..0bc2a8553069 100644 --- a/pkgs/development/compilers/ghc/7.4.2.nix +++ b/pkgs/development/compilers/ghc/7.4.2.nix @@ -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=[ diff --git a/pkgs/development/compilers/ghc/7.6.3.nix b/pkgs/development/compilers/ghc/7.6.3.nix index dc3a912a34ac..427d21660b89 100644 --- a/pkgs/development/compilers/ghc/7.6.3.nix +++ b/pkgs/development/compilers/ghc/7.6.3.nix @@ -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 diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index c9cd71fc2b51..37bcde172324 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -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"; diff --git a/pkgs/development/compilers/ghc/with-packages.nix b/pkgs/development/compilers/ghc/with-packages.nix index e3cc71bbccfd..979b24805868 100644 --- a/pkgs/development/compilers/ghc/with-packages.nix +++ b/pkgs/development/compilers/ghc/with-packages.nix @@ -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; } diff --git a/pkgs/development/compilers/ghc/wrapper.nix b/pkgs/development/compilers/ghc/wrapper.nix index 55fd16be5edb..bcfbd49b98a0 100644 --- a/pkgs/development/compilers/ghc/wrapper.nix +++ b/pkgs/development/compilers/ghc/wrapper.nix @@ -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; +} diff --git a/pkgs/development/compilers/uhc/default.nix b/pkgs/development/compilers/uhc/default.nix index fa66306721d7..31f45086ba0a 100644 --- a/pkgs/development/compilers/uhc/default.nix +++ b/pkgs/development/compilers/uhc/default.nix @@ -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"; diff --git a/pkgs/development/libraries/haskell/bytestring-progress/default.nix b/pkgs/development/libraries/haskell/bytestring-progress/default.nix index e9bb268b9fce..c73932b3760a 100644 --- a/pkgs/development/libraries/haskell/bytestring-progress/default.nix +++ b/pkgs/development/libraries/haskell/bytestring-progress/default.nix @@ -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"; diff --git a/pkgs/development/libraries/haskell/dns/default.nix b/pkgs/development/libraries/haskell/dns/default.nix index 8625aec86b3d..9dd35804f430 100644 --- a/pkgs/development/libraries/haskell/dns/default.nix +++ b/pkgs/development/libraries/haskell/dns/default.nix @@ -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; diff --git a/pkgs/development/libraries/haskell/ghc-mod/default.nix b/pkgs/development/libraries/haskell/ghc-mod/default.nix index 977a15d28e06..accce6f5c86a 100644 --- a/pkgs/development/libraries/haskell/ghc-mod/default.nix +++ b/pkgs/development/libraries/haskell/ghc-mod/default.nix @@ -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 ''; diff --git a/pkgs/development/libraries/haskell/modular-arithmetic/default.nix b/pkgs/development/libraries/haskell/modular-arithmetic/default.nix index 7d53d81f7bb6..c4a77630e6ae 100644 --- a/pkgs/development/libraries/haskell/modular-arithmetic/default.nix +++ b/pkgs/development/libraries/haskell/modular-arithmetic/default.nix @@ -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; diff --git a/pkgs/development/libraries/haskell/multirec/default.nix b/pkgs/development/libraries/haskell/multirec/default.nix index a7d7459b4558..61de0cace5b5 100644 --- a/pkgs/development/libraries/haskell/multirec/default.nix +++ b/pkgs/development/libraries/haskell/multirec/default.nix @@ -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"; diff --git a/pkgs/development/libraries/haskell/wxHaskell/wxc.nix b/pkgs/development/libraries/haskell/wxHaskell/wxc.nix index 74ca4f91d70f..b89b39acb50a 100644 --- a/pkgs/development/libraries/haskell/wxHaskell/wxc.nix +++ b/pkgs/development/libraries/haskell/wxHaskell/wxc.nix @@ -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 ''; diff --git a/pkgs/development/tools/documentation/haddock/2.7.2.nix b/pkgs/development/tools/documentation/haddock/2.7.2.nix index 8dd3460b6f8f..fd31a96b2913 100644 --- a/pkgs/development/tools/documentation/haddock/2.7.2.nix +++ b/pkgs/development/tools/documentation/haddock/2.7.2.nix @@ -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 = { diff --git a/pkgs/development/tools/documentation/haddock/2.9.2.nix b/pkgs/development/tools/documentation/haddock/2.9.2.nix index 61e457426dec..fcae14d789e9 100644 --- a/pkgs/development/tools/documentation/haddock/2.9.2.nix +++ b/pkgs/development/tools/documentation/haddock/2.9.2.nix @@ -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 = { diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 0b3ddbc672f6..c8d7b0dee858 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -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.