diff --git a/pkgs/development/interpreters/python-new/2.5/default.nix b/pkgs/development/interpreters/python-new/2.5/default.nix index 01fa7ca882f3..10943c9842d7 100644 --- a/pkgs/development/interpreters/python-new/2.5/default.nix +++ b/pkgs/development/interpreters/python-new/2.5/default.nix @@ -33,7 +33,7 @@ in # python wiht all features enabled. # 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 - pythonFull = t.pythonMinimal.passthru.fun { + pythonFull = t.pythonMinimal.merge { name = "python-${t.version}-full"; cfg = { zlibSupport = true; @@ -79,48 +79,46 @@ in # lib to verify it works # You can define { python25 { debugCmd = "DISPLAY=:0.0 pathtoxterm"; } # in your config for easier debugging.. - pythonLibStub = composableDerivation { - initial = { - propagatedBuildInputs = [ t.pythonFull ]; # see [1] - postPhases = ["postAll"]; # using new name so that you dno't override this phase by accident - prePhases = ["defineValidatingEval"]; - # ensure phases are run or a non zero exit status is caused (if there are any syntax errors such as eval "while") - defineValidatingEval = '' - eval(){ - e="$(type eval | { read; while read line; do echo $line; done })" - unset eval; - local evalSucc="failure" - eval "evalSucc=ok;""$1" - eval "$e" - [ $evalSucc = "failure" ] && { echo "eval failed, snippet:"; echo "$1"; return 1; } - } - ''; - postAll = '' - ensureDir $out/nix-support - echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook - # run check - if [ -n "$pyCheck" ]; then - ( . $out/nix-support/setup-hook - mkdir $TMP/new-test; cd $TMP/new-test - echo PYTHONPATH=$PYTHONPATH - echo NIX_PYTHON_SITES=$NIX_PYTHON_SITES - script="$(echo -e "import sys\nprint sys.path\npyCheck\nprint \"check ok\"")" - script="''${script/pyCheck/$pyCheck}" - echo "check script is"; echo "$script" - echo "$script" | python || { ${ getConfig [t.versionAttr "debugCmd"] ":"} ; echo "pycheck failed"; exit 1; } - ) - fi''; - passthru = { - libPython = t.version; # used to find all python libraries fitting this version (-> see name all below) - }; - mergeAttrBy = { - pyCheck = x : y : "${x}\n${y}"; - }; - }; + pythonLibStub = composableDerivation {} { + propagatedBuildInputs = [ t.pythonFull ]; # see [1] + postPhases = ["postAll"]; # using new name so that you dno't override this phase by accident + prePhases = ["defineValidatingEval"]; + # ensure phases are run or a non zero exit status is caused (if there are any syntax errors such as eval "while") + defineValidatingEval = '' + eval(){ + e="$(type eval | { read; while read line; do echo $line; done })" + unset eval; + local evalSucc="failure" + eval "evalSucc=ok;""$1" + eval "$e" + [ $evalSucc = "failure" ] && { echo "eval failed, snippet:"; echo "$1"; return 1; } + } + ''; + postAll = '' + ensureDir $out/nix-support + echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook + # run check + if [ -n "$pyCheck" ]; then + ( . $out/nix-support/setup-hook + mkdir $TMP/new-test; cd $TMP/new-test + echo PYTHONPATH=$PYTHONPATH + echo NIX_PYTHON_SITES=$NIX_PYTHON_SITES + script="$(echo -e "import sys\nprint sys.path\npyCheck\nprint \"check ok\"")" + script="''${script/pyCheck/$pyCheck}" + echo "check script is"; echo "$script" + echo "$script" | python || { ${ getConfig [t.versionAttr "debugCmd"] ":"} ; echo "pycheck failed"; exit 1; } + ) + fi''; + passthru = { + libPython = t.version; # used to find all python libraries fitting this version (-> see name all below) + }; + mergeAttrBy = { + pyCheck = x : y : "${x}\n${y}"; + }; }; # 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''; installPhase = ''python setup.py $setupFlags install --prefix=$out''; mergeAttrBy = { @@ -130,7 +128,7 @@ in ### python libraries: - wxPythonBaseFun = (t.pythonLibSetup.passthru.funMerge (a : + wxPythonBaseFun = (t.pythonLibSetup.merge (a : let inherit (a.fixed) wxGTK version; in { buildInputs = [p.pkgconfig wxGTK (wxGTK.gtk)]; @@ -144,7 +142,7 @@ in license="wxWinLL-3"; }; } - )).passthru.fun; + )).merge; wxPython26 = t.wxPythonBaseFun { version = "2.6.3.3"; @@ -166,7 +164,7 @@ in #}; # couldn't download source - #foursuite = pythonLibSetup.passthru.fun { + #foursuite = pythonLibSetup.merge { # version = "1.0.2"; # name = "4suite-${version}"; # src = fetchurl { @@ -175,7 +173,7 @@ in # }; #}; - #bsddb3 = t.pythonLibSetup.passthru.fun { + #bsddb3 = t.pythonLibSetup.merge { # version = "1.0.2"; # name = "bsddb3-4.5.0"; # 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. # 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. - pygtkBaseFun = (t.pythonLibStub.passthru.funMerge (a : + pygtkBaseFun = (t.pythonLibStub.merge (a : let inherit (a.fixed) glib gtk; in lib.mergeAttrsByFuncDefaults [ { unpackPhase = "true"; @@ -312,7 +310,7 @@ in # ''; #}; - pygtk212 = t.pygtkBaseFun.passthru.funMerge (a : { + pygtk212 = t.pygtkBaseFun.merge (a : { version = "2.12.1"; name = "pygobject-${a.fixed.pygobjectVersion}-and-pygtk-${a.fixed.version}"; pygtkSrc = fetchurl { @@ -326,7 +324,7 @@ in ''; }); - pycairo = t.pythonLibStub.passthru.fun { + pycairo = t.pythonLibStub.merge { name = "pycairo-1.8.0"; buildInputs = [ p.pkgconfig p.cairo p.x11 ]; src = fetchurl { @@ -336,7 +334,7 @@ in pyCheck = "import cairo"; }; - gstPython = t.pythonLibStub.passthru.fun { + gstPython = t.pythonLibStub.merge { name = "gst-python-0.10.13"; src = fetchurl { 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 { url = http://download.berlios.de/pygoocanvas/pygoocanvas-0.10.0.tar.gz; sha256 = "0pxznzdscbhvn8102vrqy3r1g6ss4sgs8wwy6y4c5g26rrp7l55d"; @@ -393,7 +391,7 @@ in }; }; -# zope = t.pythonLibStub.passthru.fun rec { +# zope = t.pythonLibStub.merge rec { #[> version = "3.3.1"; # version = "svn"; # name = "zope-${version}"; @@ -409,7 +407,7 @@ in # pyCheck = ""; # }; - setuptools = t.pythonLibSetup.passthru.fun { + setuptools = t.pythonLibSetup.merge { name = "setuptools-0.6c9"; postUnpack = '' 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"; name = "zope.interface-${version}"; buildInputs = [ t.setuptools ]; @@ -440,7 +438,7 @@ in pyCheck = "from zope.interface import Interface, Attribute"; }; - dbusPython = t.pythonLibStub.passthru.fun rec { + dbusPython = t.pythonLibStub.merge rec { version = "0.83.0"; name = "dbus-python-0.83.0"; buildInputs = [ p.pkgconfig ]; @@ -457,7 +455,7 @@ in }; }; - pythonXlib = t.pythonLibSetup.passthru.fun { + pythonXlib = t.pythonLibSetup.merge { name = "python-xlib-0.14"; src = fetchurl { 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"; buildInputs = [ t.setuptools ]; src = fetchurl { @@ -485,7 +483,7 @@ in pyCheck = "from mechanize import Browser"; }; - pexpect = t.pythonLibSetup.passthru.fun { + pexpect = t.pythonLibSetup.merge { name = "pexpect-2.3"; src = fetchurl { url = mirror://sourceforge/pexpect/pexpect-2.3.tar.gz; @@ -500,24 +498,22 @@ in ### python applications - pythonExStub = composableDerivation { - initial = { - buildInputs = [p.makeWrapper]; - postPhases = ["wrapExecutables"]; - propagatedBuildInputs = [ t.pythonFull ]; # see [1] + pythonExStub = composableDerivation {} { + buildInputs = [p.makeWrapper]; + postPhases = ["wrapExecutables"]; + propagatedBuildInputs = [ t.pythonFull ]; # see [1] - # adding $out to NIX_PYTHON_SITES because some of those executables seem to come with extra libs - wrapExecutables = '' - for prog in $out/bin/*; do - wrapProgram "$prog" \ - --set NIX_PYTHON_SITES "$NIX_PYTHON_SITES:$out" \ - --set PYTHONPATH "\$PYTHONPATH:$out" - done - ''; - }; + # adding $out to NIX_PYTHON_SITES because some of those executables seem to come with extra libs + wrapExecutables = '' + for prog in $out/bin/*; do + wrapProgram "$prog" \ + --set NIX_PYTHON_SITES "$NIX_PYTHON_SITES:$out" \ + --set PYTHONPATH "\$PYTHONPATH:$out" + done + ''; }; - pitivi = t.pythonExStub.passthru.fun { + pitivi = t.pythonExStub.merge { name = "pitivi-0.11.2"; src = fetchurl { 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"; buildInputs = [ t.pygtk212 t.gstPython /*t.gnomePython (contained in gtk) t.gnomePythonExtras */ t.pythonXlib p.perl p.perlXMLParser p.gettext]; diff --git a/pkgs/development/interpreters/python-new/2.5/python.nix b/pkgs/development/interpreters/python-new/2.5/python.nix index 6ae5ffb68228..932d29b40848 100644 --- a/pkgs/development/interpreters/python-new/2.5/python.nix +++ b/pkgs/development/interpreters/python-new/2.5/python.nix @@ -2,11 +2,11 @@ args: with args; let inherit (lib) optional prepareDerivationArgs concatStringsSep fix; in 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); LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") attr.buildInputs); }); - initial = { + } { postPhases = ["runCheck"]; @@ -65,5 +65,4 @@ composableDerivation { rm -rf $out/lib/python2.5/test "; - }; -} + } diff --git a/pkgs/development/tools/misc/avrdude/default.nix b/pkgs/development/tools/misc/avrdude/default.nix index 38871c8fd4c5..ce2d36bebe80 100644 --- a/pkgs/development/tools/misc/avrdude/default.nix +++ b/pkgs/development/tools/misc/avrdude/default.nix @@ -1,32 +1,30 @@ args: with args; let edf = composableDerivation.edf; in -composableDerivation.composableDerivation { - initial = { - name="avrdude-5.4"; +composableDerivation.composableDerivation {} { + name="avrdude-5.4"; - src = fetchurl { - url = http://mirror.switch.ch/mirror/gentoo/distfiles/avrdude-5.4.tar.gz; - sha256 = "bee4148c51ec95999d803cb9f68f12ac2e9128b06f07afe307d38966c0833b30"; - }; + src = fetchurl { + url = http://mirror.switch.ch/mirror/gentoo/distfiles/avrdude-5.4.tar.gz; + sha256 = "bee4148c51ec95999d803cb9f68f12ac2e9128b06f07afe307d38966c0833b30"; + }; - configureFlags = [ "--disable-dependency-tracking" ]; + configureFlags = [ "--disable-dependency-tracking" ]; - buildInputs = [yacc flex]; + buildInputs = [yacc flex]; - flags = - edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; } - // edf { name = "parport"; } - ; + flags = + edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; } + // edf { name = "parport"; } + ; - cfg = { - docSupport = false; # untested - parportSupport = true; - }; + cfg = { + docSupport = false; # untested + parportSupport = true; + }; - meta = { - license = "GPL-2"; - description = "AVR Downloader/UploaDEr"; - homepage = http://savannah.nongnu.org/projects/avrdude; - }; + meta = { + license = "GPL-2"; + description = "AVR Downloader/UploaDEr"; + homepage = http://savannah.nongnu.org/projects/avrdude; }; } diff --git a/pkgs/lib/composable-derivation.nix b/pkgs/lib/composable-derivation.nix index f597dc07bd6a..cc789866e2da 100644 --- a/pkgs/lib/composable-derivation.nix +++ b/pkgs/lib/composable-derivation.nix @@ -9,18 +9,23 @@ let inherit (lib) nv nvs; in # grep the mailinglist by title "python proposal" (dec 08) # -> http://mail.cs.uu.nl/pipermail/nix-dev/2008-December/001571.html # to see why this got complicated when using all its features + # TODO add newer example using new syntax (kernel derivation proposal -> mailinglist) composableDerivation = { - # modify args before applying stdenv.mkDerivation, this should remove at least attrs removeAttrsBy - f ? lib.prepareDerivationArgs, - stdenv ? pkgs.stdenv, - # initial set of arguments to be passed to stdenv.mkDerivation passing prepareDerivationArgs by default + mkDerivation ? pkgs.stdenv.mkDerivation, + # initial set of arguments to be passed to stdenv.mkDerivation passing prepareDerivationArgs by default initial ? {}, - # example func : (x: x // { x.buildInputs ++ ["foo"] }), but see mergeAttrByFunc which does this for you - merge ? (lib.mergeOrApply lib.mergeAttrByFunc) - }: lib.applyAndFun - (args: stdenv.mkDerivation (f args)) - merge - (merge { inherit (lib) mergeAttrBy; } initial); + + # list of functions to be applied before defaultOverridableDelayableArgs removes removeAttrs names + # prepareDerivationArgs handles derivation configurations + # applyPreTidy ? [ lib.prepareDerivationArgs ], + applyPreTidy ? [], + + removeAttrs ? ["cfg" "flags"] + + }: (lib.defaultOverridableDelayableArgs ( a: mkDerivation a) + { + inherit applyPreTidy removeAttrs; + }).merge; # some utility functions # use this function to generate flag attrs for prepareDerivationArgs diff --git a/pkgs/servers/squid/squids.nix b/pkgs/servers/squid/squids.nix index beffef173366..6d1fa34e8229 100644 --- a/pkgs/servers/squid/squids.nix +++ b/pkgs/servers/squid/squids.nix @@ -1,29 +1,27 @@ args: with args; let edf = composableDerivation.edf; in rec { - squid30 = composableDerivation.composableDerivation { - initial = { - name = "squid-3.0-stable5"; + squid30 = composableDerivation.composableDerivation {} { + name = "squid-3.0-stable5"; - 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"; - }; + 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"; + }; + }; - squid3Beta = squid30.passthru.funMerge { + squid3Beta = squid30.merge { name = "squid-3.1-beta"; src = args.fetchurl { 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"]; }; - squid3Head = squid3Beta.passthru.funMerge { + squid3Head = squid3Beta.merge { name = "squid-3.1-HEAD"; src = args.fetchurl { url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.0.3-20081221.tar.bz2;