summary refs log tree commit diff
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/jimtcl/default.nix8
-rw-r--r--pkgs/development/interpreters/lush/default.nix4
-rw-r--r--pkgs/development/interpreters/octave/hg.nix49
-rw-r--r--pkgs/development/interpreters/python/build-python-package.nix126
-rw-r--r--pkgs/development/interpreters/python/catch_conflicts.py30
-rw-r--r--pkgs/development/interpreters/python/cpython/3.3/default.nix6
-rw-r--r--pkgs/development/interpreters/python/cpython/3.4/default.nix6
-rw-r--r--pkgs/development/interpreters/python/cpython/3.5/default.nix22
-rw-r--r--pkgs/development/interpreters/python/cpython/3.6/default.nix7
-rw-r--r--pkgs/development/interpreters/python/mk-python-derivation.nix95
-rw-r--r--pkgs/development/interpreters/python/run_setup.py8
-rw-r--r--pkgs/development/interpreters/python/wrap-python.nix51
-rw-r--r--pkgs/development/interpreters/python/wrap.sh118
-rw-r--r--pkgs/development/interpreters/ruby/dev.nix1
-rw-r--r--pkgs/development/interpreters/ruby/rubygems-src.nix4
-rw-r--r--pkgs/development/interpreters/tcl/generic.nix16
16 files changed, 460 insertions, 91 deletions
diff --git a/pkgs/development/interpreters/jimtcl/default.nix b/pkgs/development/interpreters/jimtcl/default.nix
index a67dc323601f..4ac9b6479560 100644
--- a/pkgs/development/interpreters/jimtcl/default.nix
+++ b/pkgs/development/interpreters/jimtcl/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
     sqlite readline asciidoc SDL SDL_gfx
   ];
 
