2008-04-29 00:27:03 +02:00
{ ghcPkgUtil , gnum4 , perl , ghcboot , stdenv , fetchurl , recurseIntoAttrs , gmp , readline , lib , hasktags , ctags
, sourceByName , autoconf , happy , alex , automake , getConfig } :
2008-02-13 12:15:08 +01:00
rec {
2007-11-05 10:27:36 +01:00
/* W h a t ' s i n h e r e ?
Goal : really pure GHC . This means put every library into its each package . conf
and add all together using GHC_PACKAGE_PATH
2008-03-06 03:46:29 +01:00
First I've tried separating the build of ghc from it's lib . It hase been to painful . I've failed . Now there is nix_ghc_pkg_tool . hs which just takes the installed package . conf
2007-11-05 10:27:36 +01:00
and creates a new package db file for each contained package .
The final attribute set looks similar to this :
ghc , core_libs and extra_libraries will then be used to build all the ohter packages availible on hackege . .
( There is much left to be done )
ghcAndLibraries = {
ghc68 = {
ghc = {
src = " T h e c o m p i l e r s o u r c e "
extra_src = " s o u r c e o f e x t r a l i b r a r i e s "
version = " G H C v e r s i o n a s s t r i n g "
}
core_libs = [ libs distributed the ghc core ( see libraries/core-packages ] ;
extra_libraries = [ libraries contained extra_src ] ;
} ;
ghc66 = {
roughly the same
} ;
}
* /
#this only works for ghc-6.8 right now
ghcAndLibraries = { version , src /* , c o r e _ l i b r a r i e s , e x t r a _ l i b r a r i e s */
2008-04-29 00:27:03 +02:00
, extra_src , pass ? { } } :
2007-11-05 10:27:36 +01:00
recurseIntoAttrs ( rec {
inherit src extra_src version ;
2008-04-29 00:27:03 +02:00
ghc = stdenv . mkDerivation ( lib . mergeAttrsNoOverride { } pass {
2007-11-05 10:27:36 +01:00
name = " g h c - " + version ;
inherit src ghcboot gmp version ;
buildInputs = [ readline perl gnum4 gmp ] ;
preConfigure = "
chmod u + x rts/gmp/configure
# still requires a hack for ncurses
sed - i \ " s | ^ \( l i b r a r y - d i r s . * $ \) | \1 \\ \" $ n c u r s e s / l i b \\ \" | \" l i b r a r i e s / r e a d l i n e / p a c k a g e . c o n f . i n
" ;
2008-02-09 15:08:37 +01:00
# TODO add unique (filter duplicates?) shouldn't be there?
nix_ghc_pkg_tool = ./nix_ghc_pkg_tool.hs ;
2007-11-05 10:27:36 +01:00
configurePhase = " . / c o n f i g u r e "
+ " - - p r e f i x = \$ o u t "
+ " - - w i t h - g h c = \$ g h c b o o t / b i n / g h c "
+ " - - w i t h - g m p - l i b r a r i e s = $ g m p / l i b "
2008-01-22 15:34:23 +01:00
+ " - - w i t h - g m p - i n c l u d e s = ${ gmp } / i n c l u d e "
2007-11-05 10:27:36 +01:00
+ " - - w i t h - r e a d l i n e - l i b r a r i e s = \" $ r e a d l i n e / l i b \" " ;
# now read the main package.conf and create a single package db file for each of them
# Also create setup hook.
2008-04-29 00:27:03 +02:00
makeFlags = getConfig [ " g h c " " m a k e F l a g s " ] " " ;
2007-11-05 10:27:36 +01:00
# note : I don't know yet wether it's a good idea to have RUNGHC.. It's faster
# but you can't pass packages, can you?
postInstall = "
2008-02-09 15:08:37 +01:00
cp \ $ nix_ghc_pkg_tool nix_ghc_pkg_tool . hs
\ $ out/bin/ghc- \ $ version - - make - o nix_ghc_pkg_tool nix_ghc_pkg_tool . hs ;
./nix_ghc_pkg_tool split \ $ out/lib/ghc- \ $ version/package.conf \ $ out/lib/ghc- \ $ version
cp nix_ghc_pkg_tool \ $ out/bin
2007-11-05 10:27:36 +01:00
if test - x \ $ out/bin/runghc ; then
RUNHGHC = \ $ out/bin/runghc # > ghc-6.7/8 ?
else
RUNHGHC = \ $ out/bin/runhaskell # ghc-6.6 and prior
fi
ensureDir \ $ out/nix-support
sh = \ $ out/nix-support/setup-hook
echo \ " R U N H G H C = \$ R U N H G H C \" > > \$ s h
" ;
2008-04-29 00:27:03 +02:00
} ) ;
2007-11-05 10:27:36 +01:00
2008-02-13 12:15:08 +01:00
core_libs = rec {
# name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
cabal_darcs_name = " c a b a l - d a r c s " ;
# introducing p here to speed things up.
# It merges derivations (defined below) and additional inputs. I hope that using as few nix functions as possible results in greates speed?
# unfortunately with x; won't work because it forces nix to evaluate all attributes of x which would lead to infinite recursion
pkgs = let x = derivations ; in {
# ghc extra packages
2008-02-13 22:21:20 +01:00
cabal = { name = " C a b a l - 1 . 2 . 3 . 0 " ; srcDir = " l i b r a r i e s / C a b a l " ;
2008-02-13 12:15:08 +01:00
deps = [ x . base x . pretty x . old_locale x . old_time
x . directory x . unix x . process x . array x . containers
x . rts x . filepath ] ; } ;
array = { name = " a r r a y - 0 . 1 . 0 . 0 " ; srcDir = " l i b r a r i e s / a r r a y " ;
deps = [ x . base ] ; } ;
base = { name = " b a s e - 3 . 0 . 1 . 0 " ; srcDir = " l i b r a r i e s / b a s e " ;
deps = [ x . rts ] ; } ;
bytestring = { name = " b y t e s t r i n g - 0 . 9 . 0 . 1 " ; srcDir = " l i b r a r i e s / b y t e s t r i n g " ;
deps = [ x . base x . array ] ; } ;
containers = { name = " c o n t a i n e r s - 0 . 1 . 0 . 1 " ; srcDir = " l i b r a r i e s / c o n t a i n e r s " ;
deps = [ x . base x . array ] ; } ;
directory = { name = " d i r e c t o r y - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / d i r e c t o r y " ;
deps = [ x . base x . old_locale x . old_time x . filepath ] ; } ;
filepath = { name = " f i l e p a t h - 1 . 1 . 0 . 0 " ; srcDir = " l i b r a r i e s / f i l e p a t h " ;
deps = [ x . base ] ; } ;
2008-03-06 03:46:29 +01:00
ghc = { name = " g h c - ${ version } " ; srcDir = " c o m p i l e r " ;
2008-02-13 12:15:08 +01:00
deps = [ x . base x . old_locale x . old_time x . filepath
x . directory x . array x . containers x . hpc x . bytestring
x . pretty x . packedstring x . template_haskell x . unix
x . process x . readline x . cabal x . random x . haskell98 ] ; } ;
haskell98 = { name = " h a s k e l l 9 8 - 1 . 0 . 1 . 0 " ; srcDir = " l i b r a r i e s / h a s k e l l 9 8 " ;
deps = [ x . base x . old_locale x . old_time x . filepath
x . directory x . random x . unix x . process x . array ] ; } ;
hpc = { name = " h p c - 0 . 5 . 0 . 0 " ; srcDir = " l i b r a r i e s / h p c " ;
deps = [ x . base x . old_locale x . old_time x . filepath
x . directory x . array x . containers ] ; } ;
old_locale = { name = " o l d - l o c a l e - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / o l d - l o c a l e " ;
deps = [ x . base ] ; } ;
old_time = { name = " o l d - t i m e - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / o l d - t i m e " ;
deps = [ x . base x . old_locale ] ; } ;
packedstring = { name = " p a c k e d s t r i n g - 0 . 1 . 0 . 0 " ; srcDir = " l i b r a r i e s / p a c k e d s t r i n g " ;
deps = [ x . base x . array ] ; } ;
pretty = { name = " p r e t t y - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / p r e t t y " ;
deps = [ x . base ] ; } ;
process = { name = " p r o c e s s - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / p r o c e s s " ;
deps = [ x . base x . old_locale x . old_time x . filepath
x . directory x . unix ] ; } ;
random = { name = " r a n d o m - 1 . 0 . 0 . 0 " ; srcDir = " l i b r a r i e s / r a n d o m " ;
deps = [ x . base x . old_locale x . old_time ] ; } ;
readline = { name = " r e a d l i n e - 1 . 0 . 1 . 0 " ; srcDir = " l i b r a r i e s / r e a d l i n e " ;
deps = [ x . base x . old_locale x . old_time x . filepath
x . directory x . unix x . process ] ; } ;
rts = rec {
name = " r t s - 1 . 0 " ; srcDir = " r t s " ; # TODO: Doesn't have .hs files so I should use ctags if creating tags at all
deps = [ ] ;
createTagFiles = [
2008-03-06 03:46:29 +01:00
{ name = " ${ name } _ h a s k e l l " ;
2008-02-13 12:15:08 +01:00
tagCmd = " ${ toString ctags } / b i n / c t a g s - R . ; m v t a g s \$ T A G _ F I L E " ; }
] ;
} ;
template_haskell = { name = " t e m p l a t e - h a s k e l l - 2 . 2 . 0 . 0 " ; srcDir = " l i b r a r i e s / t e m p l a t e - h a s k e l l " ;
deps = [ x . base x . pretty x . array x . packedstring x . containers ] ; } ;
unix = { name = " u n i x - 2 . 3 . 0 . 0 " ; srcDir = " l i b r a r i e s / u n i x " ;
deps = [ x . base x . old_locale x . old_time x . filepath x . directory ] ; } ;
} ;
toDerivation = attrs : with attrs ;
2008-03-06 03:46:29 +01:00
stdenv . mkDerivation {
inherit ( attrs ) name ;
2008-02-13 12:15:08 +01:00
phases = " b u i l d P h a s e f i x u p P h a s e " ;
buildInputs = [ ghcPkgUtil ] ;
2008-03-06 03:46:29 +01:00
propagatedBuildInputs = [ ghc ] ++ attrs . deps ;
buildPhase = " s e t u p H o o k R e g i s t e r i n g P a c k a g e D a t a b a s e \" ${ ghc } / l i b / g h c - ${ ghc . version } / ${ attrs . name } . c o n f \" " ;
2008-03-13 10:46:12 +01:00
meta = {
2008-03-06 03:46:29 +01:00
sourceWithTags = {
src = ghc . src ;
inherit srcDir ;
name = attrs . name + " - s r c - w i t h - t a g s " ;
createTagFiles = lib . maybeAttr " c r e a t e T a g F i l e s " [
{ name = " ${ attrs . name } _ h a s k e l l " ;
tagCmd = " ${ toString hasktags } / b i n / h a s k t a g s - m o d i f i e d - - c t a g s ` f i n d . - t y p e f - n a m e \" * . * h s \" ` ; s o r t t a g s > \$ T A G _ F I L E " ; }
] attrs ;
} ;
} ;
2008-02-13 12:15:08 +01:00
} ;
derivations = with lib ; builtins . listToAttrs ( lib . concatLists ( lib . mapRecordFlatten
2009-03-10 21:04:08 +01:00
( n : attrs : let d = ( toDerivation attrs ) ; in [ ( nameValuePair n d ) ( nameValuePair attrs . name d ) ] ) pkgs ) ) ;
2008-02-13 12:15:08 +01:00
} . derivations ;
} ) ;
2007-11-05 10:27:36 +01:00
2008-01-22 15:34:23 +01:00
ghc68 = ghcAndLibraries rec {
version = " 6 . 8 . 2 " ;
2007-11-05 10:27:36 +01:00
src = fetchurl {
2008-01-22 15:34:23 +01:00
#url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.0.20071004-src.tar.bz2;
#sha256 = "1yyl7sxykmvkiwfxkfzpqa6cmgw19phkyjcdv99ml22j16wli63l";
url = " h t t p : / / w w w . h a s k e l l . o r g / g h c / d i s t / s t a b l e / d i s t / g h c - ${ version } - s r c . t a r . b z 2 " ;
md5 = " 7 4 5 c 6 b 7 d 4 3 7 0 6 1 0 2 4 4 4 1 9 c b f e c 4 b 2 f 8 4 " ;
2007-11-05 10:27:36 +01:00
#url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.20070912-src.tar.bz2;
#sha256 = "1b1gvi7hc7sc0fkh29qvzzd5lgnlvdv3ayiak4mkfnzkahvmq85s";
} ;
2008-04-29 00:27:03 +02:00
pass = { patches = ./patch ; } ;
2007-11-05 10:27:36 +01:00
extra_src = fetchurl {
2008-01-22 15:34:23 +01:00
url = " h t t p : / / w w w . h a s k e l l . o r g / g h c / d i s t / s t a b l e / d i s t / g h c - ${ version } - s r c - e x t r a l i b s . t a r . b z 2 " ;
sha256 = " 0 4 4 m p b z p k b x c n q h j n r n m j s 0 0 m r 8 5 0 5 7 d 1 2 3 r r l z 2 v c h 7 9 5 l x b k c n " ;
2007-11-05 10:27:36 +01:00
#url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.20070912-src-extralibs.tar.bz2;
#sha256 = "0py7d9nh3lkhjxr3yb3n9345d0hmzq79bi40al5rcr3sb84rnp9r";
} ;
} ;
2008-04-29 00:27:03 +02:00
# this works. commented out because I haven't uploaded all the bleeding edge source dist files.
#[> darcs version of ghc which is updated occasionally by Marc Weber
#ghc68darcs = ghcAndLibraries rec {
# version = "6.9";
# pass = { buildInputs = [ happy alex];
# patches = ./patch;
# patchPhase = "
# unset patchPhase; patchPhase
# pwd
# sed 's/GhcWithJavaGen=NO/GhcWithJavaGen=YES/g' -i mk/config.mk.in
# ";
# };
# [> each library is usually added using darcs-all get
# [> so I assemble and prepare the sources here
# src = stdenv.mkDerivation {
# name = "ghc-darcs-src-dist";
# buildInputs = [autoconf automake];
# core_libs = map (x : sourceByName "ghc_core_${x}") ["array" "base" "bytestring" "Cabal" "containers" "directory" "editline" "filepath" "ghc_prim" "haskell98" "hpc" "integer_gmp" "old_locale" "old_time" "packedstring" "pretty" "process" "random" "template_haskell" "unix" "Win32" ];
# ghc = sourceByName "ghc";
# phases = "buildPhase";
# buildPhase = "
# echo unpacking ghc
# tar xfz \$ghc &> /dev/null
# cd nix_repsoitory_manager_tmp_dir/libraries
# for i in \$core_libs; do
# echo 'unpacking core_lib :' \$i
# tar xfz \$i &> /dev/null
# n=`basename \$i`
# n=\${n/ghc_core_/}
# if [ -f nix_repsoitory_manager_tmp_dir/*.ac ]; then
# cd nix_repsoitory_manager_tmp_dir
# echo =======================================================
# echo \$n
# autoreconf
# cd ..
# fi
# mv nix_repsoitory_manager_tmp_dir \${n/.tar.gz/}
# done
# mv ghc_prim ghc-prim
# for i in integer-gmp old-locale old-time template-haskell; do
# mv \${i/-/_} $i
# done
# mkdir \$out
# cd ..
# autoreconf
# sh boot
# cd ..
# mv nix*/* \$out/
# ";
# };
# [> TODO this is copied.. use dev versions as well here
# extra_src = fetchurl {
# url = "http://www.haskell.org/ghc/dist/stable/dist/ghc-${version}-src-extralibs.tar.bz2";
# sha256 = "044mpbzpkbxcnqhjnrnmjs00mr85057d123rrlz2vch795lxbkcn";
# [>url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.20070912-src-extralibs.tar.bz2;
# [>sha256 = "0py7d9nh3lkhjxr3yb3n9345d0hmzq79bi40al5rcr3sb84rnp9r";
# };
#};
2007-11-05 10:27:36 +01:00
}