ghcjs: support for Haskell-NG

closes #5828
closes #6786
This commit is contained in:
Charles Strahan 2015-03-12 23:20:56 -04:00 committed by Peter Simons
parent 1901f3fe77
commit d590a0f4b6
13 changed files with 287 additions and 476 deletions

View File

@ -1,282 +0,0 @@
# generic builder for Cabal packages
{ stdenv, fetchurl, lib, pkgconfig, ghcjs, ghc, Cabal, jailbreakCabal, glibcLocales
, gnugrep, coreutils, hscolour # hscolour is unused
, enableLibraryProfiling ? false
, enableSharedLibraries ? false
, enableSharedExecutables ? false
, enableStaticLibraries ? true
, enableCheckPhase ? true
, enableHyperlinkSource ? false
, extension ? (self : super : {})
}:
let
enableFeature = stdenv.lib.enableFeature;
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
{
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;
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}-ghcjs${ghc.ghc.version}-${self.version}-profiling-shared"
else if enableLibraryProfiling && !self.enableSharedLibraries then
"haskell-${self.pname}-ghcjs${ghc.ghc.version}-${self.version}-profiling"
else if !enableLibraryProfiling && self.enableSharedLibraries then
"haskell-${self.pname}-ghcjs${ghc.ghc.version}-${self.version}-shared"
else
"haskell-${self.pname}-ghcjs${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 ghc.ghc.parent.Cabal_1_22_0_0] ++ self.extraBuildInputs;
extraBuildInputs = self.buildTools ++
(optionals self.doCheck self.testDepends) ++
(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 = false; # !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
doCheck = false; #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 true "shared")
(enableFeature self.enableStaticLibraries "library-vanilla")
(enableFeature self.enableSharedExecutables "executable-dynamic")
(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 "${ghc.ghc.parent.jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
PATH=$PATH:${ghc.ghc.ghc}/bin
for i in Setup.hs Setup.lhs ${defaultSetupHs}; do
test -f $i && break
done
ghc --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
for p in $extraBuildInputs $propagatedBuildInputs $propagatedNativeBuildInputs; do
PkgDir="$p/lib/ghcjs-${ghc.ghc.version}_ghc-${ghc.ghc.ghc.version}/package.conf.d"
if [ -f "$PkgDir/package.cache" ]; then
extraConfigureFlags+=" --package-db=$PkgDir"
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
configureFlags+=" --package-db=${ghc.ghc}/${ghc.ghc.libDir}/package.conf.d"
${optionalString (self.enableSharedExecutables && self.stdenv.isLinux) ''
configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}";
''}
${optionalString (self.enableSharedExecutables && self.stdenv.isDarwin) ''
configureFlags+=" --ghc-option=-optl=-Wl,-headerpad_max_install_names";
''}
echo "configure flags: $extraConfigureFlags $configureFlags"
./Setup configure --ghcjs --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/ghcjs-${ghc.ghc.version}_ghc-${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 ghcjs-pkg --global register $pkgConf --force --package-db=$confDir || true
ghcjs-pkg recache --package-db=$confDir
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 || true # Ignore failures, which seem to be due to hitting bash scripts rather than binaries
done
''}
eval "$postInstall"
'';
# We inherit stdenv and ghc so that they can be used
# in Cabal derivations.
inherit stdenv ghc;
};
in
stdenv.mkDerivation (postprocess (let super = defaults self // args self;
self = super // extension self super;
in self));
}

View File

@ -28,7 +28,9 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
# We patch Cabal for GHCJS. See: https://github.com/haskell/cabal/issues/2454
preConfigure = ''
sed -i 's/HcPkg.useSingleFileDb = .*/HcPkg.useSingleFileDb = False/' libraries/Cabal/Cabal/Distribution/Simple/GHCJS.hs
echo >mk/build.mk "${buildMK}"
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
'' + stdenv.lib.optionalString (!stdenv.isDarwin) ''

View File