+  NIX_CFLAGS_COMPILE = [ "-I${SDL.dev}/include/SDL" ];
+
   configureFlags = [
     "--with-ext=oo"
     "--with-ext=tree"
@@ -25,12 +27,6 @@ stdenv.mkDerivation {
     "--ipv6"
   ];
 
-  preConfigurePhase = ''
-    export CFLAGS=$(sdl-config --cflags)
-    export LDFLAGS=$(sdl-config --libs)
-  '';
-
-
   meta = {
     description = "An open source small-footprint implementation of the Tcl programming language";
     homepage = http://jim.tcl.tk/;
diff --git a/pkgs/development/interpreters/lush/default.nix b/pkgs/development/interpreters/lush/default.nix
index dcfdc11c7a9e..62568c40c784 100644
--- a/pkgs/development/interpreters/lush/default.nix
+++ b/pkgs/development/interpreters/lush/default.nix
@@ -1,5 +1,5 @@
 {stdenv, fetchurl, libX11, xproto, indent, readline, gsl, freeglut, mesa, SDL
-, blas, binutils, intltool, gettext, zlib}:
+, blas, binutils, intltool, gettext, zlib, libSM}:
 
 stdenv.mkDerivation rec {
   baseName = "lush";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [
-    libX11 xproto indent readline gsl freeglut mesa SDL blas binutils
+    libX11 libSM xproto indent readline gsl freeglut mesa SDL blas binutils
     intltool gettext zlib
   ];
 
diff --git a/pkgs/development/interpreters/octave/hg.nix b/pkgs/development/interpreters/octave/hg.nix
deleted file mode 100644
index 797fff584f6a..000000000000
--- a/pkgs/development/interpreters/octave/hg.nix
+++ /dev/null
@@ -1,49 +0,0 @@
-{stdenv, fetchurl, gfortran, readline, ncurses, perl, flex,
- bison, autoconf, automake, sourceFromHead, config, lib, atlas, gperf, python, glibc, gnuplot, texinfo, texLive, qhull, libX11}:
-
-let commonBuildInputs = [gfortran readline ncurses perl glibc qhull libX11 texinfo]; in
-
-stdenv.mkDerivation ({
-  NIX_LDFLAGS = "-lpthread";
-  configureFlags = "--enable-readline --enable-dl";
-  meta = { 
-      description = "High-level interactive language for numerical computations";
-      homepage = http://www.octave.org;
-      license = stdenv.lib.licenses.gpl3;
-    };
-} // (
-  if config.octave.devVersion or false then {
-    name = "octave-hg"; # developement version mercurial repo
-    # REGION AUTO UPDATE:   { name="octave"; type = "hg"; url = "http://www.octave.org/hg/octave"; }
-    src = sourceFromHead "octave-03b414516dd8.tar.gz"
-                 (fetchurl { url = "http://mawercer.de/~nix/repos/octave-03b414516dd8.tar.gz"; sha256 = "30877f1e2ff1a456e7a76153aabf7c59ce7c7a8b63eda0515b1eead6a4351ce7"; });
-    # END
-    # HOME is set to $TMP because octave needs to access ${HOME}/.octave_hist while running targets
-    # in doc/interpreter.. Maybe this can be done better. This hack is fastest :)
-    preConfigure = ''
-        # glob is contained in glibc! Don't know why autotools want to use -lglob
-        sed -i 's/-lglob//' configure.in
-        ./autogen.sh
-        export HOME=$TMP
-        '';
-    buildInputs = commonBuildInputs ++ [ flex bison autoconf automake gperf gnuplot texLive ]
-                  ++ lib.optionals (config.octave.atlas or true) [ python atlas ];
-    # it does build, but documentation doesn't.. So just remove that directory
-    # from the buildfile
-    buildPhase = ''
-      sed -i octMakefile \
-        -e 's/^\(INSTALL_SUBDIRS = .*\)doc \(.*\)$/\1 \2/' \
-        -e 's/^\(SUBDIRS = .*\)doc \(.*\)$/\1 \2/' \
-        -e 's/\$(MAKE) -C doc/#/'
-      make
-    '';
-  } else {
-    name = "octave-3.1.55";
-    src =  fetchurl {
-      url = ftp://ftp.octave.org/pub/octave/bleeding-edge/octave-3.1.55.tar.bz2;
-      sha256 = "1lm4v85kdic4n5yxwzrdb0v6dc6nw06ljgx1q8hfkmi146kpg7s6";
-    };
-    buildInputs = commonBuildInputs ++ [ flex bison autoconf automake python ]
-                  ++ lib.optionals (config.octave.atlas or true) [ python atlas ];
-  }
-))
diff --git a/pkgs/development/interpreters/python/build-python-package.nix b/pkgs/development/interpreters/python/build-python-package.nix
new file mode 100644
index 000000000000..a92296cedbaa
--- /dev/null
+++ b/pkgs/development/interpreters/python/build-python-package.nix
@@ -0,0 +1,126 @@
+/* This function provides a generic Python package builder.  It is
+   intended to work with packages that use `distutils/setuptools'
+   (http://pypi.python.org/pypi/setuptools/), which represents a large
+   number of Python packages nowadays.  */
+
+{ lib
+, python
+, mkPythonDerivation
+, bootstrapped-pip
+}:
+
+{ buildInputs ? []
+
+# propagate build dependencies so in case we have A -> B -> C,
+# C can import package A propagated by B
+#, propagatedBuildInputs ? []
+
+# passed to "python setup.py build_ext"
+# https://github.com/pypa/pip/issues/881
+, setupPyBuildFlags ? []
+
+# Execute before shell hook
+, preShellHook ? ""
+
+# Execute after shell hook
+, postShellHook ? ""
+
+# Additional flags to pass to "pip install".
+, installFlags ? []
+
+, format ? "setup"
+
+, ... } @ attrs:
+
+
+
+
+let
+  # use setuptools shim (so that setuptools is imported before distutils)
+  # pip does the same thing: https://github.com/pypa/pip/pull/3265
+  setuppy = ./run_setup.py;
+
+  formatspecific =
+    if format == "wheel" then
+      {
+        unpackPhase = ''
+          mkdir dist
+          cp $src dist/"''${src#*-}"
+        '';
+
+        # Wheels are pre-compiled
+        buildPhase = attrs.buildPhase or ":";
+        installCheckPhase = attrs.checkPhase or ":";
+
+        # Wheels don't have any checks to run
+        doCheck = attrs.doCheck or false;
+      }
+    else if format == "setup" then
+      {
+        # we copy nix_run_setup.py over so it's executed relative to the root of the source
+        # many project make that assumption
+        buildPhase = attrs.buildPhase or ''
+          runHook preBuild
+          cp ${setuppy} nix_run_setup.py
+          ${python.interpreter} nix_run_setup.py ${lib.optionalString (setupPyBuildFlags != []) ("build_ext " + (lib.concatStringsSep " " setupPyBuildFlags))} bdist_wheel
+          runHook postBuild
+        '';
+
+        installCheckPhase = attrs.checkPhase or ''
+          runHook preCheck
+          ${python.interpreter} nix_run_setup.py test
+          runHook postCheck
+        '';
+
+        # Python packages that are installed with setuptools
+        # are typically distributed with tests.
+        # With Python it's a common idiom to run the tests
+        # after the software has been installed.
+        doCheck = attrs.doCheck or true;
+      }
+    else
+      throw "Unsupported format ${format}";
+
+in mkPythonDerivation ( attrs // {
+
+  # To build and install a wheel we need pip
+  buildInputs = buildInputs ++ [ bootstrapped-pip ];
+
+#inherit propagatedBuildInputs;
+
+  configurePhase = attrs.configurePhase or ''
+    runHook preConfigure
+
+    # patch python interpreter to write null timestamps when compiling python files
+    # this way python doesn't try to update them when we freeze timestamps in nix store
+    export DETERMINISTIC_BUILD=1
+
+    runHook postConfigure
+  '';
+
+  installPhase = attrs.installPhase or ''
+    runHook preInstall
+
+    mkdir -p "$out/${python.sitePackages}"
+    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
+
+    pushd dist
+    ${bootstrapped-pip}/bin/pip install *.whl --no-index --prefix=$out --no-cache ${toString installFlags}
+    popd
+
+    runHook postInstall
+  '';
+
+  shellHook = attrs.shellHook or ''
+    ${preShellHook}
+    if test -e setup.py; then
+       tmp_path=$(mktemp -d)
+       export PATH="$tmp_path/bin:$PATH"
+       export PYTHONPATH="$tmp_path/${python.sitePackages}:$PYTHONPATH"
+       mkdir -p $tmp_path/${python.sitePackages}
+       ${bootstrapped-pip}/bin/pip install -e . --prefix $tmp_path
+    fi
+    ${postShellHook}
+  '';
+
+} // formatspecific)
diff --git a/pkgs/development/interpreters/python/catch_conflicts.py b/pkgs/development/interpreters/python/catch_conflicts.py
new file mode 100644
index 000000000000..bb82900c65a9
--- /dev/null
+++ b/pkgs/development/interpreters/python/catch_conflicts.py
@@ -0,0 +1,30 @@
+import pkg_resources
+import collections
+import sys
+
+do_abort = False
+packages = collections.defaultdict(list)
+
+for f in sys.path:
+    for req in pkg_resources.find_distributions(f):
+        if req not in packages[req.project_name]:
+            # some exceptions inside buildPythonPackage
+            if req.project_name in ['setuptools', 'pip', 'wheel']:
+                continue
+            packages[req.project_name].append(req)
+
+
+for name, duplicates in packages.items():
+    if len(duplicates) > 1:
+        do_abort = True
+        print("Found duplicated packages in closure for dependency '{}': ".format(name))
+        for dup in duplicates:
+            print("  " + repr(dup))
+
+if do_abort:
+    print("")
+    print(
+        'Package duplicates found in closure, see above. Usually this '
+        'happens if two packages depend on different version '
+        'of the same dependency.')
+    sys.exit(1)
diff --git a/pkgs/development/interpreters/python/cpython/3.3/default.nix b/pkgs/development/interpreters/python/cpython/3.3/default.nix
index 1d2312fdc151..cb48186a69e7 100644
--- a/pkgs/development/interpreters/python/cpython/3.3/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.3/default.nix
@@ -2,7 +2,6 @@
 , bzip2
 , db
 , gdbm
-, less
 , libX11, xproto
 , lzma
 , ncurses
@@ -29,10 +28,6 @@ let
     zlib bzip2 lzma gdbm sqlite db readline ncurses openssl tcl tk libX11 xproto
   ];
 
