2008-02-13 12:15:08 +01:00
{ ghcPkgUtil , gnum4 , perl , ghcboot , stdenv , fetchurl , recurseIntoAttrs , gmp , readline , lib , annotatedDerivations , hasktags , ctags } :
with annotatedDerivations ;
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
First I've tried separating the build of ghc from it's lib . It hase been to painful . I've failed .
2008-02-09 15:08:37 +01:00
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-02-13 12:15:08 +01:00
, extra_src } :
2007-11-05 10:27:36 +01:00
recurseIntoAttrs ( rec {
inherit src extra_src version ;
ghc = stdenv . mkDerivation {
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.
# 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-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 ] ; } ;
ghc = { name = " g h c - ${ version } " ; srcDir = " l i b r a r i e s / C a b a l " ;
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 = [
{ name = " ${ name } _ h a s k e l l _ t a g s " ;
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 ;
rec {
inherit name ;
#aDeps = concatLists ( catAttrs ( subsetmap id args [ "buildInputs" "propagatedBuildInputs" ] ) );
aDeps = deps ;
# dummy derivation, only creates setup-hook for package database located in the ghc derivation
aDeriv = stdenv . mkDerivation {
inherit name ;
phases = " b u i l d P h a s e f i x u p P h a s e " ;
buildInputs = [ ghcPkgUtil ] ;
propagatedBuildInputs = [ ghc ] ++ map delAnnotation 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 } / ${ name } . c o n f \" " ;
} ;
sourceWithTags = {
src = ghc . src ;
inherit srcDir ;
name = 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 = " ${ name } _ h a s k e l l _ t a g s " ;
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 ;
} ;
} ;
derivations = with lib ; builtins . listToAttrs ( lib . concatLists ( lib . mapRecordFlatten
( n : attrs : let d = ( toDerivation attrs ) ; in [ ( nv n d ) ( nv attrs . name d ) ] ) pkgs ) ) ;
} . 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";
} ;
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";
} ;
} ;
}