adjust packages to overridableDelayableArgs

svn path=/nixpkgs/trunk/; revision=14427
This commit is contained in:
Marc Weber 2009-03-06 23:21:24 +00:00
parent f1183f33e3
commit 51289a41b0
5 changed files with 123 additions and 127 deletions

View File

@ -33,7 +33,7 @@ in
# python wiht all features enabled. # python wiht all features enabled.
# if you really need a stripped version we should add __overides # if you really need a stripped version we should add __overides
# so that you can replace it the way it's done in all-packages.nix # so that you can replace it the way it's done in all-packages.nix
pythonFull = t.pythonMinimal.passthru.fun { pythonFull = t.pythonMinimal.merge {
name = "python-${t.version}-full"; name = "python-${t.version}-full";
cfg = { cfg = {
zlibSupport = true; zlibSupport = true;
@ -79,48 +79,46 @@ in
# lib to verify it works # lib to verify it works
# You can define { python25 { debugCmd = "DISPLAY=:0.0 pathtoxterm"; } # You can define { python25 { debugCmd = "DISPLAY=:0.0 pathtoxterm"; }
# in your config for easier debugging.. # in your config for easier debugging..
pythonLibStub = composableDerivation { pythonLibStub = composableDerivation {} {
initial = { propagatedBuildInputs = [ t.pythonFull ]; # see [1]
propagatedBuildInputs = [ t.pythonFull ]; # see [1] postPhases = ["postAll"]; # using new name so that you dno't override this phase by accident
postPhases = ["postAll"]; # using new name so that you dno't override this phase by accident prePhases = ["defineValidatingEval"];
prePhases = ["defineValidatingEval"]; # ensure phases are run or a non zero exit status is caused (if there are any syntax errors such as eval "while")
# ensure phases are run or a non zero exit status is caused (if there are any syntax errors such as eval "while") defineValidatingEval = ''
defineValidatingEval = '' eval(){
eval(){ e="$(type eval | { read; while read line; do echo $line; done })"
e="$(type eval | { read; while read line; do echo $line; done })" unset eval;
unset eval; local evalSucc="failure"
local evalSucc="failure" eval "evalSucc=ok;""$1"
eval "evalSucc=ok;""$1" eval "$e"
eval "$e" [ $evalSucc = "failure" ] && { echo "eval failed, snippet:"; echo "$1"; return 1; }
[ $evalSucc = "failure" ] && { echo "eval failed, snippet:"; echo "$1"; return 1; } }
} '';
''; postAll = ''
postAll = '' ensureDir $out/nix-support
ensureDir $out/nix-support echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook
echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook # run check
# run check if [ -n "$pyCheck" ]; then
if [ -n "$pyCheck" ]; then ( . $out/nix-support/setup-hook
( . $out/nix-support/setup-hook mkdir $TMP/new-test; cd $TMP/new-test
mkdir $TMP/new-test; cd $TMP/new-test echo PYTHONPATH=$PYTHONPATH
echo PYTHONPATH=$PYTHONPATH echo NIX_PYTHON_SITES=$NIX_PYTHON_SITES
echo NIX_PYTHON_SITES=$NIX_PYTHON_SITES script="$(echo -e "import sys\nprint sys.path\npyCheck\nprint \"check ok\"")"
script="$(echo -e "import sys\nprint sys.path\npyCheck\nprint \"check ok\"")" script="''${script/pyCheck/$pyCheck}"
script="''${script/pyCheck/$pyCheck}" echo "check script is"; echo "$script"
echo "check script is"; echo "$script" echo "$script" | python || { ${ getConfig [t.versionAttr "debugCmd"] ":"} ; echo "pycheck failed"; exit 1; }
echo "$script" | python || { ${ getConfig [t.versionAttr "debugCmd"] ":"} ; echo "pycheck failed"; exit 1; } )
) fi'';
fi''; passthru = {
passthru = { libPython = t.version; # used to find all python libraries fitting this version (-> see name all below)
libPython = t.version; # used to find all python libraries fitting this version (-> see name all below) };
}; mergeAttrBy = {
mergeAttrBy = { pyCheck = x : y : "${x}\n${y}";
pyCheck = x : y : "${x}\n${y}"; };
};
};
}; };
# same as pythonLibStub, but runs default python setup.py actions # same as pythonLibStub, but runs default python setup.py actions
pythonLibSetup = t.pythonLibStub.passthru.fun { pythonLibSetup = t.pythonLibStub.merge {
buildPhase = ''python setup.py $setupFlags build''; buildPhase = ''python setup.py $setupFlags build'';
installPhase = ''python setup.py $setupFlags install --prefix=$out''; installPhase = ''python setup.py $setupFlags install --prefix=$out'';
mergeAttrBy = { mergeAttrBy = {
@ -130,7 +128,7 @@ in
### python libraries: ### python libraries:
wxPythonBaseFun = (t.pythonLibSetup.passthru.funMerge (a : wxPythonBaseFun = (t.pythonLibSetup.merge (a :
let inherit (a.fixed) wxGTK version; in let inherit (a.fixed) wxGTK version; in
{ {
buildInputs = [p.pkgconfig wxGTK (wxGTK.gtk)]; buildInputs = [p.pkgconfig wxGTK (wxGTK.gtk)];
@ -144,7 +142,7 @@ in
license="wxWinLL-3"; license="wxWinLL-3";
}; };
} }
)).passthru.fun; )).merge;
wxPython26 = t.wxPythonBaseFun { wxPython26 = t.wxPythonBaseFun {
version = "2.6.3.3"; version = "2.6.3.3";
@ -166,7 +164,7 @@ in
#}; #};
# couldn't download source # couldn't download source
#foursuite = pythonLibSetup.passthru.fun { #foursuite = pythonLibSetup.merge {
# version = "1.0.2"; # version = "1.0.2";
# name = "4suite-${version}"; # name = "4suite-${version}";
# src = fetchurl { # src = fetchurl {
@ -175,7 +173,7 @@ in
# }; # };
#}; #};
#bsddb3 = t.pythonLibSetup.passthru.fun { #bsddb3 = t.pythonLibSetup.merge {
# version = "1.0.2"; # version = "1.0.2";
# name = "bsddb3-4.5.0"; # name = "bsddb3-4.5.0";
# setupFlags = ["--berkeley-db=${p.db4}"]; # setupFlags = ["--berkeley-db=${p.db4}"];
@ -197,7 +195,7 @@ in
# patching pygtk to another */gtk2.0 directory to sys.path for each NIX_PYTHON_SITES. # patching pygtk to another */gtk2.0 directory to sys.path for each NIX_PYTHON_SITES.
# If you install dozens of python packages this might be bloat. # If you install dozens of python packages this might be bloat.
# So I think the overhead of installing these packages into the same store path should be prefered. # So I think the overhead of installing these packages into the same store path should be prefered.
pygtkBaseFun = (t.pythonLibStub.passthru.funMerge (a : pygtkBaseFun = (t.pythonLibStub.merge (a :
let inherit (a.fixed) glib gtk; in lib.mergeAttrsByFuncDefaults [ let inherit (a.fixed) glib gtk; in lib.mergeAttrsByFuncDefaults [
{ {
unpackPhase = "true"; unpackPhase = "true";
@ -312,7 +310,7 @@ in
# ''; # '';
#}; #};
pygtk212 = t.pygtkBaseFun.passthru.funMerge (a : { pygtk212 = t.pygtkBaseFun.merge (a : {
version = "2.12.1"; version = "2.12.1";
name = "pygobject-${a.fixed.pygobjectVersion}-and-pygtk-${a.fixed.version}"; name = "pygobject-${a.fixed.pygobjectVersion}-and-pygtk-${a.fixed.version}";
pygtkSrc = fetchurl { pygtkSrc = fetchurl {
@ -326,7 +324,7 @@ in
''; '';
}); });
pycairo = t.pythonLibStub.passthru.fun { pycairo = t.pythonLibStub.merge {
name = "pycairo-1.8.0"; name = "pycairo-1.8.0";
buildInputs = [ p.pkgconfig p.cairo p.x11 ]; buildInputs = [ p.pkgconfig p.cairo p.x11 ];
src = fetchurl { src = fetchurl {
@ -336,7 +334,7 @@ in
pyCheck = "import cairo"; pyCheck = "import cairo";
}; };
gstPython = t.pythonLibStub.passthru.fun { gstPython = t.pythonLibStub.merge {
name = "gst-python-0.10.13"; name = "gst-python-0.10.13";
src = fetchurl { src = fetchurl {
url = http://gstreamer.freedesktop.org/src/gst-python/gst-python-0.10.13.tar.gz; url = http://gstreamer.freedesktop.org/src/gst-python/gst-python-0.10.13.tar.gz;
@ -377,7 +375,7 @@ in
}; };
}; };
pygoocanvas = t.pythonLibStub.passthru.fun { pygoocanvas = t.pythonLibStub.merge {
src = p.fetchurl { src = p.fetchurl {
url = http://download.berlios.de/pygoocanvas/pygoocanvas-0.10.0.tar.gz; url = http://download.berlios.de/pygoocanvas/pygoocanvas-0.10.0.tar.gz;
sha256 = "0pxznzdscbhvn8102vrqy3r1g6ss4sgs8wwy6y4c5g26rrp7l55d"; sha256 = "0pxznzdscbhvn8102vrqy3r1g6ss4sgs8wwy6y4c5g26rrp7l55d";
@ -393,7 +391,7 @@ in
}; };
}; };
# zope = t.pythonLibStub.passthru.fun rec { # zope = t.pythonLibStub.merge rec {
#[> version = "3.3.1"; #[> version = "3.3.1";
# version = "svn"; # version = "svn";
# name = "zope-${version}"; # name = "zope-${version}";
@ -409,7 +407,7 @@ in
# pyCheck = ""; # pyCheck = "";
# }; # };
setuptools = t.pythonLibSetup.passthru.fun { setuptools = t.pythonLibSetup.merge {
name = "setuptools-0.6c9"; name = "setuptools-0.6c9";
postUnpack = '' postUnpack = ''
ensureDir $out/lib/python2.5/site-packages ensureDir $out/lib/python2.5/site-packages
@ -429,7 +427,7 @@ in
}; };
}; };
zopeInterface = t.pythonLibSetup.passthru.fun rec { zopeInterface = t.pythonLibSetup.merge rec {
version = "3.3.0"; version = "3.3.0";
name = "zope.interface-${version}"; name = "zope.interface-${version}";
buildInputs = [ t.setuptools ]; buildInputs = [ t.setuptools ];
@ -440,7 +438,7 @@ in
pyCheck = "from zope.interface import Interface, Attribute"; pyCheck = "from zope.interface import Interface, Attribute";
}; };
dbusPython = t.pythonLibStub.passthru.fun rec { dbusPython = t.pythonLibStub.merge rec {
version = "0.83.0"; version = "0.83.0";
name = "dbus-python-0.83.0"; name = "dbus-python-0.83.0";
buildInputs = [ p.pkgconfig ]; buildInputs = [ p.pkgconfig ];
@ -457,7 +455,7 @@ in
}; };
}; };
pythonXlib = t.pythonLibSetup.passthru.fun { pythonXlib = t.pythonLibSetup.merge {
name = "python-xlib-0.14"; name = "python-xlib-0.14";
src = fetchurl { src = fetchurl {
url = http://puzzle.dl.sourceforge.net/sourceforge/python-xlib/python-xlib-0.14.tar.gz; url = http://puzzle.dl.sourceforge.net/sourceforge/python-xlib/python-xlib-0.14.tar.gz;
@ -470,7 +468,7 @@ in
}; };
}; };
mechanize = t.pythonLibSetup.passthru.fun { mechanize = t.pythonLibSetup.merge {
name = "mechanize-0.1.11"; name = "mechanize-0.1.11";
buildInputs = [ t.setuptools ]; buildInputs = [ t.setuptools ];
src = fetchurl { src = fetchurl {
@ -485,7 +483,7 @@ in
pyCheck = "from mechanize import Browser"; pyCheck = "from mechanize import Browser";
}; };
pexpect = t.pythonLibSetup.passthru.fun { pexpect = t.pythonLibSetup.merge {
name = "pexpect-2.3"; name = "pexpect-2.3";
src = fetchurl { src = fetchurl {
url = mirror://sourceforge/pexpect/pexpect-2.3.tar.gz; url = mirror://sourceforge/pexpect/pexpect-2.3.tar.gz;
@ -500,24 +498,22 @@ in
### python applications ### python applications
pythonExStub = composableDerivation { pythonExStub = composableDerivation {} {
initial = { buildInputs = [p.makeWrapper];
buildInputs = [p.makeWrapper]; postPhases = ["wrapExecutables"];
postPhases = ["wrapExecutables"]; propagatedBuildInputs = [ t.pythonFull ]; # see [1]
propagatedBuildInputs = [ t.pythonFull ]; # see [1]
# adding $out to NIX_PYTHON_SITES because some of those executables seem to come with extra libs # adding $out to NIX_PYTHON_SITES because some of those executables seem to come with extra libs
wrapExecutables = '' wrapExecutables = ''
for prog in $out/bin/*; do for prog in $out/bin/*; do
wrapProgram "$prog" \ wrapProgram "$prog" \
--set NIX_PYTHON_SITES "$NIX_PYTHON_SITES:$out" \ --set NIX_PYTHON_SITES "$NIX_PYTHON_SITES:$out" \
--set PYTHONPATH "\$PYTHONPATH:$out" --set PYTHONPATH "\$PYTHONPATH:$out"
done done
''; '';
};
}; };
pitivi = t.pythonExStub.passthru.fun { pitivi = t.pythonExStub.merge {
name = "pitivi-0.11.2"; name = "pitivi-0.11.2";
src = fetchurl { src = fetchurl {
url = http://ftp.gnome.org/pub/GNOME/sources/pitivi/0.11/pitivi-0.11.2.tar.bz2; url = http://ftp.gnome.org/pub/GNOME/sources/pitivi/0.11/pitivi-0.11.2.tar.bz2;
@ -537,7 +533,7 @@ in
''; '';
}; };
istanbul = t.pythonExStub.passthru.fun { istanbul = t.pythonExStub.merge {
name = "istanbul-0.2.2"; name = "istanbul-0.2.2";
buildInputs = [ t.pygtk212 t.gstPython /*t.gnomePython (contained in gtk) t.gnomePythonExtras */ t.pythonXlib buildInputs = [ t.pygtk212 t.gstPython /*t.gnomePython (contained in gtk) t.gnomePythonExtras */ t.pythonXlib
p.perl p.perlXMLParser p.gettext]; p.perl p.perlXMLParser p.gettext];

View File

@ -2,11 +2,11 @@ args: with args;
let inherit (lib) optional prepareDerivationArgs concatStringsSep fix; in let inherit (lib) optional prepareDerivationArgs concatStringsSep fix; in
composableDerivation { composableDerivation {
f = args: let attr = lib.prepareDerivationArgs args; in stdenv.mkDerivation ( attr // { mkDerivation = attr : stdenv.mkDerivation ( attr // {
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") attr.buildInputs); C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") attr.buildInputs);
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") attr.buildInputs); LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") attr.buildInputs);
}); });
initial = { } {
postPhases = ["runCheck"]; postPhases = ["runCheck"];
@ -65,5 +65,4 @@ composableDerivation {
rm -rf $out/lib/python2.5/test rm -rf $out/lib/python2.5/test
"; ";
}; }
}

View File

@ -1,32 +1,30 @@
args: with args; args: with args;
let edf = composableDerivation.edf; in let edf = composableDerivation.edf; in
composableDerivation.composableDerivation { composableDerivation.composableDerivation {} {
initial = { name="avrdude-5.4";
name="avrdude-5.4";
src = fetchurl { src = fetchurl {
url = http://mirror.switch.ch/mirror/gentoo/distfiles/avrdude-5.4.tar.gz; url = http://mirror.switch.ch/mirror/gentoo/distfiles/avrdude-5.4.tar.gz;
sha256 = "bee4148c51ec95999d803cb9f68f12ac2e9128b06f07afe307d38966c0833b30"; sha256 = "bee4148c51ec95999d803cb9f68f12ac2e9128b06f07afe307d38966c0833b30";
}; };
configureFlags = [ "--disable-dependency-tracking" ]; configureFlags = [ "--disable-dependency-tracking" ];
buildInputs = [yacc flex]; buildInputs = [yacc flex];
flags = flags =
edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; } edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; }
// edf { name = "parport"; } // edf { name = "parport"; }
; ;
cfg = { cfg = {
docSupport = false; # untested docSupport = false; # untested
parportSupport = true; parportSupport = true;
}; };
meta = { meta = {
license = "GPL-2"; license = "GPL-2";
description = "AVR Downloader/UploaDEr"; description = "AVR Downloader/UploaDEr";
homepage = http://savannah.nongnu.org/projects/avrdude; homepage = http://savannah.nongnu.org/projects/avrdude;
};
}; };
} }

View File

@ -9,18 +9,23 @@ let inherit (lib) nv nvs; in
# grep the mailinglist by title "python proposal" (dec 08) # grep the mailinglist by title "python proposal" (dec 08)
# -> http://mail.cs.uu.nl/pipermail/nix-dev/2008-December/001571.html # -> http://mail.cs.uu.nl/pipermail/nix-dev/2008-December/001571.html
# to see why this got complicated when using all its features # to see why this got complicated when using all its features
# TODO add newer example using new syntax (kernel derivation proposal -> mailinglist)
composableDerivation = { composableDerivation = {
# modify args before applying stdenv.mkDerivation, this should remove at least attrs removeAttrsBy mkDerivation ? pkgs.stdenv.mkDerivation,
f ? lib.prepareDerivationArgs, # initial set of arguments to be passed to stdenv.mkDerivation passing prepareDerivationArgs by default
stdenv ? pkgs.stdenv,
# initial set of arguments to be passed to stdenv.mkDerivation passing prepareDerivationArgs by default
initial ? {}, initial ? {},
# example func : (x: x // { x.buildInputs ++ ["foo"] }), but see mergeAttrByFunc which does this for you
merge ? (lib.mergeOrApply lib.mergeAttrByFunc) # list of functions to be applied before defaultOverridableDelayableArgs removes removeAttrs names
}: lib.applyAndFun # prepareDerivationArgs handles derivation configurations
(args: stdenv.mkDerivation (f args)) # applyPreTidy ? [ lib.prepareDerivationArgs ],
merge applyPreTidy ? [],
(merge { inherit (lib) mergeAttrBy; } initial);
removeAttrs ? ["cfg" "flags"]
}: (lib.defaultOverridableDelayableArgs ( a: mkDerivation a)
{
inherit applyPreTidy removeAttrs;
}).merge;
# some utility functions # some utility functions
# use this function to generate flag attrs for prepareDerivationArgs # use this function to generate flag attrs for prepareDerivationArgs

View File

@ -1,29 +1,27 @@
args: with args; args: with args;
let edf = composableDerivation.edf; in let edf = composableDerivation.edf; in
rec { rec {
squid30 = composableDerivation.composableDerivation { squid30 = composableDerivation.composableDerivation {} {
initial = { name = "squid-3.0-stable5";
name = "squid-3.0-stable5";
buildInputs = [perl]; buildInputs = [perl];
src = args.fetchurl {
url = http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE5.tar.bz2;
sha256 = "1m4ccpjw30q9vwsycmgg9dmhly0mpznvxrch6f7dxgfzpjp26l7w";
};
configureFlags = ["--enable-ipv6"];
meta = {
description = "http-proxy";
homepage = "http://www.squid-cache.org";
license = "GPL2";
};
src = args.fetchurl {
url = http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE5.tar.bz2;
sha256 = "1m4ccpjw30q9vwsycmgg9dmhly0mpznvxrch6f7dxgfzpjp26l7w";
}; };
configureFlags = ["--enable-ipv6"];
meta = {
description = "http-proxy";
homepage = "http://www.squid-cache.org";
license = "GPL2";
};
}; };
squid3Beta = squid30.passthru.funMerge { squid3Beta = squid30.merge {
name = "squid-3.1-beta"; name = "squid-3.1-beta";
src = args.fetchurl { src = args.fetchurl {
url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.0.3.tar.bz2; url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.0.3.tar.bz2;
@ -32,7 +30,7 @@ rec {
configureFlags = ["--enable-ipv6"]; configureFlags = ["--enable-ipv6"];
}; };
squid3Head = squid3Beta.passthru.funMerge { squid3Head = squid3Beta.merge {
name = "squid-3.1-HEAD"; name = "squid-3.1-HEAD";
src = args.fetchurl { src = args.fetchurl {
url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.0.3-20081221.tar.bz2; url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.0.3-20081221.tar.bz2;