-  propagatedBuildInputs = [
-    less
-  ];
-
 in
 stdenv.mkDerivation {
   name = "python3-${version}";
@@ -40,7 +35,6 @@ stdenv.mkDerivation {
   inherit majorVersion version;
 
   inherit buildInputs;
-  inherit propagatedBuildInputs;
 
   src = fetchurl {
     url = "http://www.python.org/ftp/python/${version}/Python-${version}.tar.xz";
diff --git a/pkgs/development/interpreters/python/cpython/3.4/default.nix b/pkgs/development/interpreters/python/cpython/3.4/default.nix
index 64c61e504b7e..2293e6d485a9 100644
--- a/pkgs/development/interpreters/python/cpython/3.4/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.4/default.nix
@@ -2,7 +2,6 @@
 , bzip2
 , db
 , gdbm
-, less
 , libX11, xproto
 , lzma
 , ncurses
@@ -44,10 +43,6 @@ let
     xproto
   ] ++ optionals stdenv.isDarwin [ CF configd ];
 
-  propagatedBuildInputs = [
-    less
-  ];
-
 in
 stdenv.mkDerivation {
   name = "python3-${fullVersion}";
@@ -55,7 +50,6 @@ stdenv.mkDerivation {
   inherit majorVersion version;
 
   inherit buildInputs;
-  inherit propagatedBuildInputs;
 
   src = fetchurl {
     url = "http://www.python.org/ftp/python/${version}/Python-${fullVersion}.tar.xz";
diff --git a/pkgs/development/interpreters/python/cpython/3.5/default.nix b/pkgs/development/interpreters/python/cpython/3.5/default.nix
index c36d7c2a6eb9..1b6814ea4363 100644
--- a/pkgs/development/interpreters/python/cpython/3.5/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.5/default.nix
@@ -1,8 +1,6 @@
 { stdenv, fetchurl
 , bzip2
-, db
 , gdbm
-, less
 , libX11, xproto
 , lzma
 , ncurses
@@ -34,7 +32,6 @@ let
     lzma
     gdbm
     sqlite
-    db
     readline
     ncurses
     openssl
@@ -43,11 +40,6 @@ let
     libX11
     xproto
   ] ++ optionals stdenv.isDarwin [ CF configd ];
-
-  propagatedBuildInputs = [
-    less
-  ];
-
 in
 stdenv.mkDerivation {
   name = "python3-${fullVersion}";
@@ -55,7 +47,6 @@ stdenv.mkDerivation {
   inherit majorVersion version;
 
   inherit buildInputs;
-  inherit propagatedBuildInputs;
 
   src = fetchurl {
     url = "http://www.python.org/ftp/python/${version}/Python-${fullVersion}.tar.xz";
@@ -102,10 +93,21 @@ stdenv.mkDerivation {
     paxmark E $out/bin/python${majorVersion}
   '';
 
+  postFixup = ''
+    # Get rid of retained dependencies on -dev packages, and remove
+    # some $TMPDIR references to improve binary reproducibility.
+    for i in $out/lib//python${majorVersion}/_sysconfigdata.py $out/lib/python${majorVersion}/config-${majorVersion}m/Makefile; do
+      sed -i $i -e "s|-I/nix/store/[^ ']*||g" -e "s|-L/nix/store/[^ ']*||g" -e "s|$TMPDIR|/no-such-path|g"
+    done
+
+    # FIXME: should regenerate this.
+    rm $out/lib/python${majorVersion}/__pycache__/_sysconfigdata.cpython*
+  '';
+
   passthru = rec {
     zlibSupport = zlib != null;
     sqliteSupport = sqlite != null;
-    dbSupport = db != null;
+    dbSupport = false;
     readlineSupport = readline != null;
     opensslSupport = openssl != null;
     tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null);
diff --git a/pkgs/development/interpreters/python/cpython/3.6/default.nix b/pkgs/development/interpreters/python/cpython/3.6/default.nix
index 3269a3c9684f..2c1846442070 100644
--- a/pkgs/development/interpreters/python/cpython/3.6/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.6/default.nix
@@ -3,7 +3,6 @@
 , bzip2
 , db
 , gdbm
-, less
 , libX11, xproto
 , lzma
 , ncurses
@@ -45,11 +44,6 @@ let
     libX11
     xproto
   ] ++ optionals stdenv.isDarwin [ CF configd ];
-
-  propagatedBuildInputs = [
-    less
-  ];
-
 in
 stdenv.mkDerivation {
   name = "python3-${fullVersion}";
@@ -57,7 +51,6 @@ stdenv.mkDerivation {
   inherit majorVersion version;
 
   inherit buildInputs;
-  inherit propagatedBuildInputs;
 
   src = fetchurl {
     url = "https://www.python.org/ftp/python/${majorVersion}.0/Python-${fullVersion}.tar.xz";
diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix
new file mode 100644
index 000000000000..99af42cd7add
--- /dev/null
+++ b/pkgs/development/interpreters/python/mk-python-derivation.nix
@@ -0,0 +1,95 @@
+/* Generic builder for Python packages that come without a setup.py. */
+
+{ lib
+, python
+, wrapPython
+, setuptools
+, unzip
+, ensureNewerSourcesHook
+}:
+
+{ name
+
+# by default prefix `name` e.g. "python3.3-${name}"
+, namePrefix ? python.libPrefix + "-"
+
+# Dependencies for building the package
+, buildInputs ? []
+
+# Dependencies needed for running the checkPhase.
+# These are added to buildInputs when doCheck = true.
+, checkInputs ? []
+
+# propagate build dependencies so in case we have A -> B -> C,
+# C can import package A propagated by B
+, propagatedBuildInputs ? []
+
+# DEPRECATED: use propagatedBuildInputs
+, pythonPath ? []
+
+# used to disable derivation, useful for specific python versions
+, disabled ? false
+
+# Raise an error if two packages are installed with the same name
+, catchConflicts ? true
+
+# Additional arguments to pass to the makeWrapper function, which wraps
+# generated binaries.
+, makeWrapperArgs ? []
+
+, meta ? {}
+
+, passthru ? {}
+
+, doCheck ? false
+
+, ... } @ attrs:
+
+
+# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
+if disabled
+then throw "${name} not supported for interpreter ${python.executable}"
+else
+
+python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
+
+  name = namePrefix + name;
+
+  inherit pythonPath;
+
+  buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath
+    ++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
+    ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip)
+    ++ lib.optionals doCheck checkInputs;
+
+  # propagate python/setuptools to active setup-hook in nix-shell
+  propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ];
+
+  # Python packages don't have a checkPhase, only an installCheckPhase
+  doCheck = false;
+  doInstallCheck = doCheck;
+
+  postFixup = attrs.postFixup or ''
+    wrapPythonPrograms
+  '' + lib.optionalString catchConflicts ''
+    # check if we have two packages with the same name in closure and fail
+    # this shouldn't happen, something went wrong with dependencies specs
+    ${python.interpreter} ${./catch_conflicts.py}
+  '';
+
+  passthru = {
+    inherit python; # The python interpreter
+  } // passthru;
+
+  meta = with lib.maintainers; {
+    # default to python's platforms
+    platforms = python.meta.platforms;
+  } // meta // {
+    # add extra maintainer(s) to every package
+    maintainers = (meta.maintainers or []) ++ [ chaoflow domenkozar ];
+    # a marker for release utilities to discover python packages
+    isBuildPythonPackage = python.meta.platforms;
+  };
+})
+
+
diff --git a/pkgs/development/interpreters/python/run_setup.py b/pkgs/development/interpreters/python/run_setup.py
new file mode 100644
index 000000000000..e3a530eb0cb6
--- /dev/null
+++ b/pkgs/development/interpreters/python/run_setup.py
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+
+import setuptools
+import tokenize
+
+__file__='setup.py';
+
+exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
diff --git a/pkgs/development/interpreters/python/wrap-python.nix b/pkgs/development/interpreters/python/wrap-python.nix
new file mode 100644
index 000000000000..b965ff5350b1
--- /dev/null
+++ b/pkgs/development/interpreters/python/wrap-python.nix
@@ -0,0 +1,51 @@
+{ lib
+, python
+, makeSetupHook
+, makeWrapper }:
+
+with lib;
+
+makeSetupHook {
+      deps = makeWrapper;
+      substitutions.libPrefix = python.libPrefix;
+      substitutions.executable = python.interpreter;
+      substitutions.python = python;
+      substitutions.magicalSedExpression = let
+        # Looks weird? Of course, it's between single quoted shell strings.
+        # NOTE: Order DOES matter here, so single character quotes need to be
+        #       at the last position.
+        quoteVariants = [ "'\"'''\"'" "\"\"\"" "\"" "'\"'\"'" ]; # hey Vim: ''
+
+        mkStringSkipper = labelNum: quote: let
+          label = "q${toString labelNum}";
+          isSingle = elem quote [ "\"" "'\"'\"'" ];
+          endQuote = if isSingle then "[^\\\\]${quote}" else quote;
+        in ''
+          /^[a-z]?${quote}/ {
+            /${quote}${quote}|${quote}.*${endQuote}/{n;br}
+            :${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label}
+          }
+        '';
+
+        # This preamble does two things:
+        # * Sets argv[0] to the original application's name; otherwise it would be .foo-wrapped.
+        #   Python doesn't support `exec -a`.
+        # * Adds all required libraries to sys.path via `site.addsitedir`. It also handles *.pth files.
+        preamble = ''
+          import sys
+          import site
+          import functools
+          sys.argv[0] = '"'$(basename "$f")'"'
+          functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo())
+        '';
+
+      in ''
+        1 {
+          :r
+          /\\$|,$/{N;br}
+          /__future__|^ |^ *(#.*)?$/{n;br}
+          ${concatImapStrings mkStringSkipper quoteVariants}
+          /^[^# ]/i ${replaceStrings ["\n"] [";"] preamble}
+        }
+      '';
+} ./wrap.sh
diff --git a/pkgs/development/interpreters/python/wrap.sh b/pkgs/development/interpreters/python/wrap.sh
new file mode 100644
index 000000000000..f4b63b826403
--- /dev/null
+++ b/pkgs/development/interpreters/python/wrap.sh
@@ -0,0 +1,118 @@
+# Wrapper around wrapPythonProgramsIn, below. The $pythonPath
+# variable is passed in from the buildPythonPackage function.
+wrapPythonPrograms() {
+    wrapPythonProgramsIn $out "$out $pythonPath"
+}
+
+# Builds environment variables like PYTHONPATH and PATH walking through closure
+# of dependencies.
+buildPythonPath() {
+    local pythonPath="$1"
+    local path
+
+    # Create an empty table of python paths (see doc on _addToPythonPath
+    # for how this is used). Build up the program_PATH and program_PYTHONPATH
+    # variables.
+    declare -A pythonPathsSeen=()
+    program_PYTHONPATH=
+    program_PATH=
+    pythonPathsSeen["@python@"]=1
+    addToSearchPath program_PATH @python@/bin
+    for path in $pythonPath; do
+        _addToPythonPath $path
+    done
+}
+
+# Patches a Python script so that it has correct libraries path and executable
+# name.
+patchPythonScript() {
+    local f="$1"
+
+    # The magicalSedExpression will invoke a "$(basename "$f")", so
+    # if you change $f to something else, be sure to also change it
+    # in pkgs/top-level/python-packages.nix!
+    # It also uses $program_PYTHONPATH.
+    sed -i "$f" -re '@magicalSedExpression@'
+}
+
+# Transforms any binaries generated by the setup.py script, replacing them
+# with an executable shell script which will set some environment variables
+# and then call into the original binary (which has been given a .wrapped
+# suffix).
+wrapPythonProgramsIn() {
+    local dir="$1"
+    local pythonPath="$2"
+    local f
+
+    buildPythonPath "$pythonPath"
+
+    # Find all regular files in the output directory that are executable.
+    for f in $(find "$dir" -type f -perm -0100); do
+        # Rewrite "#! .../env python" to "#! /nix/store/.../python".
+        # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
+        # Python to use besides one with this hook anyway.
+        if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
+            sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
+        fi
+
+        # catch /python and /.python-wrapped
+        if head -n1 "$f" | grep -q '/\.\?\(python\|pypy\)'; then
+            # dont wrap EGG-INFO scripts since they are called from python
+            if echo "$f" | grep -qv EGG-INFO/scripts; then
+                echo "wrapping \`$f'..."
+                patchPythonScript "$f"
+                # wrapProgram creates the executable shell script described
+                # above. The script will set PYTHONPATH and PATH variables.!
+                # (see pkgs/build-support/setup-hooks/make-wrapper.sh)
+                local -a wrap_args=("$f"
+                                 --prefix PATH ':' "$program_PATH")
+
+                # Add any additional arguments provided by makeWrapperArgs
+                # argument to buildPythonPackage.
+                local -a user_args="($makeWrapperArgs)"
+                local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
+                wrapProgram "${wrapProgramArgs[@]}"
+            fi
+        fi
+    done
+}
+
+# Adds the lib and bin directories to the PYTHONPATH and PATH variables,
+# respectively. Recurses on any paths declared in
+# `propagated-native-build-inputs`, while avoiding duplicating paths by
+# flagging the directories it has visited in `pythonPathsSeen`.
+_addToPythonPath() {
+    local dir="$1"
+    # Stop if we've already visited here.
+    if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
+    pythonPathsSeen[$dir]=1
+    # addToSearchPath is defined in stdenv/generic/setup.sh. It will have
+    # the effect of calling `export program_X=$dir/...:$program_X`.
+    addToSearchPath program_PYTHONPATH $dir/lib/@libPrefix@/site-packages
+    addToSearchPath program_PATH $dir/bin
+
+    # Inspect the propagated inputs (if they exist) and recur on them.
+    local prop="$dir/nix-support/propagated-native-build-inputs"
+    if [ -e $prop ]; then
+        local new_path
+        for new_path in $(cat $prop); do
+            _addToPythonPath $new_path
+        done
+    fi
+}
+
+createBuildInputsPth() {
+    local category="$1"
+    local inputs="$2"
+    if [ foo"$inputs" != foo ]; then
+        for x in $inputs; do
+            if $(echo -n $x |grep -q python-recursive-pth-loader); then
+                continue
+            fi
+            if test -d "$x"/lib/@libPrefix@/site-packages; then
+                echo $x/lib/@libPrefix@/site-packages \
+                    >> "$out"/lib/@libPrefix@/site-packages/${name}-nix-python-$category.pth
+            fi
+        done
+    fi
+}
diff --git a/pkgs/development/interpreters/ruby/dev.nix b/pkgs/development/interpreters/ruby/dev.nix
index 7787306eb324..62d561fbc142 100644
--- a/pkgs/development/interpreters/ruby/dev.nix
+++ b/pkgs/development/interpreters/ruby/dev.nix
@@ -8,7 +8,6 @@ let
     ruby = ruby;
   };
   bundix_ = bundix.override {
-    ruby = ruby;
     bundler = bundler_;
   };
 in
diff --git a/pkgs/development/interpreters/ruby/rubygems-src.nix b/pkgs/development/interpreters/ruby/rubygems-src.nix
index fea749e7de0e..59b2becdc6e3 100644
--- a/pkgs/development/interpreters/ruby/rubygems-src.nix
+++ b/pkgs/development/interpreters/ruby/rubygems-src.nix
@@ -1,6 +1,6 @@
 { fetchurl
-, version ? "2.6.2"
-, sha256 ? "1j02ajici555f35vd6ky6m4bxs8lh8nqb1c59qqib4jp4ibcv6zy"
+, version ? "2.6.6"
+, sha256 ? "0x0ldlwr627d0brw96jdbscib6d2nk19izvnh8lzsasszi1k5rkq"
 }:
 fetchurl {
   url = "http://production.cf.rubygems.org/rubygems/rubygems-${version}.tgz";
diff --git a/pkgs/development/interpreters/tcl/generic.nix b/pkgs/development/interpreters/tcl/generic.nix
index d01df5ce8be8..3bf4ba2dc2f0 100644
--- a/pkgs/development/interpreters/tcl/generic.nix
+++ b/pkgs/development/interpreters/tcl/generic.nix
@@ -10,15 +10,27 @@ stdenv.mkDerivation rec {
 
   inherit src;
 
+  outputs = [ "out" "man" ];
+
+  setOutputFlags = false;
+
   preConfigure = ''
+    # Note: using $out instead of $man to prevent a runtime dependency on $man.
+    configureFlagsArray+=(--mandir=$out/share/man --enable-man-symlinks)
+
+    # Don't install tzdata because NixOS already has a more up-to-date copy.
+    configureFlagsArray+=(--with-tzdata=no)
+
     cd unix
   '';
 
+  enableParallelBuilding = true;
+
   postInstall = ''
     make install-private-headers
     ln -s $out/bin/tclsh${release} $out/bin/tclsh
   '';
-  
+
   meta = with stdenv.lib; {
     description = "The Tcl scription language";
     homepage = http://www.tcl.tk/;
@@ -26,7 +38,7 @@ stdenv.mkDerivation rec {
     platforms = platforms.all;
     maintainers = with maintainers; [ wkennington vrthra ];
   };
-  
+
   passthru = rec {
     inherit release version;
     libPrefix = "tcl${release}";