@ -1,64 +1,91 @@
{ nodejs, cabal, filepath, HTTP, HUnit, mtl, network, QuickCheck, random, stm
, testFramework, testFrameworkHunit, testFrameworkQuickcheck2, time
, zlib, aeson, attoparsec, bzlib, dataDefault, ghcPaths, hashable
, haskellSrcExts, haskellSrcMeta, lens, optparseApplicative
, parallel, safe, shelly, split, stringsearch, syb, systemFileio
, systemFilepath, tar, terminfo, textBinary, unorderedContainers
, vector, wlPprintText, yaml, fetchgit, Cabal, cabalInstall
, regexPosix, alex, happy, git, gnumake, gcc, autoconf, patch
, automake, libtool, gmp, base16Bytestring
, cryptohash, executablePath, transformersCompat, haddockApi
, haddock, hspec, xhtml, primitive, cacert, pkgs, ghc
{ mkDerivation
, test-framework
, test-framework-hunit
, test-framework-quickcheck2
, data-default
, ghc-paths
, haskell-src-exts
, haskell-src-meta
, optparse-applicative
, system-fileio
, system-filepath
, text-binary
, unordered-containers
, cabal-install
, wl-pprint-text
, base16-bytestring
, executable-path
, transformers-compat
, haddock-api
, ghcjs-prim
, regex-posix
, ghc, gmp
, jailbreak-cabal
, nodejs, stdenv, filepath, HTTP, HUnit, mtl, network, QuickCheck, random, stm
, time
, zlib, aeson, attoparsec, bzlib, hashable
, lens
, parallel, safe, shelly, split, stringsearch, syb
, tar, terminfo
, vector, yaml, fetchgit, Cabal
, alex, happy, git, gnumake, autoconf, patch
, automake, libtool
, cryptohash
, haddock, hspec, xhtml, primitive, cacert, pkgs
, coreutils
, ghcjsPrim
, libiconv
}:
let
version = "0.1.0";
libDir = "share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.ghc.version}/ghcjs";
libDir = "share/ghcjs/${pkgs.stdenv.system}-${version}-${ghc.version}/ghcjs";
ghcjsBoot = fetchgit {
url = git://github.com/ghcjs/ghcjs-boot.git;
rev = "5c7a71472d5a797e895914d3b82cea447a058793";
sha256 = "0dp97bgbnlr3sd9yfnk27p6dfv46fi26sn6y6qv1wxs5i29kmjav";
rev = "8cd6144870470258fb037b3e04a0a2a98c2b6551"; # 7.10 branch
sha256 = "16cbncx179n5khf8hkj9r221wf73rc8isffk8rv3n9psshv1jiji";
fetchSubmodules = true;
};
shims = fetchgit {
url = git://github.com/ghcjs/shims.git;
rev = "99bbd4bed584ec42bfcc5ea61c3808a2c670053d";
sha256 = "1my3gqkln7hgm0bpy32pnhwjfza096alh0n9x9ny8xfpxhmzz4h6";
rev = "6ada4bf1a084d1b80b993303d35ed863d219b031"; # master branch
sha256 = "0dhfnjj3rxdbb2m1pbnjc2yp4xcgsfdrsinljgdmg0hpqkafp4vc";
};
in cabal.mkDerivation (self: rec {
in mkDerivation (rec {
pname = "ghcjs";
inherit version;
src = fetchgit {
url = git://github.com/ghcjs/ghcjs.git;
rev = "4b9461e8be646d5152a0ae7ece5b3616bf938637";
sha256 = "19g62j1kkdwcgp0042ppmskwbvfk7qkf1fjs8bpjc6wwd19ipiar";
rev = "35a59743c4027f26a227635cb24a6246bd851f8d"; # master branch
sha256 = "107sh36ji3psdl3py84vxgqbywjyzglj3p0akzpvcmbarxwfr1mw";
};
isLibrary = true;
isExecutable = true;
jailbreak = true;
noHaddock = true;
doHaddock = false;
doCheck = false;
buildDepends = [
filepath HTTP mtl network random stm time zlib aeson attoparsec
bzlib dataDefault ghcPaths hashable haskellSrcExts haskellSrcMeta
lens optparseApplicative parallel safe shelly split
stringsearch syb systemFileio systemFilepath tar terminfo textBinary
unorderedContainers vector wlPprintText yaml
alex happy git gnumake gcc autoconf automake libtool patch gmp
base16Bytestring cryptohash executablePath haddockApi
transformersCompat QuickCheck haddock hspec xhtml
ghcjsPrim regexPosix
bzlib data-default ghc-paths hashable haskell-src-exts haskell-src-meta
lens optparse-applicative parallel safe shelly split
stringsearch syb system-fileio system-filepath tar terminfo text-binary
unordered-containers vector wl-pprint-text yaml
alex happy git gnumake autoconf automake libtool patch gmp
base16-bytestring cryptohash executable-path haddock-api
transformers-compat QuickCheck haddock hspec xhtml
ghcjs-prim regex-posix libiconv
];
buildTools = [ nodejs git ];
testDepends = [
HUnit testFramework testFrameworkHunit
HUnit test-framework test-framework-hunit
];
patches = [ ./ghcjs.patch ];
postPatch = ''
substituteInPlace Setup.hs --replace "/usr/bin/env" "${coreutils}/bin/env"
substituteInPlace src/Compiler/Info.hs --replace "@PREFIX@" "$out"
substituteInPlace src-bin/Boot.hs --replace "@PREFIX@" "$out"
substituteInPlace src-bin/Boot.hs \
--replace "@PREFIX@" "$out" \
--replace "@CC@" "${stdenv.cc}/bin/cc"
'';
preBuild = ''
local topDir=$out/${libDir}
@ -69,23 +96,33 @@ in cabal.mkDerivation (self: rec {
cp -r ${shims} $topDir/shims
chmod -R u+w $topDir/shims
# Make the patches be relative their corresponding package's directory.
# See: https://github.com/ghcjs/ghcjs-boot/pull/12
for patch in $topDir/ghcjs-boot/patches/*.patch; do
echo "fixing patch: $patch"
sed -i -e 's@ \(a\|b\)/boot/[^/]\+@ \1@g' $patch
done
'';
postInstall = ''
PATH=$out/bin:${Cabal}/bin:$PATH LD_LIBRARY_PATH=${gmp}/lib:${gcc.cc}/lib64:$LD_LIBRARY_PATH \
PATH=$out/bin:$PATH LD_LIBRARY_PATH=${gmp}/lib:${stdenv.cc}/lib64:$LD_LIBRARY_PATH \
env -u GHC_PACKAGE_PATH $out/bin/ghcjs-boot \
--dev \
--with-cabal ${cabalInstall}/bin/cabal \
--with-cabal ${cabal-install}/bin/cabal \
--with-gmp-includes ${gmp}/include \
--with-gmp-libraries ${gmp}/lib
'';
passthru = {
inherit libDir;
isGhcjs = true;
nativeGhc = ghc;
};
meta = {
homepage = "https://github.com/ghcjs/ghcjs";
description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API";
license = self.stdenv.lib.licenses.bsd3;
platforms = self.ghc.meta.platforms;
maintainers = [ self.stdenv.lib.maintainers.jwiegley ];
};
homepage = "https://github.com/ghcjs/ghcjs";
description = "GHCJS is a Haskell to JavaScript compiler that uses the GHC API";
license = stdenv.lib.licenses.bsd3;
platforms = ghc.meta.platforms;
maintainers = with stdenv.lib.maintainers; [
jwiegley cstrahan
];
})

View File

@ -1,5 +1,5 @@
diff --git a/src-bin/Boot.hs b/src-bin/Boot.hs
index 988955b..a55f07b 100644
index 3c68dcf..64f3cf7 100644
--- a/src-bin/Boot.hs
+++ b/src-bin/Boot.hs
@@ -512,9 +512,7 @@ initPackageDB :: B ()
@ -46,9 +46,11 @@ index 988955b..a55f07b 100644
mapM_ patchPackage =<< allPackages
preparePrimops
buildGenPrim
@@ -1086,7 +1077,9 @@ cabalInstallFlags parmakeGhcjs = do
@@ -1085,8 +1076,11 @@ cabalInstallFlags parmakeGhcjs = do
, "--avoid-reinstalls"
, "--builddir", "dist"
, "--with-compiler", ghcjs ^. pgmLocText
+ , "--with-gcc", "@CC@"
, "--with-hc-pkg", ghcjsPkg ^. pgmLocText
- , "--prefix", toTextI instDir
+ , "--prefix", "@PREFIX@"

View File

@ -33,6 +33,9 @@ self: super: {
unix = null;
xhtml = null;
# Cabal_1_22_1_1 requires filepath >=1 && <1.4
cabal-install = dontCheck (super.cabal-install.override { Cabal = null; });
# We have Cabal 1.22.x.
jailbreak-cabal = super.jailbreak-cabal.override { Cabal = null; };
@ -55,6 +58,9 @@ self: super: {
# We have time 1.5
aeson = disableCabalFlag super.aeson "old-locale";
# requires filepath >=1.1 && <1.4
Glob = doJailbreak super.Glob;
# Setup: At least the following dependencies are missing: base <4.8
hspec-expectations = overrideCabal super.hspec-expectations (drv: {
patchPhase = "sed -i -e 's|base < 4.8|base|' hspec-expectations.cabal";
@ -83,6 +89,20 @@ self: super: {
# Test suite fails in "/tokens_bytestring_unicode.g.bin".
alex = dontCheck super.alex;
# TODO: should eventually update the versions in hackage-packages.nix
haddock-library = overrideCabal super.haddock-library (drv: {
version = "1.2.0";
sha256 = "0kf8qihkxv86phaznb3liq6qhjs53g3iq0zkvz5wkvliqas4ha56";
});
haddock-api = overrideCabal super.haddock-api (drv: {
version = "2.16.0";
sha256 = "0hk42w6fbr6xp8xcpjv00bhi9r75iig5kp34vxbxdd7k5fqxr1hj";
});
haddock = overrideCabal super.haddock (drv: {
version = "2.16.0";
sha256 = "1afb96w1vv3gmvha2f1h3p8zywpdk8dfk6bgnsa307ydzsmsc3qa";
});
# Upstream was notified about the over-specified constraint on 'base'
# but refused to do anything about it because he "doesn't want to
# support a moving target". Go figure.
@ -104,14 +124,13 @@ self: super: {
sed -i '119iimport Prelude hiding ((<$>))' Text/PrettyPrint/Leijen/Text.hs
'';
});
# https://github.com/kazu-yamamoto/unix-time/issues/30
unix-time = dontCheck super.unix-time;
# Until the changes have been pushed to Hackage
haskell-src-meta = appendPatch super.haskell-src-meta (pkgs.fetchpatch {
url = "https://github.com/bmillwood/haskell-src-meta/pull/31.patch";
sha256 = "0idf12b2wd6chyvsgdcfl5kzx67crvgs1cqklx5say3426j57g4q";
haskell-src-meta = overrideCabal (doJailbreak (appendPatch super.haskell-src-meta ./haskell-src-meta-ghc710.patch)) (drv: {
prePatch = "sed -i -e 's|template-haskell [^,]\\+|template-haskell|' haskell-src-meta.cabal && cat haskell-src-meta.cabal";
});
foldl = appendPatch super.foldl (pkgs.fetchpatch {
url = "https://github.com/Gabriel439/Haskell-Foldl-Library/pull/30.patch";
@ -144,4 +163,16 @@ self: super: {
sha256 = "1fycvjfr1l9wa03k30bnppl3ns99lffh9kmp9r7sr8b6yiydcajq";
stripLen = 1;
});
ghcjs-prim = self.callPackage ({ mkDerivation, fetchgit, primitive }: mkDerivation {
pname = "ghcjs-prim";
version = "0.1.0.0";
src = fetchgit {
url = git://github.com/ghcjs/ghcjs-prim.git;
rev = "ca08e46257dc276e01d08fb47a693024bae001fa"; # ghc-7.10 branch
sha256 = "0w7sqzp5p70yhmdhqasgkqbf3b61wb24djlavwil2j8ry9y472w3";
};
buildDepends = [ primitive ];
license = pkgs.stdenv.lib.licenses.bsd3;
}) {};
}

View File

@ -7,6 +7,12 @@ self: super: {
# LLVM is not supported on this GHC; use the latest one.
inherit (pkgs) llvmPackages;
jailbreak-cabal = pkgs.haskell-ng.packages.ghc7101.jailbreak-cabal;
# Many packages fail with:
# haddock: internal error: expectJust getPackageDetails
mkDerivation = drv: super.mkDerivation (drv // { doHaddock = false; });
# This is the list of packages that are built into a booted ghcjs installation
# It can be generated with the command:
# nix-shell '<nixpkgs>' -A pkgs.haskellPackages_ghcjs.ghc --command "ghcjs-pkg list | sed -n 's/^ \(.*\)-\([0-9.]*\)$/\1_\2/ p' | sed 's/\./_/g' | sed 's/-\(.\)/\U\1/' | sed 's/^\([^_]*\)\(.*\)$/\1 = null;/'"
@ -19,21 +25,21 @@ self: super: {
binary = null;
rts = null;
bytestring = null;
caseInsensitive = null;
case-insensitive = null;
containers = null;
deepseq = null;
directory = null;
dlist = null;
extensibleExceptions = null;
extensible-exceptions = null;
filepath = null;
ghcPrim = null;
ghcjsBase = null;
ghcjsPrim = null;
ghc-prim = null;
ghcjs-base = null;
ghcjs-prim = null;
hashable = null;
integerGmp = null;
integer-gmp = null;
mtl = null;
oldLocale = null;
oldTime = null;
old-locale = null;
old-time = null;
parallel = null;
pretty = null;
primitive = null;
@ -41,12 +47,64 @@ self: super: {
scientific = null;
stm = null;
syb = null;
templateHaskell = null;
template-haskell = null;
text = null;
time = null;
transformers = null;
unix = null;
unorderedContainers = null;
unordered-containers = null;
vector = null;
pqueue = overrideCabal super.pqueue (drv: {
patchPhase = ''
sed -i -e '12s|null|Data.PQueue.Internals.null|' Data/PQueue/Internals.hs
sed -i -e '64s|null|Data.PQueue.Internals.null|' Data/PQueue/Internals.hs
sed -i -e '32s|null|Data.PQueue.Internals.null|' Data/PQueue/Min.hs
sed -i -e '32s|null|Data.PQueue.Max.null|' Data/PQueue/Max.hs
sed -i -e '42s|null|Data.PQueue.Prio.Internals.null|' Data/PQueue/Prio/Min.hs
sed -i -e '42s|null|Data.PQueue.Prio.Max.null|' Data/PQueue/Prio/Max.hs
'';
});
reactive-banana = overrideCabal super.reactive-banana (drv: {
patchPhase = ''
cat >> src/Reactive/Banana/Switch.hs <<EOF
instance Functor (AnyMoment Identity) where
fmap = liftM
instance Applicative (AnyMoment Identity) where
pure = return
(<*>) = ap
EOF
'';
});
transformers-compat = overrideCabal super.transformers-compat (drv: {
configureFlags = [];
});
dependent-map = overrideCabal super.dependent-map (drv: {
preConfigure = ''
sed -i 's/^.*trust base.*$//' *.cabal
'';
});
profunctors = overrideCabal super.profunctors (drv: {
preConfigure = ''
sed -i 's/^{-# ANN .* #-}//' src/Data/Profunctor/Unsafe.hs
'';
});
"ghcjs-dom" = self.callPackage
({ mkDerivation, base, mtl, text, ghcjs-base
}:
mkDerivation {
pname = "ghcjs-dom";
version = "0.1.1.3";
sha256 = "0pdxb2s7fflrh8sbqakv0qi13jkn3d0yc32xhg2944yfjg5fvlly";
buildDepends = [ base mtl text ghcjs-base ];
description = "DOM library that supports both GHCJS and WebKitGTK";
license = pkgs.stdenv.lib.licenses.mit;
hydraPlatforms = pkgs.stdenv.lib.platforms.none;
}) {};
}

View File

@ -15,8 +15,8 @@
, doHoogle ? true
, editedCabalFile ? null
, enableLibraryProfiling ? false
, enableSharedExecutables ? stdenv.lib.versionOlder "7.7" ghc.version
, enableSharedLibraries ? stdenv.lib.versionOlder "7.7" ghc.version
, enableSharedExecutables ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableSplitObjs ? !stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013
, enableStaticLibraries ? true
, extraLibraries ? []
@ -53,6 +53,8 @@ let
inherit (stdenv.lib) optional optionals optionalString versionOlder
concatStringsSep enableFeature optionalAttrs;
isGhcjs = ghc.isGhcjs or false;
newCabalFile = fetchurl {
url = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal";
sha256 = editedCabalFile;
@ -64,7 +66,7 @@ let
main = defaultMain
'';
ghc76xOrLater = stdenv.lib.versionOlder "7.6" ghc.version;
ghc76xOrLater = isGhcjs || stdenv.lib.versionOlder "7.6" ghc.version;
packageDbFlag = if ghc76xOrLater then "package-db" else "package-conf";
hasActiveLibrary = isLibrary && (enableStaticLibraries || enableSharedLibraries || enableLibraryProfiling);
@ -82,14 +84,17 @@ let
(enableFeature enableSplitObjs "split-objs")
(enableFeature enableLibraryProfiling "library-profiling")
(enableFeature enableSharedLibraries "shared")
(optionalString (versionOlder "7" ghc.version) (enableFeature enableStaticLibraries "library-vanilla"))
(optionalString (versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
(optionalString (versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature enableStaticLibraries "library-vanilla"))
(optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
] ++ optionals isGhcjs [
"--with-hsc2hs=${ghc.nativeGhc}/bin/hsc2hs"
"--ghcjs"
];
setupCompileFlags = [
(optionalString (!coreSetup) "-${packageDbFlag}=$packageConfDir")
(optionalString (versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES")
(optionalString (isGhcjs || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES")
(optionalString (versionOlder "7.10" ghc.version) "-threaded") # https://github.com/haskell/cabal/issues/2398
];
@ -108,9 +113,12 @@ let
ghcEnv = ghc.withPackages (p: haskellBuildInputs);
setupBuilder = if isGhcjs then "${ghc.nativeGhc}/bin/ghc" else "ghc";
ghcCommand = if isGhcjs then "ghcjs" else "ghc";
in
stdenv.mkDerivation ({
name = "${optionalString hasActiveLibrary "haskell-"}${pname}-${version}";
name = "${optionalString (hasActiveLibrary && pname != "ghcjs") "haskell-"}${pname}-${version}";
pos = builtins.unsafeGetAttrPos "pname" args;
@ -162,7 +170,7 @@ stdenv.mkDerivation ({
configureFlags+=" --extra-lib-dirs=$p/lib"
fi
done
ghc-pkg --${packageDbFlag}="$packageConfDir" recache
${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache
runHook postSetupCompilerEnvironment
'';
@ -175,7 +183,7 @@ stdenv.mkDerivation ({
done
echo setupCompileFlags: $setupCompileFlags
ghc $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
runHook postCompileBuildDriver
'';
@ -248,13 +256,13 @@ stdenv.mkDerivation ({
isHaskellLibrary = hasActiveLibrary;
env = stdenv.mkDerivation {
name = "interactive-${optionalString hasActiveLibrary "haskell-"}${pname}-${version}-environment";
name = "interactive-${optionalString (hasActiveLibrary && pname != "ghcjs") "haskell-"}${pname}-${version}-environment";
nativeBuildInputs = [ ghcEnv systemBuildInputs ];
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
shellHook = ''
export NIX_GHC="${ghcEnv}/bin/ghc"
export NIX_GHCPKG="${ghcEnv}/bin/ghc"
export NIX_GHC="${ghcEnv}/bin/${ghcCommand}"
export NIX_GHCPKG="${ghcEnv}/bin/${ghcCommand}-pkg"
export NIX_GHC_DOCDIR="${ghcEnv}/share/doc/ghc/html"
export NIX_GHC_LIBDIR="${ghcEnv}/lib/${ghcEnv.name}"
'';

View File

@ -0,0 +1,55 @@
From 24e6f45408083745080ff2f3710f58209041113c Mon Sep 17 00:00:00 2001
From: Luite Stegeman <stegeman@gmail.com>
Date: Sun, 28 Dec 2014 21:33:22 +0100
Subject: [PATCH] updates for GHC 7.10 and Template Haskell 2.10
---
haskell-src-meta.cabal | 4 ++--
src/Language/Haskell/Meta/Syntax/Translate.hs | 6 ++++++
src/Language/Haskell/Meta/Utils.hs | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/Language/Haskell/Meta/Syntax/Translate.hs b/src/Language/Haskell/Meta/Syntax/Translate.hs
index 189d32e..36a08f1 100644
--- a/src/Language/Haskell/Meta/Syntax/Translate.hs
+++ b/src/Language/Haskell/Meta/Syntax/Translate.hs
@@ -384,9 +384,15 @@ a .->. b = AppT (AppT ArrowT a) b
toCxt :: Hs.Context -> Cxt
toCxt = fmap toPred
where
+#if MIN_VERSION_template_haskell(2,10,0)
+ toPred (Hs.ClassA n ts) = foldl' AppT (ConT (toName n)) (fmap toType ts)
+ toPred (Hs.InfixA t1 n t2) = foldl' AppT (ConT (toName n)) (fmap toType [t1,t2])
+ toPred (Hs.EqualP t1 t2) = foldl' AppT EqualityT (fmap toType [t1,t2])
+#else
toPred (Hs.ClassA n ts) = ClassP (toName n) (fmap toType ts)
toPred (Hs.InfixA t1 n t2) = ClassP (toName n) (fmap toType [t1, t2])
toPred (Hs.EqualP t1 t2) = EqualP (toType t1) (toType t2)
+#endif
toPred a@Hs.IParam{} = noTH "toCxt" a
foldAppT :: Type -> [Type] -> Type
diff --git a/src/Language/Haskell/Meta/Utils.hs b/src/Language/Haskell/Meta/Utils.hs
index 36f7e96..d194f3e 100644
--- a/src/Language/Haskell/Meta/Utils.hs
+++ b/src/Language/Haskell/Meta/Utils.hs
@@ -166,6 +166,9 @@ renameT env new (ForallT ns cxt t) =
unVarT (VarT n) = PlainTV n
renamePreds = renameThings renamePred
+#if MIN_VERSION_template_haskell(2,10,0)
+ renamePred = renameT
+#else
renamePred env new (ClassP n ts) = let
(ts', env', new') = renameTs env new [] ts
in (ClassP (normaliseName n) ts', env', new')
@@ -174,7 +177,7 @@ renameT env new (ForallT ns cxt t) =
(t1', env1, new1) = renameT env new t1
(t2', env2, new2) = renameT env1 new1 t2
in (EqualP t1' t2', env2, new2)
-
+#endif
-- | Remove qualification, etc.
normaliseName :: Name -> Name

View File

@ -29,9 +29,10 @@ assert versionOlder "6.12" ghc.version;
# fi
let
ghc761OrLater = versionOlder "7.6.1" ghc.version;
ghc761OrLater = ghc.isGhcjs || versionOlder "7.6.1" ghc.version;
packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
libDir = "$out/lib/ghc-${ghc.version}";
ghcCommand = if ghc.isGhcjs then "ghcjs" else "ghc";
libDir = "$out/lib/${ghcCommand}-${ghc.version}";
docDir = "$out/share/doc/ghc/html";
packageCfgDir = "${libDir}/package.conf.d";
paths = filter (x: x ? isHaskellLibrary) (closePropagation packages);
@ -50,6 +51,10 @@ buildEnv {
postBuild = ''
. ${makeWrapper}/nix-support/setup-hook
${lib.optionalString ghc.isGhcjs ''
cp -r ${ghc}/${ghc.libDir}/* ${libDir}/
''}
if test -L "$out/bin"; then
binTarget="$(readlink -f "$out/bin")"
rm "$out/bin"
@ -59,32 +64,32 @@ buildEnv {
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
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_DOCDIR" "${docDir}" \
--set "NIX_GHC_LIBDIR" "${libDir}" \
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
--add-flags '"-B$NIX_GHC_LIBDIR"' \
--set "NIX_GHC" "$out/bin/${ghcCommand}" \
--set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \
--set "NIX_GHC_DOCDIR" "${docDir}" \
--set "NIX_GHC_LIBDIR" "${libDir}" \
${optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
done
for prg in runghc runhaskell; do
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_DOCDIR" "${docDir}" \
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
--add-flags "-f $out/bin/ghc" \
--set "NIX_GHC" "$out/bin/${ghcCommand}" \
--set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \
--set "NIX_GHC_DOCDIR" "${docDir}" \
--set "NIX_GHC_LIBDIR" "${libDir}"
done
for prg in ghc-pkg ghc-pkg-${ghc.version}; do
for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
rm -f $out/bin/$prg
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
done
${optionalString hasLibraries "$out/bin/ghc-pkg recache"}
$out/bin/ghc-pkg check
${optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
$out/bin/${ghcCommand}-pkg check
'';
} // {
preferLocalBuild = true;

View File

@ -3664,7 +3664,6 @@ let
haskellPackages_ghc784_no_profiling = recurseIntoAttrs haskell.packages_ghc784.noProfiling;
haskellPackages_ghc784_profiling = recurseIntoAttrs haskell.packages_ghc784.profiling;
haskellPackages_ghc784 = recurseIntoAttrs haskell.packages_ghc784.highPrio;
haskellPackages_ghcjs = haskell.packages_ghcjs;
haskellPackages = haskellPackages_ghc784;
haskell-ng = callPackage ./haskell-ng.nix { };

View File

@ -17,15 +17,6 @@
ghcHEADPrefs = self : super : super // {
cabalInstall_1_20_0_6 = super.cabalInstall_1_20_0_6.override { Cabal = null; };
mtl = self.mtl_2_2_1;
ghcjsBase = null;
ghcjsDom = with self; super.ghcjsDom.override {
cabal = self.cabal.override {
extension = self: super: {
configureFlags = [ "-f-ghcjs" "-fwebkit" "-f-gtk3" ];
buildDepends = [ mtl glib transformers gtk webkit ];
};
};
};
};
ghc784Prefs = self : super : ghcHEADPrefs self super // {
@ -200,88 +191,6 @@
prefFun = ghc784Prefs;
};
packages_ghcjs =
packages {
ghc = pkgs.haskell-ng.compiler.ghc784;
prefFun = self : super : super // {
ghc = let parent = packages_ghc784; in
callPackage ../development/compilers/ghcjs/wrapper.nix {
ghc = parent.ghcjs // { inherit parent; };
};
cabal = self.cabalJs;
buildLocalCabalWithArgs = args: super.buildLocalCabalWithArgs (args // {
nativePkgs = packages_ghc784;
});
ghcjsDom = with self; super.ghcjsDom.override {
cabal = self.cabal.override {
extension = self: super: {
configureFlags = [ ];
buildDepends = [ mtl ghcjsBase ];
};
};
};
# This is the list of packages that are built into a booted ghcjs installation
# It can be generated with the command:
# nix-shell '<nixpkgs>' -A pkgs.haskellPackages_ghcjs.ghc --command "ghcjs-pkg list | sed -n 's/^ \(.*\)-\([0-9.]*\)$/\1_\2/ p' | sed 's/\./_/g' | sed 's/-\(.\)/\U\1/' | sed 's/^\([^_]*\)\(.*\)$/\1 = null;/'"
Cabal = null;
aeson = null;
array = null;
async = null;
attoparsec = null;
base = null;
binary = null;
rts = null;
bytestring = null;
caseInsensitive = null;
containers = null;
deepseq = null;
directory = null;
dlist = null;
extensibleExceptions = null;
filepath = null;
ghcPrim = null;
ghcjsBase = null;
ghcjsPrim = null;
hashable = null;
integerGmp = null;
mtl = null;
oldLocale = null;
oldTime = null;
parallel = null;
pretty = null;
primitive = null;
process = null;
scientific = null;
stm = null;
syb = null;
templateHaskell = null;
text = null;
time = null;
transformers = null;
unix = null;
unorderedContainers = null;
vector = null;
# GHCJS-specific workarounds
split = super.split.override {
cabal = self.cabal.override {
extension = self: super: {
doCheck = false; # Under ghcjs, the tests hang
};
};
};
dependentMap = super.dependentMap.override {
cabal = self.cabal.override {
extension = self: super: {
preConfigure = ''
sed -i 's/^.*ghc-options:.*$//' *.cabal
''; # Without this, we get "target base is not a module name or a source file"
};
};
};
};
};
packages_ghc763 =
packages { ghc = pkgs.haskell-ng.compiler.ghc763;
prefFun = ghc763Prefs;

View File

@ -39,6 +39,9 @@ rec {
});
ghc = compiler.ghc784;
ghcjs = packages.ghc7101.callPackage ../development/compilers/ghcjs {
ghc = compiler.ghc7101;
};
};
packages = {
@ -77,6 +80,7 @@ rec {
packageSetConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { };
};
ghcjs = callPackage ../development/haskell-modules {
ghc = compiler.ghcjs;
packageSetConfig = callPackage ../development/haskell-modules/configuration-ghcjs.nix { };
};

View File

@ -103,15 +103,6 @@ self : let callPackage = x : y : modifyPrio (newScope self x y); in
extension = self : super : {};
};
cabalJs = callPackage ../build-support/cabal/ghcjs.nix {
Cabal = null; # prefer the Cabal version shipped with the compiler
hscolour = self.hscolourBootstrap;
inherit enableLibraryProfiling enableCheckPhase
enableStaticLibraries enableSharedLibraries enableSharedExecutables;
glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null;
extension = self : super : {};
};
# A variant of the cabal build driver that disables unit testing.
# Useful for breaking cycles, where the unit test of a package A
# depends on package B, which has A as a regular build input.
@ -968,14 +959,6 @@ self : let callPackage = x : y : modifyPrio (newScope self x y); in
ghcid = callPackage ../development/tools/haskell/ghcid {};
ghcjs = callPackage ../development/compilers/ghcjs {
Cabal = self.Cabal_1_22_0_0;
cabalInstall = self.cabalInstall_1_22_0_0;
haddock = self.haddock.override {
Cabal = null;
};
};
ghcjsDom = callPackage ../development/libraries/haskell/ghcjs-dom {};
ghcjsCodemirror = callPackage ../development/libraries/haskell/ghcjs-codemirror {};