about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/build-managers
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/tools/build-managers')
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/alibuild/default.nix27
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/apache-ant/1.9.nix111
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/apache-ant/default.nix111
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/apache-maven/builder.sh17
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/apache-maven/default.nix27
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/arpa2cm/default.nix22
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bam/default.nix35
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/0.4.nix100
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/bazel-deps/default.nix81
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/default.nix25
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/deps.nix29
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/default.nix239
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks-0.4.patch51
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks.patch37
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bear/cmakepaths.patch13
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bear/default.nix33
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch23
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bloop/default.nix63
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/boot/builder.sh13
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/boot/default.nix25
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/buck/default.nix49
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/buck/pex-mtime.patch13
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/2.8.nix88
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/3.2.2-cygwin.patch274
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/application-services.patch15
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/default.nix114
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/libuv-application-services.patch83
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/search-path-2.8.patch92
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/cmake/search-path.patch62
-rwxr-xr-xnixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh129
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/colormake/default.nix25
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/conan/default.nix80
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/doit/default.nix39
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile2
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile.lock15
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/drake/default.nix18
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/drake/gemset.nix18
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/dub/default.nix109
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gn/default.nix62
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/default.nix62
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch32
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs.patch34
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/pselect.patch170
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gradle/default.nix103
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/gup/default.nix39
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/icmake/default.nix46
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/jam/default.nix36
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/kati/default.nix26
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/kati/version.patch19
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/leiningen/default.nix57
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/mage/default.nix32
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch25
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/meson/default.nix85
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/meson/fix-rpath.patch52
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/meson/gir-fallback-path.patch16
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/meson/setup-hook.sh41
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/mill/default.nix40
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/mk/builder.sh4
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/mk/default.nix14
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/ninja/default.nix49
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/ninja/setup-hook.sh78
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/pants/default.nix41
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/qbs/default.nix29
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile2
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile.lock13
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rake/default.nix15
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rake/gemset.nix10
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rebar/default.nix41
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rebar3/default.nix127
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/rebar3/hermetic-rebar3.patch103
-rwxr-xr-xnixpkgs/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap300
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/redo-sh/default.nix31
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/redo/default.nix28
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/remake/default.nix27
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/remake/glibc-2.27-glob.patch34
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix39
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/sbt/default.nix33
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/sbt/scala-native.nix18
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/scons/common.nix34
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/scons/default.nix18
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/scons/print-statements.patch13
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/scons/setup-hook.sh84
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/shards/default.nix32
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/tup/default.nix52
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/waf/default.nix33
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/waf/setup-hook.sh62
86 files changed, 4648 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/build-managers/alibuild/default.nix b/nixpkgs/pkgs/development/tools/build-managers/alibuild/default.nix
new file mode 100644
index 000000000000..eb805dcce7a9
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/alibuild/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, lib, python}:
+
+python.pkgs.buildPythonApplication rec {
+  pname = "alibuild";
+  version = "1.5.4rc3";
+
+  src = python.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "1mnh0h9m96p78b9ln1gbl4lw1mgl16qbyfi9fj2l13p3nxaq1sib";
+  };
+
+  argparse = null;
+
+  doCheck = false;
+  propagatedBuildInputs = [
+    python.pkgs.requests
+    python.pkgs.argparse
+    python.pkgs.pyyaml
+  ];
+
+  meta = with lib; {
+    homepage = "https://alisw.github.io/alibuild/";
+    description = "Build tool for ALICE experiment software";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ ktf ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/apache-ant/1.9.nix b/nixpkgs/pkgs/development/tools/build-managers/apache-ant/1.9.nix
new file mode 100644
index 000000000000..8816a005ca0f
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/apache-ant/1.9.nix
@@ -0,0 +1,111 @@
+{ fetchurl, stdenv, coreutils, makeWrapper }:
+
+let version = "1.9.6"; in
+
+stdenv.mkDerivation {
+  name = "ant-${version}";
+
+  buildInputs = [ makeWrapper ];
+
+  src = fetchurl {
+    url = "mirror://apache/ant/binaries/apache-ant-${version}-bin.tar.bz2";
+    sha256 = "1cwd5vq175gyicw0hkm8idwa33zxwhf7xlxywaqxcqqdjql0jfx4";
+  };
+
+  contrib = fetchurl {
+    url = mirror://sourceforge/ant-contrib/ant-contrib-1.0b3-bin.tar.bz2;
+    sha256 = "96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1";
+  };
+
+  installPhase =
+    ''
+      mkdir -p $out/bin $out/lib/ant
+      mv * $out/lib/ant/
+
+      # Get rid of the manual (35 MiB).  Maybe we should put this in a
+      # separate output.  Keep the antRun script since it's vanilla sh
+      # and needed for the <exec/> task (but since we set ANT_HOME to
+      # a weird value, we have to move antRun to a weird location).
+      # Get rid of the other Ant scripts since we provide our own.
+      mv $out/lib/ant/bin/antRun $out/bin/
+      rm -rf $out/lib/ant/{manual,bin,WHATSNEW}
+      mkdir $out/lib/ant/bin
+      mv $out/bin/antRun $out/lib/ant/bin/
+
+      # Install ant-contrib.
+      unpackFile $contrib
+      cp -p ant-contrib/ant-contrib-*.jar $out/lib/ant/lib/
+
+      cat >> $out/bin/ant <<EOF
+      #! ${stdenv.shell} -e
+
+      ANT_HOME=$out/lib/ant
+
+      # Find the JDK by looking for javac.  As a fall-back, find the
+      # JRE by looking for java.  The latter allows just the JRE to be
+      # used with (say) ECJ as the compiler.  Finally, allow the GNU
+      # JVM.
+      if [ -z "\$JAVA_HOME" ]; then
+          for i in javac java gij; do
+              if p="\$(type -p \$i)"; then
+                  export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))"
+                  break
+              fi
+          done
+          if [ -z "\$JAVA_HOME" ]; then
+              echo "\$0: cannot find the JDK or JRE" >&2
+              exit 1
+          fi
+      fi
+
+      if [ -z \$NIX_JVM ]; then
+          if [ -e \$JAVA_HOME/bin/java ]; then
+              NIX_JVM=\$JAVA_HOME/bin/java
+          elif [ -e \$JAVA_HOME/bin/gij ]; then
+              NIX_JVM=\$JAVA_HOME/bin/gij
+          else
+              NIX_JVM=java
+          fi
+      fi
+
+      LOCALCLASSPATH="\$ANT_HOME/lib/ant-launcher.jar\''${LOCALCLASSPATH:+:}\$LOCALCLASSPATH"
+
+      exec \$NIX_JVM \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" \
+          -Dant.home=\$ANT_HOME -Dant.library.dir="\$ANT_LIB" \
+          org.apache.tools.ant.launch.Launcher \$NIX_ANT_ARGS \$ANT_ARGS \
+          -cp "\$CLASSPATH" "\$@"
+      EOF
+
+      chmod +x $out/bin/ant
+    ''; # */
+
+  meta = {
+    homepage = http://ant.apache.org/;
+    description = "A Java-based build tool";
+
+    longDescription = ''
+      Apache Ant is a Java-based build tool.  In theory, it is kind of like
+      Make, but without Make's wrinkles.
+
+      Why another build tool when there is already make, gnumake, nmake, jam,
+      and others? Because all those tools have limitations that Ant's
+      original author couldn't live with when developing software across
+      multiple platforms.  Make-like tools are inherently shell-based -- they
+      evaluate a set of dependencies, then execute commands not unlike what
+      you would issue in a shell.  This means that you can easily extend
+      these tools by using or writing any program for the OS that you are
+      working on.  However, this also means that you limit yourself to the
+      OS, or at least the OS type such as Unix, that you are working on.
+
+      Ant is different.  Instead of a model where it is extended with
+      shell-based commands, Ant is extended using Java classes.  Instead of
+      writing shell commands, the configuration files are XML-based, calling
+      out a target tree where various tasks get executed.  Each task is run
+      by an object that implements a particular Task interface.
+    '';
+
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [ stdenv.lib.maintainers.eelco ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/apache-ant/default.nix b/nixpkgs/pkgs/development/tools/build-managers/apache-ant/default.nix
new file mode 100644
index 000000000000..b6c2702485b1
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/apache-ant/default.nix
@@ -0,0 +1,111 @@
+{ fetchurl, stdenv, coreutils, makeWrapper }:
+
+let version = "1.10.2"; in
+
+stdenv.mkDerivation {
+  name = "ant-${version}";
+
+  buildInputs = [ makeWrapper ];
+
+  src = fetchurl {
+    url = "mirror://apache/ant/binaries/apache-ant-${version}-bin.tar.bz2";
+    sha256 = "0662qammjvibh9kgkxzadkayfn2r7iwnagbwaw28crqqclrb2rp1";
+  };
+
+  contrib = fetchurl {
+    url = mirror://sourceforge/ant-contrib/ant-contrib-1.0b3-bin.tar.bz2;
+    sha256 = "96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1";
+  };
+
+  installPhase =
+    ''
+      mkdir -p $out/bin $out/lib/ant
+      mv * $out/lib/ant/
+
+      # Get rid of the manual (35 MiB).  Maybe we should put this in a
+      # separate output.  Keep the antRun script since it's vanilla sh
+      # and needed for the <exec/> task (but since we set ANT_HOME to
+      # a weird value, we have to move antRun to a weird location).
+      # Get rid of the other Ant scripts since we provide our own.
+      mv $out/lib/ant/bin/antRun $out/bin/
+      rm -rf $out/lib/ant/{manual,bin,WHATSNEW}
+      mkdir $out/lib/ant/bin
+      mv $out/bin/antRun $out/lib/ant/bin/
+
+      # Install ant-contrib.
+      unpackFile $contrib
+      cp -p ant-contrib/ant-contrib-*.jar $out/lib/ant/lib/
+
+      cat >> $out/bin/ant <<EOF
+      #! ${stdenv.shell} -e
+
+      ANT_HOME=$out/lib/ant
+
+      # Find the JDK by looking for javac.  As a fall-back, find the
+      # JRE by looking for java.  The latter allows just the JRE to be
+      # used with (say) ECJ as the compiler.  Finally, allow the GNU
+      # JVM.
+      if [ -z "\$JAVA_HOME" ]; then
+          for i in javac java gij; do
+              if p="\$(type -p \$i)"; then
+                  export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))"
+                  break
+              fi
+          done
+          if [ -z "\$JAVA_HOME" ]; then
+              echo "\$0: cannot find the JDK or JRE" >&2
+              exit 1
+          fi
+      fi
+
+      if [ -z \$NIX_JVM ]; then
+          if [ -e \$JAVA_HOME/bin/java ]; then
+              NIX_JVM=\$JAVA_HOME/bin/java
+          elif [ -e \$JAVA_HOME/bin/gij ]; then
+              NIX_JVM=\$JAVA_HOME/bin/gij
+          else
+              NIX_JVM=java
+          fi
+      fi
+
+      LOCALCLASSPATH="\$ANT_HOME/lib/ant-launcher.jar\''${LOCALCLASSPATH:+:}\$LOCALCLASSPATH"
+
+      exec \$NIX_JVM \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" \
+          -Dant.home=\$ANT_HOME -Dant.library.dir="\$ANT_LIB" \
+          org.apache.tools.ant.launch.Launcher \$NIX_ANT_ARGS \$ANT_ARGS \
+          -cp "\$CLASSPATH" "\$@"
+      EOF
+
+      chmod +x $out/bin/ant
+    ''; # */
+
+  meta = {
+    homepage = http://ant.apache.org/;
+    description = "A Java-based build tool";
+
+    longDescription = ''
+      Apache Ant is a Java-based build tool.  In theory, it is kind of like
+      Make, but without Make's wrinkles.
+
+      Why another build tool when there is already make, gnumake, nmake, jam,
+      and others? Because all those tools have limitations that Ant's
+      original author couldn't live with when developing software across
+      multiple platforms.  Make-like tools are inherently shell-based -- they
+      evaluate a set of dependencies, then execute commands not unlike what
+      you would issue in a shell.  This means that you can easily extend
+      these tools by using or writing any program for the OS that you are
+      working on.  However, this also means that you limit yourself to the
+      OS, or at least the OS type such as Unix, that you are working on.
+
+      Ant is different.  Instead of a model where it is extended with
+      shell-based commands, Ant is extended using Java classes.  Instead of
+      writing shell commands, the configuration files are XML-based, calling
+      out a target tree where various tasks get executed.  Each task is run
+      by an object that implements a particular Task interface.
+    '';
+
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [ stdenv.lib.maintainers.eelco ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/apache-maven/builder.sh b/nixpkgs/pkgs/development/tools/build-managers/apache-maven/builder.sh
new file mode 100644
index 000000000000..8d06352b1356
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/apache-maven/builder.sh
@@ -0,0 +1,17 @@
+source $stdenv/setup
+
+unpackPhase
+
+mkdir -p $out/maven
+cp -r $name/* $out/maven
+
+makeWrapper $out/maven/bin/mvn $out/bin/mvn --set JAVA_HOME "$jdk"
+
+# Add the maven-axis and JIRA plugin by default when using maven 1.x
+if [ -e $out/maven/bin/maven ]
+then
+  export OLD_HOME=$HOME
+  export HOME=.
+  $out/maven/bin/maven plugin:download -DgroupId=maven-plugins -DartifactId=maven-axis-plugin -Dversion=0.7
+  export HOME=OLD_HOME
+fi
diff --git a/nixpkgs/pkgs/development/tools/build-managers/apache-maven/default.nix b/nixpkgs/pkgs/development/tools/build-managers/apache-maven/default.nix
new file mode 100644
index 000000000000..c48954a6aaa3
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/apache-maven/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, jdk, makeWrapper }:
+
+assert jdk != null;
+
+let version = "3.6.0"; in
+stdenv.mkDerivation rec {
+  name = "apache-maven-${version}";
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://apache/maven/maven-3/${version}/binaries/${name}-bin.tar.gz";
+    sha256 = "0ds61yy6hs7jgmld64b65ss6kpn5cwb186hw3i4il7vaydm386va";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  inherit jdk;
+
+  meta = with stdenv.lib; {
+    description = "Build automation tool (used primarily for Java projects)";
+    homepage = http://maven.apache.org/;
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ cko ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/arpa2cm/default.nix b/nixpkgs/pkgs/development/tools/build-managers/arpa2cm/default.nix
new file mode 100644
index 000000000000..0aec7491e4ad
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/arpa2cm/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "arpa2cm";
+  version = "0.5";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    sha256 = "093h7njj8d8iiwnw5byfxkkzlbny60fwv1w57j8f1lsd4yn6rih4";
+    rev = "version-${version}";
+    repo = "${pname}";
+    owner = "arpa2";
+  };
+
+  buildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "CMake Module library for the ARPA2 project";
+    license = licenses.bsd2;
+    maintainers = with maintainers; [ leenaars ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bam/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bam/default.nix
new file mode 100644
index 000000000000..c20431c5e7e0
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bam/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, lua5, python }:
+
+stdenv.mkDerivation rec {
+  name = "bam-${version}";
+  version = "0.4.0";
+
+  src = fetchurl {
+    url = "http://github.com/downloads/matricks/bam/${name}.tar.bz2";
+    sha256 = "0z90wvyd4nfl7mybdrv9dsd4caaikc6fxw801b72gqi1m9q0c0sn";
+  };
+
+  buildInputs = [ lua5 python ];
+
+  buildPhase = ''${stdenv.shell} make_unix.sh'';
+
+  checkPhase = ''${python.interpreter} scripts/test.py'';
+
+  installPhase = ''
+    mkdir -p "$out/share/bam"
+    cp -r docs examples tests  "$out/share/bam"
+    mkdir -p "$out/bin"
+    cp bam "$out/bin"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Yet another build manager";
+    maintainers = with maintainers;
+    [
+      raskin
+    ];
+    platforms = platforms.linux;
+    license = licenses.free;
+    downloadPage = "http://matricks.github.com/bam/";
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/0.4.nix b/nixpkgs/pkgs/development/tools/build-managers/bazel/0.4.nix
new file mode 100644
index 000000000000..1018abd6ee9c
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/0.4.nix
@@ -0,0 +1,100 @@
+{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, makeWrapper, which, coreutils
+# Always assume all markers valid (don't redownload dependencies).
+# Also, don't clean up environment variables.
+, enableNixHacks ? false
+}:
+
+stdenv.mkDerivation rec {
+
+  version = "0.4.5";
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/bazelbuild/bazel/;
+    description = "Build tool that builds code quickly and reliably";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ cstrahan philandstuff ];
+    platforms = platforms.linux;
+    broken = true; # 2018-08-07
+  };
+
+  name = "bazel-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
+    sha256 = "0asmq3kxnl4326zhgh13mvcrc8jvmiswjj4ymrq0943q4vj7nwrb";
+  };
+
+  preUnpack = ''
+    mkdir bazel
+    cd bazel
+  '';
+  sourceRoot = ".";
+
+  patches = lib.optional enableNixHacks ./nix-hacks-0.4.patch;
+
+  postPatch = ''
+    for f in $(grep -l -r '/bin/bash'); do
+      substituteInPlace "$f" --replace '/bin/bash' '${bash}/bin/bash'
+    done
+    for f in $(grep -l -r '/usr/bin/env'); do
+      substituteInPlace "$f" --replace '/usr/bin/env' '${coreutils}/bin/env'
+    done
+  '' + lib.optionalString stdenv.isDarwin ''
+    sed -i 's,/usr/bin/xcrun clang,clang,g' \
+      scripts/bootstrap/compile.sh \
+      src/tools/xcode/realpath/BUILD \
+      src/tools/xcode/stdredirect/BUILD \
+      src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
+    sed -i 's,/usr/bin/xcrun "''${TOOLNAME}","''${TOOLNAME}",g' \
+      src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
+    sed -i 's/"xcrun", "clang"/"clang"/g' tools/osx/xcode_configure.bzl
+  '';
+
+  buildInputs = [
+    jdk
+    zip
+    unzip
+    makeWrapper
+    which
+  ];
+
+  # These must be propagated since the dependency is hidden in a compressed
+  # archive.
+
+  propagatedBuildInputs = [
+    bash
+  ];
+
+  buildPhase = ''
+    export TMPDIR=/tmp/.bazel-$UID
+    ./compile.sh
+    ./output/bazel --output_user_root=$TMPDIR/.bazel build //scripts:bash_completion \
+      --spawn_strategy=standalone \
+      --genrule_strategy=standalone
+    cp bazel-bin/scripts/bazel-complete.bash output/
+  '';
+
+  # Build the CPP and Java examples to verify that Bazel works.
+
+  doCheck = true;
+  checkPhase = ''
+    export TEST_TMPDIR=$(pwd)
+    ./output/bazel test --test_output=errors \
+        examples/cpp:hello-success_test \
+        examples/java-native/src/test/java/com/example/myproject:hello
+  '';
+
+  # Bazel expects gcc and java to be in the path.
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv output/bazel $out/bin
+    wrapProgram "$out/bin/bazel" --prefix PATH : "${stdenv.cc}/bin:${jdk}/bin"
+    mkdir -p $out/share/bash-completion/completions $out/share/zsh/site-functions
+    mv output/bazel-complete.bash $out/share/bash-completion/completions/
+    cp scripts/zsh_completion/_bazel $out/share/zsh/site-functions/
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/bazel-deps/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bazel/bazel-deps/default.nix
new file mode 100644
index 000000000000..142f729517d5
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/bazel-deps/default.nix
@@ -0,0 +1,81 @@
+{ stdenv, buildBazelPackage, lib, fetchFromGitHub, git, jre, makeWrapper }:
+
+buildBazelPackage rec {
+  name = "bazel-deps-${version}";
+  version = "2018-11-01";
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/johnynek/bazel-deps";
+    description = "Generate bazel dependencies for maven artifacts";
+    license = licenses.mit;
+    maintainers = [ maintainers.uri-canva ];
+    platforms = platforms.all;
+  };
+
+  src = fetchFromGitHub {
+    owner = "johnynek";
+    repo = "bazel-deps";
+    rev = "1af8921d52f053fad575f26762533a3823b4a847";
+    sha256 = "0srz0sbz4bq9n7cp4g1n3kd3j6rcjqfi25sq8aa64l27yqzbk53x";
+  };
+
+  bazelTarget = "//src/scala/com/github/johnynek/bazel_deps:parseproject_deploy.jar";
+
+  buildInputs = [ git makeWrapper ];
+
+  fetchAttrs = {
+    preInstall = ''
+      # Remove all built in external workspaces, Bazel will recreate them when building
+      rm -rf $bazelOut/external/{bazel_tools,\@bazel_tools.marker,embedded_jdk,\@embedded_jdk.marker,local_*,\@local_*}
+      # For each external workspace, remove all files that aren't referenced by Bazel
+      # Many of these files are non-hermetic (for example .git/refs/remotes/origin/HEAD)
+      files_to_delete=()
+      for workspace in $(find $bazelOut/external -maxdepth 2 -name "WORKSPACE" -print0 | xargs -0L1 dirname); do
+        workspaceOut="$NIX_BUILD_TOP/workspaces/$(basename workspace)/output"
+        workspaceUserRoot="$NIX_BUILD_TOP/workspaces/$(basename workspace)/tmp"
+        rm -rf $workspace/.git
+        if ! targets_and_files=$(cd "$workspace" && bazel --output_base="$workspaceOut" --output_user_root="$workspaceUserRoot" query '//...:*' 2> /dev/null | sort -u); then
+          continue
+        fi
+        if ! targets=$(cd "$workspace" && bazel --output_base="$workspaceOut" --output_user_root="$workspaceUserRoot" query '//...:all' 2> /dev/null | sort -u); then
+          continue
+        fi
+        mapfile -t referenced_files < <(comm -23 <(printf '%s' "$targets_and_files") <(printf '%s' "$targets") | sed -e 's,^//:,,g' | sed -e 's,^//,,g' | sed -e 's,:,/,g')
+        referenced_files+=( "WORKSPACE" )
+        for referenced_file in "''${referenced_files[@]}"; do
+          # Some of the referenced files are symlinks to non-referenced files.
+          # The symlink targets have deterministic contents, but non-deterministic
+          # paths. Copy them to the referenced path, which is deterministic.
+          if target=$(readlink "$workspace/$referenced_file"); then
+            rm "$workspace/$referenced_file"
+            cp -a "$target" "$workspace/$referenced_file"
+          fi
+        done
+        mapfile -t workspace_files_to_delete < <(find "$workspace" -type f -or -type l | sort -u | comm -23 - <(printf "$workspace/%s\n" "''${referenced_files[@]}" | sort -u))
+        for workspace_file_to_delete in "''${workspace_files_to_delete[@]}"; do
+          files_to_delete+=("$workspace_file_to_delete")
+        done
+        # We're running bazel in many different workspaces in a loop. Letting the
+        # daemon shut down on its own would leave several daemons alive at the
+        # same time, using up a lot of memory. Shut them down explicitly instead.
+        bazel --output_base="$workspaceOut" --output_user_root="$workspaceUserRoot" shutdown 2> /dev/null
+      done
+      for file_to_delete in "''${files_to_delete[@]}"; do
+        rm "$file_to_delete"
+      done
+      find . -type d -empty -delete
+    '';
+
+    sha256 = "1gvl4a9z8p4ch2gmcj3lpp0imrkrvy8wng949p3wlkibi14hc6ww";
+  };
+
+  buildAttrs = {
+    installPhase = ''
+      mkdir -p $out/bin/bazel-bin/src/scala/com/github/johnynek/bazel_deps
+
+      cp gen_maven_deps.sh $out/bin
+      wrapProgram "$out/bin/gen_maven_deps.sh" --set JAVA_HOME "${jre}" --prefix PATH : ${lib.makeBinPath [ jre ]}
+      cp bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject_deploy.jar $out/bin/bazel-bin/src/scala/com/github/johnynek/bazel_deps
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/default.nix
new file mode 100644
index 000000000000..d7bed13ec9d9
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "bazel-buildtools-unstable-${version}";
+  version = "2018-10-11";
+
+  goPackagePath = "github.com/bazelbuild/buildtools";
+
+  src = fetchFromGitHub {
+    owner = "bazelbuild";
+    repo = "buildtools";
+    rev = "86b40b7fee59cc67d3371d20f10702fe8c6dd808";
+    sha256 = "10fzqbafwzv0bvx8aag78gh731k5j9nwlbcflhc5xm5zwhla9cyf";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Tools for working with Google's bazel buildtool. Includes buildifier, buildozer, and unused_deps.";
+    homepage = https://github.com/bazelbuild/buildtools;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ uri-canva ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/deps.nix b/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/deps.nix
new file mode 100644
index 000000000000..d53c744d04a9
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/buildtools/deps.nix
@@ -0,0 +1,29 @@
+[
+  {
+    goPackagePath = "github.com/bazelbuild/buildtools";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bazelbuild/buildtools";
+      rev = "588d90030bc8054b550967aa45a8a8d170deba0b";
+      sha256 = "18q1z138545kh4s5k0jcqwhpzc1w7il4x00l7yzv9wq8bg1vn1rv";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "3a3da3a4e26776cc22a79ef46d5d58477532dede";
+      sha256 = "05l0kjgk6ss98qii7vpjj2bqszyd16h448w47sv4422mp2xbni40";
+    };
+  }
+  {
+    goPackagePath = "github.com/google/skylark";
+    fetch = {
+      type = "git";
+      url = "https://github.com/google/skylark";
+      rev = "572cea2bd78e2f1de8f3e136db9413cf02f097eb";
+      sha256 = "0hc7gwvqsw421if06nlfdl86h6jl8wgjx1j2x2mzpnzdh1r03w92";
+    };
+  }
+]
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bazel/default.nix
new file mode 100644
index 000000000000..9aff59f3497f
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/default.nix
@@ -0,0 +1,239 @@
+{ stdenv, lib, fetchurl, fetchpatch, runCommand, makeWrapper
+, jdk, zip, unzip, bash, writeCBin, coreutils
+, which, python, perl, gnused, gnugrep, findutils
+# Apple dependencies
+, cctools, clang, libcxx, CoreFoundation, CoreServices, Foundation
+# Allow to independently override the jdks used to build and run respectively
+, buildJdk ? jdk, runJdk ? jdk
+# Always assume all markers valid (don't redownload dependencies).
+# Also, don't clean up environment variables.
+, enableNixHacks ? false
+}:
+
+let
+  srcDeps = lib.singleton (
+    fetchurl {
+      url = "https://github.com/google/desugar_jdk_libs/archive/fd937f4180c1b557805219af4482f1a27eb0ff2b.zip";
+      sha256 = "04hs399340xfwcdajbbcpywnb2syp6z5ydwg966if3hqdb2zrf23";
+    }
+  );
+
+  distDir = runCommand "bazel-deps" {} ''
+    mkdir -p $out
+    for i in ${builtins.toString srcDeps}; do cp $i $out/$(stripHash $i); done
+  '';
+
+  defaultShellPath = lib.makeBinPath [ bash coreutils findutils gnugrep gnused which ];
+
+in
+stdenv.mkDerivation rec {
+
+  version = "0.20.0";
+
+  meta = with lib; {
+    homepage = "https://github.com/bazelbuild/bazel/";
+    description = "Build tool that builds code quickly and reliably";
+    license = licenses.asl20;
+    maintainers = [ maintainers.mboes ];
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+
+  name = "bazel-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
+    sha256 = "1g9hglly5199gcw929fzc5f0d0dwlharkh387h58p1fq9ylayi8r";
+  };
+
+  sourceRoot = ".";
+
+  patches =
+    lib.optional enableNixHacks ./nix-hacks.patch;
+
+  # Bazel expects several utils to be available in Bash even without PATH. Hence this hack.
+
+  customBash = writeCBin "bash" ''
+    #include <stdio.h>
+    #include <stdlib.h>
+    #include <string.h>
+    #include <unistd.h>
+
+    extern char **environ;
+
+    int main(int argc, char *argv[]) {
+      char *path = getenv("PATH");
+      char *pathToAppend = "${defaultShellPath}";
+      char *newPath;
+      if (path != NULL) {
+        int length = strlen(path) + 1 + strlen(pathToAppend) + 1;
+        newPath = malloc(length * sizeof(char));
+        snprintf(newPath, length, "%s:%s", path, pathToAppend);
+      } else {
+        newPath = pathToAppend;
+      }
+      setenv("PATH", newPath, 1);
+      execve("${bash}/bin/bash", argv, environ);
+      return 0;
+    }
+  '';
+
+  postPatch = let
+    darwinPatches = ''
+      # Disable Bazel's Xcode toolchain detection which would configure compilers
+      # and linkers from Xcode instead of from PATH
+      export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
+
+      # Explicitly configure gcov since we don't have it on Darwin, so autodetection fails
+      export GCOV=${coreutils}/bin/false
+
+      # Framework search paths aren't added by bintools hook
+      # https://github.com/NixOS/nixpkgs/pull/41914
+      export NIX_LDFLAGS="$NIX_LDFLAGS -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks"
+
+      # libcxx includes aren't added by libcxx hook
+      # https://github.com/NixOS/nixpkgs/pull/41589
+      export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${libcxx}/include/c++/v1"
+
+      # 10.10 apple_sdk Foundation doesn't have type arguments on classes
+      # Remove this when we update apple_sdk
+      sed -i -e 's/<.*\*>//g' tools/osx/xcode_locator.m
+
+      # don't use system installed Xcode to run clang, use Nix clang instead
+      sed -i -e "s;/usr/bin/xcrun clang;${clang}/bin/clang $NIX_CFLAGS_COMPILE $NIX_LDFLAGS -framework CoreFoundation;g" \
+        scripts/bootstrap/compile.sh \
+        src/tools/xcode/realpath/BUILD \
+        src/tools/xcode/stdredirect/BUILD \
+        tools/osx/BUILD
+
+      # clang installed from Xcode has a compatibility wrapper that forwards
+      # invocations of gcc to clang, but vanilla clang doesn't
+      sed -i -e 's;_find_generic(repository_ctx, "gcc", "CC", overriden_tools);_find_generic(repository_ctx, "clang", "CC", overriden_tools);g' tools/cpp/unix_cc_configure.bzl
+
+      sed -i -e 's;/usr/bin/libtool;${cctools}/bin/libtool;g' tools/cpp/unix_cc_configure.bzl
+      wrappers=( tools/cpp/osx_cc_wrapper.sh tools/cpp/osx_cc_wrapper.sh.tpl )
+      for wrapper in "''${wrappers[@]}"; do
+        sed -i -e "s,/usr/bin/install_name_tool,${cctools}/bin/install_name_tool,g" $wrapper
+      done
+    '';
+    genericPatches = ''
+      find src/main/java/com/google/devtools -type f -print0 | while IFS="" read -r -d "" path; do
+        substituteInPlace "$path" \
+          --replace /bin/bash ${customBash}/bin/bash \
+          --replace /usr/bin/env ${coreutils}/bin/env \
+          --replace /bin/true ${coreutils}/bin/true
+      done
+      # Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
+      substituteInPlace scripts/bootstrap/compile.sh \
+          --replace /bin/sh ${customBash}/bin/bash
+
+      echo "build --experimental_distdir=${distDir}" >> .bazelrc
+      echo "fetch --experimental_distdir=${distDir}" >> .bazelrc
+      echo "build --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\"" >> .bazelrc
+      echo "build --host_copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt=\"/g')\"" >> .bazelrc
+      echo "build --linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt=\"-Wl,/g')\"" >> .bazelrc
+      echo "build --host_linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt=\"-Wl,/g')\"" >> .bazelrc
+      sed -i -e "420 a --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\" \\\\" scripts/bootstrap/compile.sh
+      sed -i -e "420 a --host_copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt=\"/g')\" \\\\" scripts/bootstrap/compile.sh
+      sed -i -e "420 a --linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt=\"-Wl,/g')\" \\\\" scripts/bootstrap/compile.sh
+      sed -i -e "420 a --host_linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt=\"-Wl,/g')\" \\\\" scripts/bootstrap/compile.sh
+
+      # --experimental_strict_action_env (which will soon become the
+      # default, see bazelbuild/bazel#2574) hardcodes the default
+      # action environment to a value that on NixOS at least is bogus.
+      # So we hardcode it to something useful.
+      substituteInPlace \
+        src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java \
+        --replace /bin:/usr/bin ${defaultShellPath}
+
+      # append the PATH with defaultShellPath in tools/bash/runfiles/runfiles.bash
+      echo "PATH=$PATH:${defaultShellPath}" >> runfiles.bash.tmp
+      cat tools/bash/runfiles/runfiles.bash >> runfiles.bash.tmp
+      mv runfiles.bash.tmp tools/bash/runfiles/runfiles.bash
+
+      patchShebangs .
+    '';
+    in lib.optionalString stdenv.hostPlatform.isDarwin darwinPatches
+     + genericPatches;
+
+  buildInputs = [
+    buildJdk
+  ];
+
+  nativeBuildInputs = [
+    zip
+    python
+    unzip
+    makeWrapper
+    which
+    customBash
+  ] ++ lib.optionals (stdenv.isDarwin) [ cctools clang libcxx CoreFoundation CoreServices Foundation ];
+
+  # If TMPDIR is in the unpack dir we run afoul of blaze's infinite symlink
+  # detector (see com.google.devtools.build.lib.skyframe.FileFunction).
+  # Change this to $(mktemp -d) as soon as we figure out why.
+
+  buildPhase = ''
+    export TMPDIR=/tmp/.bazel-$UID
+    ./compile.sh
+    scripts/generate_bash_completion.sh \
+        --bazel=./output/bazel \
+        --output=output/bazel-complete.bash \
+        --prepend=scripts/bazel-complete-template.bash
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+
+    # official wrapper scripts that searches for $WORKSPACE_ROOT/tools/bazel
+    # if it can’t find something in tools, it calls $out/bin/bazel-real
+    cp scripts/packages/bazel.sh $out/bin/bazel
+    mv output/bazel $out/bin/bazel-real
+
+    wrapProgram "$out/bin/bazel" --add-flags --server_javabase="${runJdk}"
+
+    # shell completion files
+    mkdir -p $out/share/bash-completion/completions $out/share/zsh/site-functions
+    mv output/bazel-complete.bash $out/share/bash-completion/completions/bazel
+    cp scripts/zsh_completion/_bazel $out/share/zsh/site-functions/
+  '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    export TEST_TMPDIR=$(pwd)
+
+    hello_test () {
+      $out/bin/bazel test --test_output=errors \
+        examples/cpp:hello-success_test \
+        examples/java-native/src/test/java/com/example/myproject:hello
+    }
+
+    # test whether $WORKSPACE_ROOT/tools/bazel works
+
+    mkdir -p tools
+    cat > tools/bazel <<"EOF"
+    #!${stdenv.shell} -e
+    exit 1
+    EOF
+    chmod +x tools/bazel
+
+    # first call should fail if tools/bazel is used
+    ! hello_test
+
+    cat > tools/bazel <<"EOF"
+    #!${stdenv.shell} -e
+    exec "$BAZEL_REAL" "$@"
+    EOF
+
+    # second call succeeds because it defers to $out/bin/bazel-real
+    hello_test
+  '';
+
+  # Save paths to hardcoded dependencies so Nix can detect them.
+  postFixup = ''
+    mkdir -p $out/nix-support
+    echo "${customBash} ${defaultShellPath}" > $out/nix-support/depends
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks-0.4.patch b/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks-0.4.patch
new file mode 100644
index 000000000000..563fe635e6b0
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks-0.4.patch
@@ -0,0 +1,51 @@
+diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+index eafa09fb5..d2d5e40e8 100644
+--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+@@ -287,21 +287,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
+           markerData.put(key, value);
+         }
+       }
+-      boolean result = false;
+-      if (markerRuleKey.equals(ruleKey)) {
+-        result = handler.verifyMarkerData(rule, markerData, env);
+-        if (env.valuesMissing()) {
+-          return null;
+-        }
+-      }
+ 
+-      if (result) {
+-        return new Fingerprint().addString(content).digestAndReset();
+-      } else {
+-        // So that we are in a consistent state if something happens while fetching the repository
+-        markerPath.delete();
+-        return null;
+-      }
++      return new Fingerprint().addString(content).digestAndReset();
+ 
+     } catch (IOException e) {
+       throw new RepositoryFunctionException(e, Transience.TRANSIENT);
+diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+index a7ebc8f7a..40f2049fa 100644
+--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+@@ -129,7 +129,6 @@ public class JavaSubprocessFactory implements SubprocessFactory {
+     ProcessBuilder builder = new ProcessBuilder();
+     builder.command(params.getArgv());
+     if (params.getEnv() != null) {
+-      builder.environment().clear();
+       builder.environment().putAll(params.getEnv());
+     }
+ 
+diff --git a/src/main/java/com/google/devtools/build/lib/worker/Worker.java b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
+index 0268d1b2b..637364657 100644
+--- a/src/main/java/com/google/devtools/build/lib/worker/Worker.java
++++ b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
+@@ -77,7 +77,6 @@ class Worker {
+         new ProcessBuilder(command)
+             .directory(workDir.getPathFile())
+             .redirectError(Redirect.appendTo(logFile.getPathFile()));
+-    processBuilder.environment().clear();
+     processBuilder.environment().putAll(workerKey.getEnv());
+ 
+     this.process = processBuilder.start();
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks.patch b/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
new file mode 100644
index 000000000000..da3f6248f220
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
@@ -0,0 +1,37 @@
+diff -Naur a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	1980-01-01 00:00:00.000000000 -0500
++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	2018-01-18 08:17:22.420459162 -0500
+@@ -287,21 +287,8 @@
+           markerData.put(key, value);
+         }
+       }
+-      boolean result = false;
+-      if (markerRuleKey.equals(ruleKey)) {
+-        result = handler.verifyMarkerData(rule, markerData, env);
+-        if (env.valuesMissing()) {
+-          return null;
+-        }
+-      }
+ 
+-      if (result) {
+-        return new Fingerprint().addString(content).digestAndReset();
+-      } else {
+-        // So that we are in a consistent state if something happens while fetching the repository
+-        markerPath.delete();
+-        return null;
+-      }
++      return new Fingerprint().addString(content).digestAndReset();
+ 
+     } catch (IOException e) {
+       throw new RepositoryFunctionException(e, Transience.TRANSIENT);
+diff -Naur a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	1980-01-01 00:00:00.000000000 -0500
++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	2018-01-18 08:17:53.274877980 -0500
+@@ -129,7 +129,6 @@
+     ProcessBuilder builder = new ProcessBuilder();
+     builder.command(params.getArgv());
+     if (params.getEnv() != null) {
+-      builder.environment().clear();
+       builder.environment().putAll(params.getEnv());
+     }
+ 
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bear/cmakepaths.patch b/nixpkgs/pkgs/development/tools/build-managers/bear/cmakepaths.patch
new file mode 100644
index 000000000000..d237267078e6
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bear/cmakepaths.patch
@@ -0,0 +1,13 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 04c5c58..429ca47 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -24,7 +24,7 @@ set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING  "Rogue")
+ 
+ set(EAR_LIB_FILE ${CMAKE_SHARED_LIBRARY_PREFIX}ear${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(EAR_LIB_PATH "${CMAKE_INSTALL_LIBDIR}/bear")
+-set(DEFAULT_PRELOAD_FILE ${CMAKE_INSTALL_PREFIX}/${EAR_LIB_PATH}/${EAR_LIB_FILE} CACHE STRING "Default path to libear.")
++set(DEFAULT_PRELOAD_FILE ${EAR_LIB_PATH}/${EAR_LIB_FILE} CACHE STRING "Default path to libear.")
+ 
+ add_subdirectory(libear)
+ add_subdirectory(bear)
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
new file mode 100644
index 000000000000..51e8d12d3147
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, cmake, python }:
+
+stdenv.mkDerivation rec {
+  name = "bear-${version}";
+  version = "2.3.13";
+
+  src = fetchFromGitHub {
+    owner = "rizsotto";
+    repo = "Bear";
+    rev = version;
+    sha256 = "0imvvs22gyr1v6ydgp5yn2nq8fb8llmz0ra1m733ikjaczl3jm7z";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ python ]; # just for shebang of bin/bear
+
+  doCheck = false; # all fail
+
+  patches = [ ./ignore_wrapper.patch ./cmakepaths.patch ];
+
+  meta = with stdenv.lib; {
+    description = "Tool that generates a compilation database for clang tooling";
+    longDescription = ''
+      Note: the bear command is very useful to generate compilation commands
+      e.g. for YouCompleteMe.  You just enter your development nix-shell
+      and run `bear make`.  It's not perfect, but it gets a long way.
+    '';
+    homepage = https://github.com/rizsotto/Bear;
+    license = licenses.gpl3Plus;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.vcunat maintainers.babariviere ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch b/nixpkgs/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch
new file mode 100644
index 000000000000..f70e3811f654
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch
@@ -0,0 +1,23 @@
+--- Bear-2.3.11-src/bear/main.py.in	1970-01-01 01:00:01.000000000 +0100
++++ Bear-2.3.11-src-patch/bear/main.py.in	1970-01-01 01:00:01.000000000 +0100
+@@ -49,6 +49,7 @@
+ import shutil
+ import contextlib
+ import logging
++from distutils.spawn import find_executable
+ 
+ # Map of ignored compiler option for the creation of a compilation database.
+ # This map is used in _split_command method, which classifies the parameters
+@@ -540,7 +541,11 @@
+                 any(pattern.match(cmd) for pattern in COMPILER_PATTERNS_CXX)
+ 
+         if command:  # not empty list will allow to index '0' and '1:'
+-            executable = os.path.basename(command[0])  # type: str
++            absolute_executable = os.path.realpath(find_executable(command[0]))
++            if 'wrapper' in absolute_executable:
++                return None
++
++            executable = os.path.basename(absolute_executable) # type: str
+             parameters = command[1:]  # type: List[str]
+             # 'wrapper' 'parameters' and
+             # 'wrapper' 'compiler' 'parameters' are valid.
\ No newline at end of file
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bloop/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bloop/default.nix
new file mode 100644
index 000000000000..db337137bb1a
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/bloop/default.nix
@@ -0,0 +1,63 @@
+{ stdenv, lib, fetchurl, coursier, jdk, jre, python, makeWrapper }:
+
+let
+  baseName = "bloop";
+  version = "1.1.2";
+  deps = stdenv.mkDerivation {
+    name = "${baseName}-deps-${version}";
+    buildCommand = ''
+      export COURSIER_CACHE=$(pwd)
+      ${coursier}/bin/coursier fetch ch.epfl.scala:bloop-frontend_2.12:${version} \
+        -r "bintray:scalameta/maven" \
+        -r "bintray:scalacenter/releases" \
+        -r "https://oss.sonatype.org/content/repositories/staging" > deps
+      mkdir -p $out/share/java
+      cp $(< deps) $out/share/java/
+    '';
+    outputHashMode = "recursive";
+    outputHashAlgo = "sha256";
+    outputHash     = "0ki4xh8z31nv42jik998r7gvsxcm0vysx83w0nyvbhi18cah1qh6";
+  };
+in
+stdenv.mkDerivation rec {
+  name = "${baseName}-${version}";
+
+  # Fetched from https://github.com/scalacenter/bloop/releases/download/v${version}/install.py
+  nailgunCommit = "dc1dd806";
+
+  buildInputs = [ jdk makeWrapper deps ];
+
+  phases = [ "installPhase" ];
+
+  client = fetchurl {
+    url = "https://raw.githubusercontent.com/scalacenter/nailgun/${nailgunCommit}/pynailgun/ng.py";
+    sha256 = "0qjw4nsyb4cxg96jj1yv5c0ivcxvmscxxqfzll5w9p1pjb30bq0n";
+  };
+
+  zshCompletion = fetchurl {
+    url = "https://raw.githubusercontent.com/scalacenter/bloop/v${version}/etc/zsh/_bloop";
+    sha256 = "1id6f1fgy2rk0q5aad6ffivhbxa94fallzsc04l9n0y1s2xdhqpm";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/zsh/site-functions
+
+    cp ${client} $out/bin/blp-client
+    cp ${zshCompletion} $out/share/zsh/site-functions/_bloop
+    chmod +x $out/bin/blp-client
+
+    makeWrapper ${jre}/bin/java $out/bin/blp-server \
+      --prefix PATH : ${lib.makeBinPath [ jdk ]} \
+      --add-flags "-cp $CLASSPATH bloop.Server"
+    makeWrapper $out/bin/blp-client $out/bin/bloop \
+      --prefix PATH : ${lib.makeBinPath [ python ]}
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://scalacenter.github.io/bloop/;
+    license = licenses.asl20;
+    description = "Bloop is a Scala build server and command-line tool to make the compile and test developer workflows fast and productive in a build-tool-agnostic way.";
+    maintainers = with maintainers; [ tomahna ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/boot/builder.sh b/nixpkgs/pkgs/development/tools/build-managers/boot/builder.sh
new file mode 100644
index 000000000000..c1481dc6a144
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/boot/builder.sh
@@ -0,0 +1,13 @@
+source $stdenv/setup
+
+boot_bin=$out/bin/boot
+
+mkdir -pv $(dirname $boot_bin)
+cp -v $src $boot_bin
+chmod -v 755 $boot_bin
+
+patchShebangs $boot_bin
+
+sed -i \
+    -e "s;\${BOOT_JAVA_COMMAND:-java};\${BOOT_JAVA_COMMAND:-${jdk}/bin/java};g" \
+    $boot_bin
diff --git a/nixpkgs/pkgs/development/tools/build-managers/boot/default.nix b/nixpkgs/pkgs/development/tools/build-managers/boot/default.nix
new file mode 100644
index 000000000000..d9dc59ee72df
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/boot/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, jdk }:
+
+stdenv.mkDerivation rec {
+  version = "2.7.2";
+  name = "boot-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/boot-clj/boot-bin/releases/download/${version}/boot.sh";
+    sha256 = "1hqp3xxmsj5vkym0l3blhlaq9g3w0lhjgmp37g6y3rr741znkk8c";
+  };
+
+  inherit jdk;
+  
+  builder = ./builder.sh;
+
+  propagatedBuildInputs = [ jdk ];
+
+  meta = with stdenv.lib; {
+    description = "Build tooling for Clojure";
+    homepage = http://boot-clj.com/;
+    license = licenses.epl10;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ ragge ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/buck/default.nix b/nixpkgs/pkgs/development/tools/build-managers/buck/default.nix
new file mode 100644
index 000000000000..18ced2628783
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/buck/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, jdk, ant, python2, python2Packages, watchman, bash, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "buck-${version}";
+  version = "2017.10.01.01";
+
+  src = fetchFromGitHub {
+    owner = "facebook";
+    repo = "buck";
+    rev = "v${version}";
+    sha256 = "05nyyb6f0hv1h67zzvdq8297yl8zjhpbasx35lxnrsjz0m1h8ngw";
+  };
+
+  patches = [ ./pex-mtime.patch ];
+
+  postPatch = ''
+    grep -l -r '/bin/bash' --null | xargs -0 sed -i -e "s!/bin/bash!${bash}/bin/bash!g"
+  '';
+
+  buildInputs = [ jdk ant python2 watchman python2Packages.pywatchman ];
+  nativeBuildInputs = [ makeWrapper ];
+
+  targets = [ "buck" "buckd" ];
+
+  buildPhase = ''
+    ant
+
+    for exe in ${toString targets}; do
+      ./bin/buck build //programs:$exe
+    done
+  '';
+
+  installPhase = ''
+    for exe in ${toString targets}; do
+      install -D -m755 buck-out/gen/programs/$exe.pex $out/bin/$exe
+      wrapProgram $out/bin/$exe \
+        --prefix PYTHONPATH : $PYTHONPATH \
+        --prefix PATH : "${stdenv.lib.makeBinPath [jdk watchman]}"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://buckbuild.com/;
+    description = "A high-performance build tool";
+    maintainers = [ maintainers.jgertm ];
+    license = licenses.asl20;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/buck/pex-mtime.patch b/nixpkgs/pkgs/development/tools/build-managers/buck/pex-mtime.patch
new file mode 100644
index 000000000000..b8726e64a604
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/buck/pex-mtime.patch
@@ -0,0 +1,13 @@
+diff --git a/third-party/py/pex/pex/common.py b/third-party/py/pex/pex/common.py
+index 76459ce23..eff411b20 100644
+--- a/third-party/py/pex/pex/common.py
++++ b/third-party/py/pex/pex/common.py
+@@ -328,4 +328,7 @@ class Chroot(object):
+   def zip(self, filename, mode='wb'):
+     with contextlib.closing(zipfile.ZipFile(filename, mode)) as zf:
+       for f in sorted(self.files()):
+-        zf.write(os.path.join(self.chroot, f), arcname=f, compress_type=zipfile.ZIP_DEFLATED)
++        path = os.path.join(self.chroot, f)
++        instant = 615532801
++        os.utime(path, (instant, instant))
++        zf.write(path, arcname=f, compress_type=zipfile.ZIP_DEFLATED)
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/2.8.nix b/nixpkgs/pkgs/development/tools/build-managers/cmake/2.8.nix
new file mode 100644
index 000000000000..ac438080b9ab
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/2.8.nix
@@ -0,0 +1,88 @@
+{ stdenv, fetchurl, fetchpatch, curl, expat, zlib, bzip2
+, useNcurses ? false, ncurses, useQt4 ? false, qt4, ps
+}:
+
+with stdenv.lib;
+
+assert stdenv ? cc;
+assert stdenv.cc ? libc;
+
+let
+  os = stdenv.lib.optionalString;
+  majorVersion = "2.8";
+  minorVersion = "12.2";
+  version = "${majorVersion}.${minorVersion}";
+in
+
+stdenv.mkDerivation rec {
+  name = "cmake-${os useNcurses "cursesUI-"}${os useQt4 "qt4UI-"}${version}";
+
+  inherit majorVersion;
+
+  src = fetchurl {
+    url = "${meta.homepage}files/v${majorVersion}/cmake-${version}.tar.gz";
+    sha256 = "0phf295a9cby0v7zqdswr238v5aiy3rb2fs6dz39zjxbmzlp8rcc";
+  };
+
+  enableParallelBuilding = true;
+
+  patches =
+    [(fetchpatch { # see https://www.cmake.org/Bug/view.php?id=13959
+      name = "FindFreetype-2.5.patch";
+      url = "https://public.kitware.com/Bug/file/4660/0001-Support-finding-freetype2-using-pkg-config.patch";
+      sha256 = "136z63ff83hnwd247cq4m8m8164pklzyl5i2csf5h6wd8p01pdkj";
+    })] ++
+    # Don't search in non-Nix locations such as /usr, but do search in our libc.
+    [ ./search-path-2.8.patch ] ++
+    optional (stdenv.hostPlatform != stdenv.buildPlatform) (fetchurl {
+      name = "fix-darwin-cross-compile.patch";
+      url = "https://public.kitware.com/Bug/file_download.php?"
+          + "file_id=4981&type=bug";
+      sha256 = "16acmdr27adma7gs9rs0dxdiqppm15vl3vv3agy7y8s94wyh4ybv";
+    });
+
+  postPatch = ''
+    substituteInPlace Utilities/cmlibarchive/CMakeLists.txt \
+      --replace '"-framework CoreServices"' '""'
+  '';
+
+  buildInputs = [ curl expat zlib bzip2 ]
+    ++ optional useNcurses ncurses
+    ++ optional useQt4 qt4;
+
+  propagatedBuildInputs = [ ps ];
+
+  CMAKE_PREFIX_PATH = concatStringsSep ":"
+    (concatMap (p: [ (p.dev or p) (p.out or p) ]) buildInputs);
+
+  configureFlags = [
+    "--docdir=/share/doc/${name}"
+    "--mandir=/share/man"
+    "--system-libs"
+    "--no-system-libarchive"
+   ] ++ stdenv.lib.optional useQt4 "--qt-gui";
+
+  setupHook = ./setup-hook.sh;
+
+  dontUseCmakeConfigure = true;
+
+  preConfigure = with stdenv; ''
+      source $setupHook
+      fixCmakeFiles .
+      substituteInPlace Modules/Platform/UnixPaths.cmake \
+        --subst-var-by libc_bin ${getBin cc.libc} \
+        --subst-var-by libc_dev ${getDev cc.libc} \
+        --subst-var-by libc_lib ${getLib cc.libc}
+      configureFlags="--parallel=''${NIX_BUILD_CORES:-1} $configureFlags"
+    '';
+
+  hardeningDisable = [ "format" ];
+
+  meta = {
+    homepage = https://cmake.org;
+    description = "Cross-Platform Makefile Generator";
+    platforms = if useQt4 then qt4.meta.platforms else stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ ];
+    license = stdenv.lib.licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/3.2.2-cygwin.patch b/nixpkgs/pkgs/development/tools/build-managers/cmake/3.2.2-cygwin.patch
new file mode 100644
index 000000000000..982aba17e874
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/3.2.2-cygwin.patch
@@ -0,0 +1,274 @@
+--- cmake-3.2.2/Source/cmFileCommand.cxx	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/ccmFileCommand.cxx	2015-06-10 11:02:27.345598700 +0200
+@@ -1179,7 +1179,7 @@
+   MatchProperties CollectMatchProperties(const char* file)
+     {
+     // Match rules are case-insensitive on some platforms.
+-#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
++#if defined(_WIN32) || defined(__APPLE__)
+     std::string lower = cmSystemTools::LowerCase(file);
+     const char* file_to_match = lower.c_str();
+ #else
+--- cmake-3.2.2/Source/cmInstallCommand.cxx	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/cmInstallCommand.cxx	2015-06-10 11:04:19.257935200 +0200
+@@ -1138,7 +1138,7 @@
+       {
+       literal_args += " REGEX \"";
+     // Match rules are case-insensitive on some platforms.
+-#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
++#if defined(_WIN32) || defined(__APPLE__)
+       std::string regex = cmSystemTools::LowerCase(args[i]);
+ #else
+       std::string regex = args[i];
+--- cmake-3.2.2/Source/kwsys/Glob.cxx	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/kwsys/Glob.cxx	2015-06-10 11:05:51.602674000 +0200
+@@ -37,7 +37,7 @@
+ #include <string.h>
+ namespace KWSYS_NAMESPACE
+ {
+-#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
++#if defined(_WIN32) || defined(__APPLE__)
+ // On Windows and apple, no difference between lower and upper case
+ # define KWSYS_GLOB_CASE_INDEPENDENT
+ #endif
+--- cmake-3.2.2/Source/kwsys/SystemInformation.cxx	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/kwsys/SystemInformation.cxx	2015-06-10 11:13:00.308303500 +0200
+@@ -911,7 +911,7 @@
+ // Hide implementation details in an anonymous namespace.
+ namespace {
+ // *****************************************************************************
+-#if defined(__linux) || defined(__APPLE__)
++#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
+ int LoadLines(
+       FILE *file,
+       kwsys_stl::vector<kwsys_stl::string> &lines)
+@@ -947,7 +947,7 @@
+   return nRead;
+ }
+ 
+-# if defined(__linux)
++# if defined(__linux) || defined(__CYGWIN__)
+ // *****************************************************************************
+ int LoadLines(
+       const char *fileName,
+@@ -986,7 +986,7 @@
+ }
+ #endif
+ 
+-#if defined(__linux)
++#if defined(__linux) || defined(__CYGWIN__)
+ // ****************************************************************************
+ template<typename T>
+ int GetFieldsFromFile(
+@@ -3132,7 +3132,6 @@
+     pos = buffer.find("processor\t",pos+1);
+     }
+ 
+-#ifdef __linux
+   // Find the largest physical id.
+   int maxId = -1;
+   kwsys_stl::string idc =
+@@ -3165,14 +3164,6 @@
+             atoi(this->ExtractValueFromCpuInfoFile(buffer,"ncpus active").c_str());
+     }
+ 
+-#else // __CYGWIN__
+-  // does not have "physical id" entries, neither "cpu cores"
+-  // this has to be fixed for hyper-threading.
+-  kwsys_stl::string cpucount =
+-    this->ExtractValueFromCpuInfoFile(buffer,"cpu count");
+-  this->NumberOfPhysicalCPU=
+-    this->NumberOfLogicalCPU = atoi(cpucount.c_str());
+-#endif
+   // gotta have one, and if this is 0 then we get a / by 0n
+   // better to have a bad answer than a crash
+   if(this->NumberOfPhysicalCPU <= 0)
+@@ -3370,7 +3361,7 @@
+   GlobalMemoryStatusEx(&statex);
+   return statex.ullTotalPhys/1024;
+ # endif
+-#elif defined(__linux)
++#elif defined(__linux) || defined(__CYGWIN__)
+   SystemInformation::LongLong memTotal=0;
+   int ierr=GetFieldFromFile("/proc/meminfo","MemTotal:",memTotal);
+   if (ierr)
+@@ -3501,7 +3492,7 @@
+   GlobalMemoryStatusEx(&statex);
+   return (statex.ullTotalPhys - statex.ullAvailPhys)/1024;
+ # endif
+-#elif defined(__linux)
++#elif defined(__linux) || defined(__CYGWIN__)
+   const char *names[3]={"MemTotal:","MemFree:",NULL};
+   SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)};
+   int ierr=GetFieldsFromFile("/proc/meminfo",names,values);
+@@ -3560,7 +3551,7 @@
+     return -2;
+     }
+   return pmc.WorkingSetSize/1024;
+-#elif defined(__linux)
++#elif defined(__linux) || defined(__CYGWIN__)
+   SystemInformation::LongLong memUsed=0;
+   int ierr=GetFieldFromFile("/proc/self/status","VmRSS:",memUsed);
+   if (ierr)
+@@ -3612,7 +3603,7 @@
+ {
+ #if defined(_WIN32)
+   return GetCurrentProcessId();
+-#elif defined(__linux) || defined(__APPLE__)
++#elif defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
+   return getpid();
+ #else
+   return -1;
+--- cmake-3.2.2/Source/kwsys/SystemTools.cxx	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/kwsys/SystemTools.cxx	2015-06-10 11:21:58.980443200 +0200
+@@ -93,19 +93,12 @@
+ # if defined(_MSC_VER) && _MSC_VER >= 1800
+ #  define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+ # endif
+-#elif defined (__CYGWIN__)
+-# include <windows.h>
+-# undef _WIN32
+ #endif
+ 
+ #if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
+ extern char **environ;
+ #endif
+ 
+-#ifdef __CYGWIN__
+-# include <sys/cygwin.h>
+-#endif
+-
+ // getpwnam doesn't exist on Windows and Cray Xt3/Catamount
+ // same for TIOCGWINSZ
+ #if defined(_WIN32) || defined (__LIBCATAMOUNT__)
+@@ -1148,15 +1141,7 @@
+     {
+     return false;
+     }
+-#if defined(__CYGWIN__)
+-  // Convert filename to native windows path if possible.
+-  char winpath[MAX_PATH];
+-  if(SystemTools::PathCygwinToWin32(filename.c_str(), winpath))
+-    {
+-    return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES);
+-    }
+-  return access(filename.c_str(), R_OK) == 0;
+-#elif defined(_WIN32)
++#if defined(_WIN32)
+   return (GetFileAttributesW(
+             SystemTools::ConvertToWindowsExtendedPath(filename).c_str())
+           != INVALID_FILE_ATTRIBUTES);
+@@ -1190,28 +1175,6 @@
+ }
+ 
+ //----------------------------------------------------------------------------
+-#ifdef __CYGWIN__
+-bool SystemTools::PathCygwinToWin32(const char *path, char *win32_path)
+-{
+-  SystemToolsTranslationMap::iterator i =
+-    SystemTools::Cyg2Win32Map->find(path);
+-
+-  if (i != SystemTools::Cyg2Win32Map->end())
+-    {
+-    strncpy(win32_path, i->second.c_str(), MAX_PATH);
+-    }
+-  else
+-    {
+-    if(cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) != 0)
+-      {
+-      win32_path[0] = 0;
+-      }
+-    SystemToolsTranslationMap::value_type entry(path, win32_path);
+-    SystemTools::Cyg2Win32Map->insert(entry);
+-    }
+-  return win32_path[0] != 0;
+-}
+-#endif
+ 
+ bool SystemTools::Touch(const kwsys_stl::string& filename, bool create)
+ {
+@@ -4307,7 +4270,7 @@
+ 
+ bool SystemTools::FileIsFullPath(const char* in_name, size_t len)
+ {
+-#if defined(_WIN32) || defined(__CYGWIN__)
++#if defined(_WIN32)
+   // On Windows, the name must be at least two characters long.
+   if(len < 2)
+     {
+@@ -5078,9 +5041,6 @@
+ static unsigned int SystemToolsManagerCount;
+ SystemToolsTranslationMap *SystemTools::TranslationMap;
+ SystemToolsTranslationMap *SystemTools::LongPathMap;
+-#ifdef __CYGWIN__
+-SystemToolsTranslationMap *SystemTools::Cyg2Win32Map;
+-#endif
+ 
+ // SystemToolsManager manages the SystemTools singleton.
+ // SystemToolsManager should be included in any translation unit
+@@ -5126,9 +5086,6 @@
+   // Allocate the translation map first.
+   SystemTools::TranslationMap = new SystemToolsTranslationMap;
+   SystemTools::LongPathMap = new SystemToolsTranslationMap;
+-#ifdef __CYGWIN__
+-  SystemTools::Cyg2Win32Map = new SystemToolsTranslationMap;
+-#endif
+ 
+   // Add some special translation paths for unix.  These are not added
+   // for windows because drive letters need to be maintained.  Also,
+@@ -5183,9 +5140,6 @@
+ {
+   delete SystemTools::TranslationMap;
+   delete SystemTools::LongPathMap;
+-#ifdef __CYGWIN__
+-  delete SystemTools::Cyg2Win32Map;
+-#endif
+ }
+ 
+ 
+--- cmake-3.2.2/Source/kwsys/SystemTools.hxx.in	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Source/kwsys/SystemTools.hxx.in	2015-06-10 11:24:24.271286600 +0200
+@@ -298,15 +298,6 @@
+   static bool FileExists(const kwsys_stl::string& filename);
+ 
+   /**
+-   * Converts Cygwin path to Win32 path. Uses dictionary container for
+-   * caching and calls to cygwin_conv_to_win32_path from Cygwin dll
+-   * for actual translation.  Returns true on success, else false.
+-   */
+-#ifdef __CYGWIN__
+-  static bool PathCygwinToWin32(const char *path, char *win32_path);
+-#endif
+-
+-  /**
+    * Return file length
+    */
+   static unsigned long FileLength(const kwsys_stl::string& filename);
+@@ -942,9 +933,6 @@
+    */
+   static SystemToolsTranslationMap *TranslationMap;
+   static SystemToolsTranslationMap *LongPathMap;
+-#ifdef __CYGWIN__
+-  static SystemToolsTranslationMap *Cyg2Win32Map;
+-#endif
+   friend class SystemToolsManager;
+ };
+ 
+--- cmake-3.2.2/Modules/FindCurses.cmake	2015-04-13 19:09:00.000000000 +0200
++++ cmake-3.2.2/Modules/FindCurses.cmake	2015-06-10 12:10:19.682030300 +0200
+@@ -60,15 +60,6 @@
+ if(CURSES_NCURSES_LIBRARY  AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
+   set(CURSES_USE_NCURSES TRUE)
+ endif()
+-# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
+-# cygwin ncurses stopped providing curses.h symlinks see above
+-# message.  Cygwin is an ncurses package, so force ncurses on
+-# cygwin if the curses.h is missing
+-if(CYGWIN)
+-  if(NOT EXISTS /usr/include/curses.h)
+-    set(CURSES_USE_NCURSES TRUE)
+-  endif()
+-endif()
+ 
+ 
+ # Not sure the logic is correct here.
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/application-services.patch b/nixpkgs/pkgs/development/tools/build-managers/cmake/application-services.patch
new file mode 100644
index 000000000000..c83f56ae5720
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/application-services.patch
@@ -0,0 +1,15 @@
+diff -ur cmake-3.12.1/Source/cmGlobalXCodeGenerator.cxx cmake-3.12.1-patched/Source/cmGlobalXCodeGenerator.cxx
+--- cmake-3.12.1/Source/cmGlobalXCodeGenerator.cxx	2018-08-09 21:14:08.000000000 +0900
++++ cmake-3.12.1-patched/Source/cmGlobalXCodeGenerator.cxx	2018-08-12 02:47:28.719691934 +0900
+@@ -35,11 +35,6 @@
+ 
+ struct cmLinkImplementation;
+ 
+-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(__APPLE__)
+-#  define HAVE_APPLICATION_SERVICES
+-#  include <ApplicationServices/ApplicationServices.h>
+-#endif
+-
+ #if defined(CMAKE_BUILD_WITH_CMAKE)
+ #  include "cmXMLParser.h"
+ 
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/cmake/default.nix
new file mode 100644
index 000000000000..68d4118f0491
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/default.nix
@@ -0,0 +1,114 @@
+{ stdenv, fetchurl, fetchpatch, pkgconfig
+, bzip2, curl, expat, libarchive, xz, zlib, libuv, rhash
+# darwin attributes
+, ps
+, isBootstrap ? false
+, useSharedLibraries ? (!isBootstrap && !stdenv.isCygwin)
+, useNcurses ? false, ncurses
+, useQt4 ? false, qt4
+, withQt5 ? false, qtbase
+}:
+
+assert withQt5 -> useQt4 == false;
+assert useQt4 -> withQt5 == false;
+
+with stdenv.lib;
+
+let
+  os = stdenv.lib.optionalString;
+  majorVersion = "3.12";
+  minorVersion = "1";
+  # from https://cmake.org/files/v3.12/cmake-3.12.1-SHA-256.txt
+  sha256 = "1ckswlaid3p2is1a80fmr4hgwpfsiif66giyx1z9ayhxx0n5qgf5";
+  version = "${majorVersion}.${minorVersion}";
+in
+
+stdenv.mkDerivation rec {
+  name = "cmake-${os isBootstrap "boot-"}${os useNcurses "cursesUI-"}${os withQt5 "qt5UI-"}${os useQt4 "qt4UI-"}${version}";
+
+  inherit majorVersion;
+
+  src = fetchurl {
+    url = "${meta.homepage}files/v${majorVersion}/cmake-${version}.tar.gz";
+    inherit sha256;
+  };
+
+  prePatch = optionalString (!useSharedLibraries) ''
+    substituteInPlace Utilities/cmlibarchive/CMakeLists.txt \
+      --replace '"-framework CoreServices"' '""'
+  '';
+
+  patches = [
+    # Don't search in non-Nix locations such as /usr, but do search in our libc.
+    ./search-path.patch
+
+    # Don't depend on frameworks.
+    ./application-services.patch
+
+    # Derived from https://github.com/libuv/libuv/commit/1a5d4f08238dd532c3718e210078de1186a5920d
+    ./libuv-application-services.patch
+  ] ++ optional stdenv.isCygwin ./3.2.2-cygwin.patch;
+
+  outputs = [ "out" ];
+  setOutputFlags = false;
+
+  setupHook = ./setup-hook.sh;
+
+  buildInputs =
+    [ setupHook pkgconfig ]
+    ++ optionals useSharedLibraries [ bzip2 curl expat libarchive xz zlib libuv rhash ]
+    ++ optional useNcurses ncurses
+    ++ optional useQt4 qt4
+    ++ optional withQt5 qtbase;
+
+  propagatedBuildInputs = optional stdenv.isDarwin ps;
+
+  preConfigure = ''
+    fixCmakeFiles .
+    substituteInPlace Modules/Platform/UnixPaths.cmake \
+      --subst-var-by libc_bin ${getBin stdenv.cc.libc} \
+      --subst-var-by libc_dev ${getDev stdenv.cc.libc} \
+      --subst-var-by libc_lib ${getLib stdenv.cc.libc}
+    substituteInPlace Modules/FindCxxTest.cmake \
+      --replace "$""{PYTHON_EXECUTABLE}" ${stdenv.shell}
+    configureFlags="--parallel=''${NIX_BUILD_CORES:-1} $configureFlags"
+  '';
+
+  configureFlags = [
+    "--docdir=share/doc/${name}"
+  ] ++ (if useSharedLibraries then [ "--no-system-jsoncpp" "--system-libs" ] else [ "--no-system-libs" ]) # FIXME: cleanup
+    ++ optional (useQt4 || withQt5) "--qt-gui"
+    ++ [
+    "--"
+    # We should set the proper `CMAKE_SYSTEM_NAME`.
+    # http://www.cmake.org/Wiki/CMake_Cross_Compiling
+    #
+    # Unfortunately cmake seems to expect absolute paths for ar, ranlib, and
+    # strip. Otherwise they are taken to be relative to the source root of the
+    # package being built.
+    "-DCMAKE_CXX_COMPILER=${stdenv.cc.targetPrefix}c++"
+    "-DCMAKE_C_COMPILER=${stdenv.cc.targetPrefix}cc"
+    "-DCMAKE_AR=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar"
+    "-DCMAKE_RANLIB=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ranlib"
+    "-DCMAKE_STRIP=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip"
+  ]
+    # Avoid depending on frameworks.
+    ++ optional (!useNcurses) "-DBUILD_CursesDialog=OFF";
+
+  dontUseCmakeConfigure = true;
+  enableParallelBuilding = true;
+
+  # This isn't an autoconf configure script; triples are passed via
+  # CMAKE_SYSTEM_NAME, etc.
+  configurePlatforms = [ ];
+
+  doCheck = false; # fails
+
+  meta = with stdenv.lib; {
+    homepage = http://www.cmake.org/;
+    description = "Cross-Platform Makefile Generator";
+    platforms = if useQt4 then qt4.meta.platforms else platforms.all;
+    maintainers = with maintainers; [ ttuegel lnl7 ];
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/libuv-application-services.patch b/nixpkgs/pkgs/development/tools/build-managers/cmake/libuv-application-services.patch
new file mode 100644
index 000000000000..08899f5c241f
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/libuv-application-services.patch
@@ -0,0 +1,83 @@
+diff -ur cmake-3.12.1/Utilities/cmlibuv/CMakeLists.txt cmake-3.12.1-patched/Utilities/cmlibuv/CMakeLists.txt
+--- cmake-3.12.1/Utilities/cmlibuv/CMakeLists.txt	2018-08-09 21:14:08.000000000 +0900
++++ cmake-3.12.1-patched/Utilities/cmlibuv/CMakeLists.txt	2018-08-13 10:14:53.000000000 +0900
+@@ -173,6 +173,22 @@
+     src/unix/kqueue.c
+     src/unix/proctitle.c
+     )
++
++  include(CheckIncludeFile)
++
++  check_include_file("ApplicationServices/ApplicationServices.h" HAVE_ApplicationServices)
++  if (HAVE_ApplicationServices)
++    list(APPEND uv_defines
++      HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H=1
++      )
++  endif()
++
++  check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices)
++  if (HAVE_CoreServices)
++    list(APPEND uv_defines
++      HAVE_CORESERVICES_CORESERVICES_H=1
++      )
++  endif()
+ endif()
+ 
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+diff -ur cmake-3.12.1/Utilities/cmlibuv/src/unix/darwin-proctitle.c cmake-3.12.1-patched/Utilities/cmlibuv/src/unix/darwin-proctitle.c
+--- cmake-3.12.1/Utilities/cmlibuv/src/unix/darwin-proctitle.c	2018-08-09 21:14:08.000000000 +0900
++++ cmake-3.12.1-patched/Utilities/cmlibuv/src/unix/darwin-proctitle.c	2018-08-13 10:01:29.000000000 +0900
+@@ -26,9 +26,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-#include <TargetConditionals.h>
+-
+-#if !TARGET_OS_IPHONE
++#if HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
+ # include <CoreFoundation/CoreFoundation.h>
+ # include <ApplicationServices/ApplicationServices.h>
+ #endif
+@@ -58,7 +56,7 @@
+ 
+ 
+ int uv__set_process_title(const char* title) {
+-#if TARGET_OS_IPHONE
++#if !HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
+   return uv__pthread_setname_np(title);
+ #else
+   CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
+@@ -205,5 +203,5 @@
+     dlclose(application_services_handle);
+ 
+   return err;
+-#endif  /* !TARGET_OS_IPHONE */
++#endif  /* HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H */
+ }
+diff -ur cmake-3.12.1/Utilities/cmlibuv/src/unix/fsevents.c cmake-3.12.1-patched/Utilities/cmlibuv/src/unix/fsevents.c
+--- cmake-3.12.1/Utilities/cmlibuv/src/unix/fsevents.c	2018-08-09 21:14:08.000000000 +0900
++++ cmake-3.12.1-patched/Utilities/cmlibuv/src/unix/fsevents.c	2018-08-13 10:01:29.000000000 +0900
+@@ -21,7 +21,7 @@
+ #include "uv.h"
+ #include "internal.h"
+ 
+-#if TARGET_OS_IPHONE
++#if !HAVE_CORESERVICES_CORESERVICES_H
+ 
+ /* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */
+ 
+@@ -38,7 +38,7 @@
+ void uv__fsevents_loop_delete(uv_loop_t* loop) {
+ }
+ 
+-#else /* TARGET_OS_IPHONE */
++#else /* !HAVE_CORESERVICES_CORESERVICES_H */
+ 
+ #include <dlfcn.h>
+ #include <assert.h>
+@@ -916,4 +916,4 @@
+   return 0;
+ }
+ 
+-#endif /* TARGET_OS_IPHONE */
++#endif /* !HAVE_CORESERVICES_CORESERVICES_H */
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path-2.8.patch b/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path-2.8.patch
new file mode 100644
index 000000000000..9fc949661686
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path-2.8.patch
@@ -0,0 +1,92 @@
+diff -ru3 cmake-2.8.12.2/Modules/Platform/Linux.cmake cmake-2.8.12.2-new/Modules/Platform/Linux.cmake
+--- cmake-2.8.12.2/Modules/Platform/Linux.cmake	2014-01-16 21:15:08.000000000 +0400
++++ cmake-2.8.12.2-new/Modules/Platform/Linux.cmake	2016-04-13 22:00:32.928575740 +0300
+@@ -36,22 +36,11 @@
+   # checking the platform every time.  This option is advanced enough
+   # that only package maintainers should need to adjust it.  They are
+   # capable of providing a setting on the command line.
+-  if(EXISTS "/etc/debian_version")
+-    set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
+-      "Install .so files without execute permission.")
+-  else()
+-    set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
+-      "Install .so files without execute permission.")
+-  endif()
++  set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
++    "Install .so files without execute permission.")
+ endif()
+ 
+ # Match multiarch library directory names.
+ set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
+ 
+ include(Platform/UnixPaths)
+-
+-# Debian has lib64 paths only for compatibility so they should not be
+-# searched.
+-if(EXISTS "/etc/debian_version")
+-  set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
+-endif()
+diff -ru3 cmake-2.8.12.2/Modules/Platform/UnixPaths.cmake cmake-2.8.12.2-new/Modules/Platform/UnixPaths.cmake
+--- cmake-2.8.12.2/Modules/Platform/UnixPaths.cmake	2014-01-16 21:15:08.000000000 +0400
++++ cmake-2.8.12.2-new/Modules/Platform/UnixPaths.cmake	2016-04-14 00:09:10.106362636 +0300
+@@ -32,9 +32,6 @@
+ # List common installation prefixes.  These will be used for all
+ # search types.
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+-  # Standard
+-  /usr/local /usr /
+-
+   # CMake install location
+   "${_CMAKE_INSTALL_DIR}"
+ 
+@@ -44,44 +41,26 @@
+ 
+ # List common include file locations not under the common prefixes.
+ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+-  # Windows API on Cygwin
+-  /usr/include/w32api
+-
+-  # X11
+-  /usr/X11R6/include /usr/include/X11
+-
+-  # Other
+-  /usr/pkg/include
+-  /opt/csw/include /opt/include
+-  /usr/openwin/include
++  @libc_dev@/include
+   )
+ 
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+-  # Windows API on Cygwin
+-  /usr/lib/w32api
+-
+-  # X11
+-  /usr/X11R6/lib /usr/lib/X11
+-
+-  # Other
+-  /usr/pkg/lib
+-  /opt/csw/lib /opt/lib
+-  /usr/openwin/lib
++  @libc_lib@/lib
+   )
+ 
+ list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
+-  /usr/pkg/bin
++  @libc_bin@/bin
+   )
+ 
+ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+-  /lib /usr/lib /usr/lib32 /usr/lib64
++  @libc_lib@/lib
+   )
+ 
+ list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
+-  /usr/include
++  @libc_dev@/include
+   )
+ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
+-  /usr/include
++  @libc_dev@/include
+   )
+ 
+ # Enable use of lib64 search path variants by default.
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path.patch b/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path.patch
new file mode 100644
index 000000000000..6213138402b1
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/search-path.patch
@@ -0,0 +1,62 @@
+diff -ur cmake-3.9.1/Modules/Platform/UnixPaths.cmake cmake-3.9.1-mod/Modules/Platform/UnixPaths.cmake
+--- cmake-3.9.1/Modules/Platform/UnixPaths.cmake	2017-08-10 13:36:32.000000000 +0000
++++ cmake-3.9.1-mod/Modules/Platform/UnixPaths.cmake	2017-09-03 01:24:31.901473539 +0000
+@@ -22,9 +22,6 @@
+ # List common installation prefixes.  These will be used for all
+ # search types.
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+-  # Standard
+-  /usr/local /usr /
+-
+   # CMake install location
+   "${_CMAKE_INSTALL_DIR}"
+   )
+@@ -43,31 +40,26 @@
+ 
+ # Non "standard" but common install prefixes
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+-  /usr/X11R6
+-  /usr/pkg
+-  /opt
+   )
+ 
+ # List common include file locations not under the common prefixes.
+ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+-  # X11
+-  /usr/include/X11
++  @libc_dev@/include
+   )
+ 
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+-  # X11
+-  /usr/lib/X11
++  @libc_lib@/lib
+   )
+ 
+ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+-  /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
++  @libc_lib@/lib
+   )
+ 
+ list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
+-  /usr/include
++  @libc_dev@/include
+   )
+ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
+-  /usr/include
++  @libc_dev@/include
+   )
+ 
+ # Enable use of lib32 and lib64 search path variants by default.
+diff -ur cmake-3.9.1/Modules/Platform/WindowsPaths.cmake cmake-3.9.1-mod/Modules/Platform/WindowsPaths.cmake
+--- cmake-3.9.1/Modules/Platform/WindowsPaths.cmake	2017-08-10 13:36:32.000000000 +0000
++++ cmake-3.9.1-mod/Modules/Platform/WindowsPaths.cmake	2017-09-03 01:19:32.808355986 +0000
+@@ -66,7 +66,7 @@
+ 
+ if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
+   # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
+-  list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
++  # list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
+ endif()
+ 
+ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh
new file mode 100755
index 000000000000..f095103ee044
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -0,0 +1,129 @@
+addCMakeParams() {
+    addToSearchPath CMAKE_PREFIX_PATH $1
+}
+
+fixCmakeFiles() {
+    # Replace occurences of /usr and /opt by /var/empty.
+    echo "fixing cmake files..."
+    find "$1" \( -type f -name "*.cmake" -o -name "*.cmake.in" -o -name CMakeLists.txt \) -print |
+        while read fn; do
+            sed -e 's^/usr\([ /]\|$\)^/var/empty\1^g' -e 's^/opt\([ /]\|$\)^/var/empty\1^g' < "$fn" > "$fn.tmp"
+            mv "$fn.tmp" "$fn"
+        done
+}
+
+cmakeConfigurePhase() {
+    runHook preConfigure
+
+    export CTEST_OUTPUT_ON_FAILURE=1
+    if [ -n "${enableParallelChecking-1}" ]; then
+        export CTEST_PARALLEL_LEVEL=$NIX_BUILD_CORES
+    fi
+
+    if [ -z "$dontFixCmake" ]; then
+        fixCmakeFiles .
+    fi
+
+    if [ -z "$dontUseCmakeBuildDir" ]; then
+        mkdir -p build
+        cd build
+        cmakeDir=${cmakeDir:-..}
+    fi
+
+    if [ -z "$dontAddPrefix" ]; then
+        cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
+    fi
+
+    # We should set the proper `CMAKE_SYSTEM_NAME`.
+    # http://www.cmake.org/Wiki/CMake_Cross_Compiling
+    #
+    # Unfortunately cmake seems to expect absolute paths for ar, ranlib, and
+    # strip. Otherwise they are taken to be relative to the source root of the
+    # package being built.
+    cmakeFlags="-DCMAKE_CXX_COMPILER=$CXX $cmakeFlags"
+    cmakeFlags="-DCMAKE_C_COMPILER=$CC $cmakeFlags"
+    cmakeFlags="-DCMAKE_AR=$(command -v $AR) $cmakeFlags"
+    cmakeFlags="-DCMAKE_RANLIB=$(command -v $RANLIB) $cmakeFlags"
+    cmakeFlags="-DCMAKE_STRIP=$(command -v $STRIP) $cmakeFlags"
+
+    # on macOS we want to prefer Unix-style headers to Frameworks
+    # because we usually do not package the framework
+    cmakeFlags="-DCMAKE_FIND_FRAMEWORK=last $cmakeFlags"
+
+    # we never want to use the global macOS SDK
+    cmakeFlags="-DCMAKE_OSX_SYSROOT= $cmakeFlags"
+
+    # disable OSX deployment target
+    # we don't want our binaries to have a "minimum" OSX version
+    cmakeFlags="-DCMAKE_OSX_DEPLOYMENT_TARGET= $cmakeFlags"
+
+    # correctly detect our clang compiler
+    cmakeFlags="-DCMAKE_POLICY_DEFAULT_CMP0025=NEW $cmakeFlags"
+
+    # This installs shared libraries with a fully-specified install
+    # name. By default, cmake installs shared libraries with just the
+    # basename as the install name, which means that, on Darwin, they
+    # can only be found by an executable at runtime if the shared
+    # libraries are in a system path or in the same directory as the
+    # executable. This flag makes the shared library accessible from its
+    # nix/store directory.
+    cmakeFlags="-DCMAKE_INSTALL_NAME_DIR=${!outputLib}/lib $cmakeFlags"
+    cmakeFlags="-DCMAKE_INSTALL_LIBDIR=${!outputLib}/lib $cmakeFlags"
+    cmakeFlags="-DCMAKE_INSTALL_INCLUDEDIR=${!outputDev}/include $cmakeFlags"
+
+    # Avoid cmake resetting the rpath of binaries, on make install
+    # And build always Release, to ensure optimisation flags
+    cmakeFlags="-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release} -DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
+
+    if [ "$buildPhase" = ninjaBuildPhase ]; then
+        cmakeFlags="-GNinja $cmakeFlags"
+    fi
+
+    echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
+
+    cmake ${cmakeDir:-.} $cmakeFlags "${cmakeFlagsArray[@]}"
+
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "cmake: enabled parallel building"
+    fi
+
+    runHook postConfigure
+}
+
+if [ -z "$dontUseCmakeConfigure" -a -z "$configurePhase" ]; then
+    setOutputFlags=
+    configurePhase=cmakeConfigurePhase
+fi
+
+addEnvHooks "$targetOffset" addCMakeParams
+
+makeCmakeFindLibs(){
+  isystem_seen=
+  for flag in $NIX_CFLAGS_COMPILE $NIX_LDFLAGS; do
+    if test -n "$isystem_seen" && test -d "$flag"; then
+      isystem_seen=
+      export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag}"
+    else
+      isystem_seen=
+      case $flag in
+        -I*)
+          export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag:2}"
+          ;;
+        -L*)
+          export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH${CMAKE_LIBRARY_PATH:+:}${flag:2}"
+          ;;
+        -F*)
+          export CMAKE_FRAMEWORK_PATH="$CMAKE_FRAMEWORK_PATH${CMAKE_FRAMEWORK_PATH:+:}${flag:2}"
+          ;;
+        -isystem)
+          isystem_seen=1
+          ;;
+      esac
+    fi
+  done
+}
+
+# not using setupHook, because it could be a setupHook adding additional
+# include flags to NIX_CFLAGS_COMPILE
+postHooks+=(makeCmakeFindLibs)
diff --git a/nixpkgs/pkgs/development/tools/build-managers/colormake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/colormake/default.nix
new file mode 100644
index 000000000000..9f4cb366e239
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/colormake/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchgit, perl}:
+
+stdenv.mkDerivation rec {
+  name = "colormake-${version}";
+  version = "2.1.0";
+
+  buildInputs = [perl];
+
+  src = fetchgit {
+    url = https://github.com/pagekite/Colormake.git;
+    rev = "66544f40d";
+    sha256 = "8e714c5540305d169989d9387dbac47b8b9fb2cfb424af7bcd412bfe684dc6d7";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -fa colormake.pl colormake colormake-short clmake clmake-short $out/bin
+  '';
+
+  meta = {
+    description = "Simple wrapper around make to colorize the output";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/conan/default.nix b/nixpkgs/pkgs/development/tools/build-managers/conan/default.nix
new file mode 100644
index 000000000000..3725760c1d6c
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/conan/default.nix
@@ -0,0 +1,80 @@
+{ lib, python3, fetchpatch, git }:
+
+let newPython = python3.override {
+  packageOverrides = self: super: {
+    distro = super.distro.overridePythonAttrs (oldAttrs: rec {
+      version = "1.1.0";
+      src = oldAttrs.src.override {
+        inherit version;
+        sha256 = "1vn1db2akw98ybnpns92qi11v94hydwp130s8753k6ikby95883j";
+      };
+    });
+    node-semver = super.node-semver.overridePythonAttrs (oldAttrs: rec {
+      version = "0.2.0";
+      src = oldAttrs.src.override {
+        inherit version;
+        sha256 = "1080pdxrvnkr8i7b7bk0dfx6cwrkkzzfaranl7207q6rdybzqay3";
+      };
+    });
+    astroid = super.astroid.overridePythonAttrs (oldAttrs: rec {
+      version = "1.6.5";
+      src = oldAttrs.src.override {
+        inherit version;
+        sha256 = "fc9b582dba0366e63540982c3944a9230cbc6f303641c51483fa547dcc22393a";
+      };
+    });
+    pylint = super.pylint.overridePythonAttrs (oldAttrs: rec {
+      version = "1.8.4";
+      src = oldAttrs.src.override {
+        inherit version;
+        sha256 = "34738a82ab33cbd3bb6cd4cef823dbcabdd2b6b48a4e3a3054a2bbbf0c712be9";
+      };
+
+    });
+  };
+};
+
+in newPython.pkgs.buildPythonApplication rec {
+  version = "1.6.0";
+  pname = "conan";
+
+  src = newPython.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "386476d3af1fa390e4cd96e737876e7d1f1c0bca09519e51fd44c1bb45990caa";
+  };
+
+  # Bump PyYAML to 3.13
+  patches = fetchpatch {
+    url = https://github.com/conan-io/conan/commit/9d3d7a5c6e89b3aa321735557e5ad3397bb80568.patch;
+    sha256 = "1qdy6zj3ypl1bp9872mzaqg1gwigqldxb1glvrkq3p4za62p546k";
+  };
+
+  checkInputs = [
+    git
+  ] ++ (with newPython.pkgs; [
+    nose
+    parameterized
+    mock
+    webtest
+    codecov
+  ]);
+
+  propagatedBuildInputs = with newPython.pkgs; [
+    requests fasteners pyyaml pyjwt colorama patch
+    bottle pluginbase six distro pylint node-semver
+    future pygments mccabe deprecation
+  ];
+
+  checkPhase = ''
+    export HOME="$TMP/conan-home"
+    mkdir -p "$HOME"
+    nosetests conans.test
+  '';
+
+  meta = with lib; {
+    homepage = https://conan.io;
+    description = "Decentralized and portable C/C++ package manager";
+    license = licenses.mit;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/doit/default.nix b/nixpkgs/pkgs/development/tools/build-managers/doit/default.nix
new file mode 100644
index 000000000000..c6ed406840d2
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/doit/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, python3Packages }:
+
+let
+
+  name = "doit";
+  version = "0.31.1";
+
+in python3Packages.buildPythonApplication {
+  name = "${name}-${version}";
+
+  src = fetchurl {
+    url = "mirror://pypi/d/${name}/${name}-${version}.tar.gz";
+    sha256 = "1spm8vfjh4kvalaj0i2ggbdln1yy5k68d8mfwfnpqlzxxx4ikl5s";
+  };
+
+  buildInputs = with python3Packages; [ mock pytest ];
+
+  propagatedBuildInputs = with python3Packages; [ cloudpickle pyinotify ];
+
+  # Tests fail due to mysterious gdbm.open() resource temporarily
+  # unavailable errors.
+  doCheck = false;
+  checkPhase = "py.test";
+
+  meta = with stdenv.lib; {
+    homepage = http://pydoit.org/;
+    description = "A task management & automation tool";
+    license = licenses.mit;
+    longDescription = ''
+      doit is a modern open-source build-tool written in python
+      designed to be simple to use and flexible to deal with complex
+      work-flows. It is specially suitable for building and managing
+      custom work-flows where there is no out-of-the-box solution
+      available.
+    '';
+    maintainers = with maintainers; [ pSub ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile b/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile
new file mode 100644
index 000000000000..ddb13a65c165
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile
@@ -0,0 +1,2 @@
+source 'https://rubygems.org'
+gem 'drake'
diff --git a/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile.lock b/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile.lock
new file mode 100644
index 000000000000..cf8900a30eed
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/drake/Gemfile.lock
@@ -0,0 +1,15 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    comp_tree (1.1.3)
+    drake (0.9.2.0.3.1)
+      comp_tree (>= 1.1.3)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  drake
+
+BUNDLED WITH
+   1.13.7
diff --git a/nixpkgs/pkgs/development/tools/build-managers/drake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/drake/default.nix
new file mode 100644
index 000000000000..15a88b1fc312
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/drake/default.nix
@@ -0,0 +1,18 @@
+{ lib, bundlerEnv, ruby }:
+
+bundlerEnv {
+  name = "drake-0.9.2.0.3.1";
+
+  inherit ruby;
+  gemfile = ./Gemfile;
+  lockfile = ./Gemfile.lock;
+  gemset = ./gemset.nix;
+  
+  meta = with lib; {
+    description = "A branch of Rake supporting automatic parallelizing of tasks";
+    homepage = http://quix.github.io/rake/;
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ romildo ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/drake/gemset.nix b/nixpkgs/pkgs/development/tools/build-managers/drake/gemset.nix
new file mode 100644
index 000000000000..fd5a6f06a2a8
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/drake/gemset.nix
@@ -0,0 +1,18 @@
+{
+  comp_tree = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0dj9lkfxcczn67l1j12dcxswrfxxd1zgxa344zk6vqs2gwwhy9m9";
+      type = "gem";
+    };
+    version = "1.1.3";
+  };
+  drake = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "09gkmdshwdmdnkdxi03dv4rk1dip0wdv6dx14wscrmi0jyk86yag";
+      type = "gem";
+    };
+    version = "0.9.2.0.3.1";
+  };
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/development/tools/build-managers/dub/default.nix b/nixpkgs/pkgs/development/tools/build-managers/dub/default.nix
new file mode 100644
index 000000000000..11461fc69522
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/dub/default.nix
@@ -0,0 +1,109 @@
+{ stdenv, fetchFromGitHub, curl, dmd, libevent, rsync }:
+
+let
+
+  dubBuild = stdenv.mkDerivation rec {
+    name = "dubBuild-${version}";
+    version = "1.10.0";
+
+    enableParallelBuilding = true;
+
+    src = fetchFromGitHub {
+      owner = "dlang";
+      repo = "dub";
+      rev = "v${version}";
+      sha256 = "02xxpfcjs427jqbwz0vh5vl3bh62ys65zmi9gpa3svzqffyx13n4";
+    };
+
+    postUnpack = ''
+        patchShebangs .
+    '';
+
+    # Can be removed with https://github.com/dlang/dub/pull/1368
+    dubvar = "\\$DUB";
+    postPatch = ''
+        substituteInPlace test/fetchzip.sh \
+            --replace "dub remove" "\"${dubvar}\" remove"
+    '';
+
+    nativeBuildInputs = [ dmd libevent rsync ];
+    buildInputs = [ curl ];
+
+    buildPhase = ''
+      export DMD=${dmd.out}/bin/dmd
+      ./build.sh
+    '';
+
+    installPhase = ''
+      mkdir $out
+      mkdir $out/bin
+      cp bin/dub $out/bin
+    '';
+
+    meta = with stdenv.lib; {
+      description = "Package and build manager for D applications and libraries";
+      homepage = http://code.dlang.org/;
+      license = licenses.mit;
+      maintainers = with maintainers; [ ThomasMader ];
+      platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
+    };
+  };
+
+  # Need to test in a fixed-output derivation, otherwise the
+  # network tests would fail if sandbox mode is enabled.
+  # Disable tests on Darwin for now because they don't work
+  # reliably there.
+  dubUnittests = if !stdenv.hostPlatform.isDarwin then
+    stdenv.mkDerivation rec {
+      name = "dubUnittests-${version}";
+      version = dubBuild.version;
+
+      enableParallelBuilding = dubBuild.enableParallelBuilding;
+      preferLocalBuild = true;
+      inputString = dubBuild.outPath;
+      outputHashAlgo = "sha256";
+      outputHash = builtins.hashString "sha256" inputString;
+
+      src = dubBuild.src;
+      
+      postUnpack = dubBuild.postUnpack;
+      postPatch = dubBuild.postPatch;
+
+      nativeBuildInputs = dubBuild.nativeBuildInputs;
+      buildInputs = dubBuild.buildInputs;
+
+      buildPhase = ''
+        # Can't use dub from dubBuild directly because one unittest 
+        # (issue895-local-configuration) needs to generate a config 
+        # file under ../etc relative to the dub location.
+        cp ${dubBuild}/bin/dub bin/
+        export DUB=$NIX_BUILD_TOP/source/bin/dub
+        export PATH=$PATH:$NIX_BUILD_TOP/source/bin/
+        export DC=${dmd.out}/bin/dmd
+        export HOME=$TMP
+        ./test/run-unittest.sh
+      '';
+
+      installPhase = ''
+          echo -n $inputString > $out
+      '';
+    }
+  else
+    "";
+
+in
+
+stdenv.mkDerivation rec {
+  inherit dubUnittests;
+  name = "dub-${dubBuild.version}";
+  phases = "installPhase";
+  buildInputs = dubBuild.buildInputs;
+
+  installPhase = ''
+    mkdir $out
+    cp -r --symbolic-link ${dubBuild}/* $out/
+  '';
+
+  meta = dubBuild.meta;
+}
+
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gn/default.nix b/nixpkgs/pkgs/development/tools/build-managers/gn/default.nix
new file mode 100644
index 000000000000..d5559768d6fc
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gn/default.nix
@@ -0,0 +1,62 @@
+{ stdenv, lib, fetchgit, fetchzip, fetchpatch, darwin, writeText
+, git, ninja, python }:
+
+let
+  rev = "96ff462cddf35f98e25fd5d098fc27bc81eab94a";
+  sha256 = "1ny23sprl7ygb2lpdnqxv60m8kaf4h2dmpqjp61l5vc2s7f32g97";
+
+  shortRev = builtins.substring 0 7 rev;
+  lastCommitPosition = writeText "last_commit_position.h" ''
+    #ifndef OUT_LAST_COMMIT_POSITION_H_
+    #define OUT_LAST_COMMIT_POSITION_H_
+
+    #define LAST_COMMIT_POSITION "(${shortRev})"
+
+    #endif  // OUT_LAST_COMMIT_POSITION_H_
+  '';
+
+in
+stdenv.mkDerivation rec {
+  name = "gn-${version}";
+  version = "20181031";
+
+  src = fetchgit {
+    url = "https://gn.googlesource.com/gn";
+    inherit rev sha256;
+  };
+
+  postPatch = ''
+    # FIXME Needed with old Apple SDKs
+    substituteInPlace base/mac/foundation_util.mm \
+      --replace "NSArray<NSString*>*" "NSArray*"
+  '';
+
+  nativeBuildInputs = [ ninja python git ];
+  buildInputs = lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
+    libobjc
+    cctools
+
+    # frameworks
+    ApplicationServices
+    Foundation
+    AppKit
+  ]);
+
+  buildPhase = ''
+    python build/gen.py --no-sysroot --no-last-commit-position
+    ln -s ${lastCommitPosition} out/last_commit_position.h
+    ninja -j $NIX_BUILD_CORES -C out gn
+  '';
+
+  installPhase = ''
+    install -vD out/gn "$out/bin/gn"
+  '';
+
+  meta = with lib; {
+    description = "A meta-build system that generates NinjaBuild files";
+    homepage = https://gn.googlesource.com/gn;
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ stesie matthewbauer ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/default.nix b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/default.nix
new file mode 100644
index 000000000000..47f800c67be5
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/default.nix
@@ -0,0 +1,62 @@
+{ stdenv, fetchurl, guileSupport ? false, pkgconfig ? null , guile ? null }:
+
+assert guileSupport -> ( pkgconfig != null && guile != null );
+
+let
+  version = "4.2.1";
+in
+stdenv.mkDerivation {
+  name = "gnumake-${version}";
+
+  src = fetchurl {
+    url = "mirror://gnu/make/make-${version}.tar.bz2";
+    sha256 = "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn";
+  };
+
+  patchFlags = "-p0";
+  patches = [
+    # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
+    # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
+    # included Makefiles, don't look in /usr/include and friends.
+    ./impure-dirs.patch
+    ./pselect.patch
+    # Fix support for glibc 2.27's glob, inspired by http://www.linuxfromscratch.org/lfs/view/8.2/chapter05/make.html
+    ./glibc-2.27-glob.patch
+  ];
+
+  nativeBuildInputs = stdenv.lib.optionals guileSupport [ pkgconfig ];
+  buildInputs = stdenv.lib.optionals guileSupport [ guile ];
+
+  configureFlags = stdenv.lib.optional guileSupport "--with-guile"
+
+    # Make uses this test to decide whether it should keep track of
+    # subseconds. Apple made this possible with APFS and macOS 10.13.
+    # However, we still support macOS 10.11 and 10.12. Binaries built
+    # in Nixpkgs will be unable to use futimens to set mtime less than
+    # a second. So, tell Make to ignore nanoseconds in mtime here by
+    # overriding the autoconf test for the struct.
+    # See https://github.com/NixOS/nixpkgs/issues/51221 for discussion.
+    ++ stdenv.lib.optional stdenv.isDarwin "ac_cv_struct_st_mtim_nsec=no";
+
+  outputs = [ "out" "man" "info" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://www.gnu.org/software/make/;
+    description = "A tool to control the generation of non-source files from sources";
+    license = licenses.gpl3Plus;
+
+    longDescription = ''
+      Make is a tool which controls the generation of executables and
+      other non-source files of a program from the program's source files.
+
+      Make gets its knowledge of how to build your program from a file
+      called the makefile, which lists each of the non-source files and
+      how to compute it from other files. When you write a program, you
+      should write a makefile for it, so that it is possible to use Make
+      to build and install the program.
+    '';
+
+    platforms = platforms.all;
+    maintainers = [ maintainers.vrthra ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch
new file mode 100644
index 000000000000..186212d0d298
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch
@@ -0,0 +1,32 @@
+diff -Naur glob/glob.c glob/glob.c
+--- glob/glob.c	2013-10-20 13:14:38.000000000 -0400
++++ glob/glob.c	2018-03-16 14:32:38.483496170 -0400
+@@ -208,28 +208,9 @@
+ #endif /* __GNU_LIBRARY__ || __DJGPP__ */
+ 
+ 
+-#if !defined __alloca && !defined __GNU_LIBRARY__
+-
+-# ifdef	__GNUC__
+-#  undef alloca
+-#  define alloca(n)	__builtin_alloca (n)
+-# else	/* Not GCC.  */
+-#  ifdef HAVE_ALLOCA_H
+ #   include <alloca.h>
+-#  else	/* Not HAVE_ALLOCA_H.  */
+-#   ifndef _AIX
+-#    ifdef WINDOWS32
+-#     include <malloc.h>
+-#    else
+-extern char *alloca ();
+-#    endif /* WINDOWS32 */
+-#   endif /* Not _AIX.  */
+-#  endif /* sparc or HAVE_ALLOCA_H.  */
+-# endif	/* GCC.  */
+-
+ # define __alloca	alloca
+ 
+-#endif
+ 
+ #ifndef __GNU_LIBRARY__
+ # define __stat stat
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs.patch b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs.patch
new file mode 100644
index 000000000000..f6646f1d0126
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs.patch
@@ -0,0 +1,34 @@
+diff -rc read.c read.c
+*** read.c	2006-03-17 15:24:20.000000000 +0100
+--- read.c	2007-05-24 17:16:31.000000000 +0200
+***************
+*** 99,107 ****
+--- 99,109 ----
+  #endif
+      INCLUDEDIR,
+  #ifndef _AMIGA
++ #if 0    
+      "/usr/gnu/include",
+      "/usr/local/include",
+      "/usr/include",
++ #endif    
+  #endif
+      0
+    };
+diff -rc reremake.c
+*** remake.c	2006-03-20 03:36:37.000000000 +0100
+--- remake.c	2007-05-24 17:06:54.000000000 +0200
+***************
+*** 1452,1460 ****
+--- 1452,1462 ----
+    static char *dirs[] =
+      {
+  #ifndef _AMIGA
++ #if 0
+        "/lib",
+        "/usr/lib",
+  #endif
++ #endif
+  #if defined(WINDOWS32) && !defined(LIBDIR)
+  /*
+   * This is completely up to the user at product install time. Just define
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/pselect.patch b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/pselect.patch
new file mode 100644
index 000000000000..5a03acb2f7ca
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.2/pselect.patch
@@ -0,0 +1,170 @@
+From b552b05251980f693c729e251f93f5225b400714 Mon Sep 17 00:00:00 2001
+From: Paul Smith <psmith@gnu.org>
+Date: Sat, 3 Jun 2017 16:20:51 -0400
+Subject: [SV 51159] Use a non-blocking read with pselect to avoid hangs.
+
+* posixos.c (set_blocking): Set blocking on a file descriptor.
+(jobserver_setup): Set non-blocking on the jobserver read side.
+(jobserver_parse_auth): Ditto.
+(jobserver_acquire_all): Set blocking to avoid a busy-wait loop.
+(jobserver_acquire): If the non-blocking read() returns without
+taking a token then try again.
+---
+ posixos.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 71 insertions(+), 26 deletions(-)
+
+diff --git posixos.c posixos.c
+index e642d7f..dbafa51 100644
+--- posixos.c
++++ posixos.c
+@@ -62,6 +62,24 @@ make_job_rfd (void)
+ #endif
+ }
+ 
++static void
++set_blocking (int fd, int blocking)
++{
++  // If we're not using pselect() don't change the blocking
++#ifdef HAVE_PSELECT
++  int flags;
++  EINTRLOOP (flags, fcntl (fd, F_GETFL));
++  if (flags >= 0)
++    {
++      int r;
++      flags = blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK);
++      EINTRLOOP (r, fcntl (fd, F_SETFL, flags));
++      if (r < 0)
++        pfatal_with_name ("fcntl(O_NONBLOCK)");
++    }
++#endif
++}
++
+ unsigned int
+ jobserver_setup (int slots)
+ {
+@@ -86,6 +104,9 @@ jobserver_setup (int slots)
+         pfatal_with_name (_("init jobserver pipe"));
+     }
+ 
++  /* When using pselect() we want the read to be non-blocking.  */
++  set_blocking (job_fds[0], 0);
++
+   return 1;
+ }
+ 
+@@ -121,6 +142,9 @@ jobserver_parse_auth (const char *auth)
+       return 0;
+     }
+ 
++  /* When using pselect() we want the read to be non-blocking.  */
++  set_blocking (job_fds[0], 0);
++
+   return 1;
+ }
+ 
+@@ -169,7 +193,10 @@ jobserver_acquire_all (void)
+ {
+   unsigned int tokens = 0;
+ 
+-  /* Close the write side, so the read() won't hang.  */
++  /* Use blocking reads to wait for all outstanding jobs.  */
++  set_blocking (job_fds[0], 1);
++
++  /* Close the write side, so the read() won't hang forever.  */
+   close (job_fds[1]);
+   job_fds[1] = -1;
+ 
+@@ -236,18 +263,12 @@ jobserver_pre_acquire (void)
+ unsigned int
+ jobserver_acquire (int timeout)
+ {
+-  sigset_t empty;
+-  fd_set readfds;
+   struct timespec spec;
+   struct timespec *specp = NULL;
+-  int r;
+-  char intake;
++  sigset_t empty;
+ 
+   sigemptyset (&empty);
+ 
+-  FD_ZERO (&readfds);
+-  FD_SET (job_fds[0], &readfds);
+-
+   if (timeout)
+     {
+       /* Alarm after one second (is this too granular?)  */
+@@ -256,28 +277,52 @@ jobserver_acquire (int timeout)
+       specp = &spec;
+     }
+ 
+-  r = pselect (job_fds[0]+1, &readfds, NULL, NULL, specp, &empty);
+-
+-  if (r == -1)
++  while (1)
+     {
+-      /* Better be SIGCHLD.  */
+-      if (errno != EINTR)
+-        pfatal_with_name (_("pselect jobs pipe"));
+-      return 0;
+-    }
++      fd_set readfds;
++      int r;
++      char intake;
+ 
+-  if (r == 0)
+-    /* Timeout.  */
+-    return 0;
++      FD_ZERO (&readfds);
++      FD_SET (job_fds[0], &readfds);
+ 
+-  /* The read FD is ready: read it!  */
+-  EINTRLOOP (r, read (job_fds[0], &intake, 1));
+-  if (r < 0)
+-    pfatal_with_name (_("read jobs pipe"));
++      r = pselect (job_fds[0]+1, &readfds, NULL, NULL, specp, &empty);
++      if (r < 0)
++        switch (errno)
++          {
++          case EINTR:
++            /* SIGCHLD will show up as an EINTR.  */
++            return 0;
++
++          case EBADF:
++            /* Someone closed the jobs pipe.
++               That shouldn't happen but if it does we're done.  */
++              O (fatal, NILF, _("job server shut down"));
+ 
+-  /* What does it mean if read() returns 0?  It shouldn't happen because only
+-     the master make can reap all the tokens and close the write side...??  */
+-  return r > 0;
++          default:
++            pfatal_with_name (_("pselect jobs pipe"));
++          }
++
++      if (r == 0)
++        /* Timeout.  */
++        return 0;
++
++      /* The read FD is ready: read it!  This is non-blocking.  */
++      EINTRLOOP (r, read (job_fds[0], &intake, 1));
++
++      if (r < 0)
++        {
++          /* Someone sniped our token!  Try again.  */
++          if (errno == EAGAIN)
++            continue;
++
++          pfatal_with_name (_("read jobs pipe"));
++        }
++
++      /* read() should never return 0: only the master make can reap all the
++         tokens and close the write side...??  */
++      return r > 0;
++    }
+ }
+ 
+ #else
+-- 
+cgit v1.0-41-gc330
+
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gradle/default.nix b/nixpkgs/pkgs/development/tools/build-managers/gradle/default.nix
new file mode 100644
index 000000000000..afe93ddf383e
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gradle/default.nix
@@ -0,0 +1,103 @@
+{ stdenv, fetchurl, unzip, jdk, makeWrapper }:
+
+rec {
+  gradleGen = {name, src, nativeVersion} : stdenv.mkDerivation rec {
+    inherit name src nativeVersion;
+
+    dontBuild = true;
+
+    installPhase = ''
+      mkdir -pv $out/lib/gradle/
+      cp -rv lib/ $out/lib/gradle/
+
+      gradle_launcher_jar=$(echo $out/lib/gradle/lib/gradle-launcher-*.jar)
+      test -f $gradle_launcher_jar
+      makeWrapper ${jdk}/bin/java $out/bin/gradle \
+        --set JAVA_HOME ${jdk} \
+        --add-flags "-classpath $gradle_launcher_jar org.gradle.launcher.GradleMain"
+    '';
+
+    fixupPhase = if (!stdenv.isLinux) then ":" else
+      let arch = if stdenv.is64bit then "amd64" else "i386"; in ''
+        mkdir patching
+        pushd patching
+        jar xf $out/lib/gradle/lib/native-platform-linux-${arch}-${nativeVersion}.jar
+        patchelf --set-rpath "${stdenv.cc.cc.lib}/lib:${stdenv.cc.cc.lib}/lib64" net/rubygrapefruit/platform/linux-${arch}/libnative-platform.so
+        jar cf native-platform-linux-${arch}-${nativeVersion}.jar .
+        mv native-platform-linux-${arch}-${nativeVersion}.jar $out/lib/gradle/lib/
+        popd
+
+        # The scanner doesn't pick up the runtime dependency in the jar.
+        # Manually add a reference where it will be found.
+        mkdir $out/nix-support
+        echo ${stdenv.cc.cc} > $out/nix-support/manual-runtime-dependencies
+      '';
+
+    buildInputs = [ unzip jdk makeWrapper ];
+
+    meta = {
+      description = "Enterprise-grade build system";
+      longDescription = ''
+        Gradle is a build system which offers you ease, power and freedom.
+        You can choose the balance for yourself. It has powerful multi-project
+        build support. It has a layer on top of Ivy that provides a
+        build-by-convention integration for Ivy. It gives you always the choice
+        between the flexibility of Ant and the convenience of a
+        build-by-convention behavior.
+      '';
+      homepage = http://www.gradle.org/;
+      license = stdenv.lib.licenses.asl20;
+      platforms = stdenv.lib.platforms.unix;
+    };
+  };
+
+  gradle_latest = gradleGen rec {
+    name = "gradle-5.0";
+    nativeVersion = "0.14";
+
+    src = fetchurl {
+      url = "http://services.gradle.org/distributions/${name}-bin.zip";
+      sha256 = "19krxq9pid9dg6bhdbhhg7ykm5kcx7lv7cr58rj67g0h6jgsqmv1";
+    };
+  };
+
+  gradle_4_10 = gradleGen rec {
+    name = "gradle-4.10.2";
+    nativeVersion = "0.14";
+
+    src = fetchurl {
+      url = "http://services.gradle.org/distributions/${name}-bin.zip";
+      sha256 = "0a9s2iisivgaapsz4vq1l8fa2w0wnlq0cj67yv5a0rybnahnv75l";
+    };
+  };
+
+  gradle_3_5 = gradleGen rec {
+    name = "gradle-3.5";
+    nativeVersion = "0.14";
+
+    src = fetchurl {
+      url = "http://services.gradle.org/distributions/${name}-bin.zip";
+      sha256 = "046i268zkg89ps7c1sq8yx9lbn9kighh4gcskxmzf3qriiwm0x0b";
+    };
+  };
+
+  gradle_2_14 = gradleGen rec {
+    name = "gradle-2.14.1";
+    nativeVersion = "0.10";
+
+    src = fetchurl {
+      url = "http://services.gradle.org/distributions/${name}-bin.zip";
+      sha256 = "0fggjxpsnakdaviw7bn2jmsl06997phlqr1251bjmlgjf7d1xing";
+    };
+  };
+
+  gradle_2_5 = gradleGen rec {
+    name = "gradle-2.5";
+    nativeVersion = "0.10";
+
+    src = fetchurl {
+      url = "http://services.gradle.org/distributions/${name}-bin.zip";
+      sha256 = "0mc5lf6phkncx77r0papzmfvyiqm0y26x50ipvmzkcsbn463x59z";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/gup/default.nix b/nixpkgs/pkgs/development/tools/build-managers/gup/default.nix
new file mode 100644
index 000000000000..7fd801488311
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/gup/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub, nix-update-source, lib, python, which, pychecker ? null }:
+stdenv.mkDerivation rec {
+  version = "0.7.0";
+  src = fetchFromGitHub {
+    owner = "timbertson";
+    repo = "gup";
+    rev = "version-0.7.0";
+    sha256 = "1pwnmlq2pgkkln9sgz4wlb9dqlqw83bkf105qljnlvggc21zm3pv";
+  };
+  name = "gup-${version}";
+  buildInputs = lib.remove null [ python which pychecker ];
+  SKIP_PYCHECKER = pychecker == null;
+  buildPhase = "make python";
+  installPhase = ''
+    mkdir $out
+    cp -r python/bin $out/bin
+  '';
+  passthru.updateScript = ''
+    #!${stdenv.shell}
+    set -e
+    echo
+    cd ${toString ./.}
+    ${nix-update-source}/bin/nix-update-source \
+      --prompt version \
+      --replace-attr version \
+      --set owner timbertson \
+      --set repo gup \
+      --set type fetchFromGitHub \
+      --set rev 'version-{version}' \
+      --modify-nix default.nix
+  '';
+  meta = {
+    inherit (src.meta) homepage;
+    description = "A better make, inspired by djb's redo";
+    license = stdenv.lib.licenses.lgpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.timbertson ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/icmake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/icmake/default.nix
new file mode 100644
index 000000000000..c5ab3fafc5e6
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/icmake/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchFromGitLab, makeWrapper, gcc, ncurses }:
+
+stdenv.mkDerivation rec {
+  name = "icmake-${version}";
+  version = "9.02.08";
+
+  src = fetchFromGitLab {
+    sha256 = "1pr5lagmdls3clzwa2xwcfa3k5750rf7i0j3zld0xirb41zx07q2";
+    rev = version;
+    repo = "icmake";
+    owner = "fbb-git";
+  };
+
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */icmake)
+  '';
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ gcc ];
+
+  preConfigure = ''
+    patchShebangs ./
+    substituteInPlace INSTALL.im --replace "usr/" ""
+  '';
+
+  buildPhase = ''
+    ./icm_prepare $out
+    ./icm_bootstrap x
+  '';
+
+  installPhase = ''
+    ./icm_install all /
+
+    wrapProgram $out/bin/icmbuild \
+     --prefix PATH : ${ncurses}/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A program maintenance (make) utility using a C-like grammar";
+    homepage = https://fbb-git.gitlab.io/icmake/;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ pSub ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/jam/default.nix b/nixpkgs/pkgs/development/tools/build-managers/jam/default.nix
new file mode 100644
index 000000000000..7314643530e8
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/jam/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl, yacc }:
+
+stdenv.mkDerivation rec {
+  name = "jam-2.6";
+
+  src = fetchurl {
+    url = "https://swarm.workshop.perforce.com/projects/perforce_software-jam/download/main/${name}.tar";
+    sha256 = "0j4r7xcjz15ksnnpjw56qi99q4lpjmx097pkwwkl1hq3hqml1zhn";
+  };
+
+  nativeBuildInputs = [ yacc ];
+
+  preConfigure = ''
+    unset AR
+  '';
+
+  buildPhase = ''
+    make jam0
+    ./jam0 -j$NIX_BUILD_CORES -sBINDIR=$out/bin install
+  '';
+
+  installPhase = ''
+    mkdir -p $out/doc/jam
+    cp *.html $out/doc/jam
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://www.perforce.com/resources/documentation/jam;
+    license = licenses.free;
+    description = "Just Another Make";
+    maintainers = with maintainers; [ orivej ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/kati/default.nix b/nixpkgs/pkgs/development/tools/build-managers/kati/default.nix
new file mode 100644
index 000000000000..8a72847be772
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/kati/default.nix
@@ -0,0 +1,26 @@
+{ fetchgit, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "kati-unstable-${version}";
+  version = "2017-05-23";
+  rev = "2dde61e46ab789f18956ff3b7c257dd8eb97993f";
+
+  src = fetchgit {
+    inherit rev;
+    url = "https://github.com/google/kati.git";
+    sha256 = "1das1fvycra546lmh72cr5qpgblhbzqqy7gfywiijjgx160l75vq";
+  };
+
+  patches = [ ./version.patch ];
+
+  installPhase = ''
+    install -D ckati $out/bin/ckati
+  '';
+
+  meta = {
+    description = "An experimental GNU make clone";
+    homepage = https://github.com/google/kati;
+    platforms = stdenv.lib.platforms.all;
+    license = stdenv.lib.licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/kati/version.patch b/nixpkgs/pkgs/development/tools/build-managers/kati/version.patch
new file mode 100644
index 000000000000..1821ac6bbb73
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/kati/version.patch
@@ -0,0 +1,19 @@
+diff --git a/Makefile.ckati b/Makefile.ckati
+index e4067bb..15518f3 100644
+--- a/Makefile.ckati
++++ b/Makefile.ckati
+@@ -102,14 +102,8 @@ $(KATI_CXX_TEST_EXES): $(KATI_BIN_PATH)/%: $(KATI_INTERMEDIATES_PATH)/%.o
+ 	$(KATI_LD) $^ -o $@ $(KATI_LIBS)
+ 
+ # Rule to generate version.cc
+-KATI_GIT_DIR := $(shell git -C $(KATI_SRC_PATH) rev-parse --show-toplevel)
+-ifneq ($(KATI_GIT_DIR),)
+-KATI_VERSION_DEPS := $(KATI_GIT_DIR)/.git/HEAD $(KATI_GIT_DIR)/.git/index
+-KATI_VERSION := $(shell git -C $(KATI_GIT_DIR) rev-parse HEAD)
+-else
+ KATI_VERSION_DEPS :=
+ KATI_VERSION := unknown
+-endif
+ $(KATI_INTERMEDIATES_PATH)/version.cc: $(KATI_VERSION_DEPS)
+ 	@mkdir -p $(dir $@)
+ 	echo '// +build ignore' > $@
diff --git a/nixpkgs/pkgs/development/tools/build-managers/leiningen/default.nix b/nixpkgs/pkgs/development/tools/build-managers/leiningen/default.nix
new file mode 100644
index 000000000000..4faf524af117
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/leiningen/default.nix
@@ -0,0 +1,57 @@
+{ stdenv, fetchurl, makeWrapper
+, coreutils, jdk, rlwrap, gnupg1compat }:
+
+stdenv.mkDerivation rec {
+  pname = "leiningen";
+  version = "2.8.1";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "https://raw.github.com/technomancy/leiningen/${version}/bin/lein-pkg";
+    sha256 = "0wk4m7m66xxx7i3nis08mc8qna7acgcmpim562vdyyrpbxdhj24i";
+  };
+
+  jarsrc = fetchurl {
+    # NOTE: This is actually a .jar, Github has issues
+    url = "https://github.com/technomancy/leiningen/releases/download/${version}/${name}-standalone.zip";
+    sha256 = "0n3wkb0a9g25r1xq93lskay2lw210qymz2qakjnl5vr5zz3vnjgw";
+  };
+
+  JARNAME = "${name}-standalone.jar";
+
+  unpackPhase = "true";
+
+  buildInputs = [ makeWrapper ];
+  propagatedBuildInputs = [ jdk ];
+
+  # the jar is not in share/java, because it's a standalone jar and should
+  # never be picked up by set-java-classpath.sh
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share
+
+    cp -v $src $out/bin/lein
+    cp -v $jarsrc $out/share/$JARNAME
+  '';
+
+  fixupPhase = ''
+    chmod +x $out/bin/lein
+    patchShebangs $out/bin/lein
+
+    substituteInPlace $out/bin/lein \
+      --replace 'LEIN_JAR=/usr/share/java/leiningen-$LEIN_VERSION-standalone.jar' "LEIN_JAR=$out/share/$JARNAME"
+
+    wrapProgram $out/bin/lein \
+      --prefix PATH ":" "${stdenv.lib.makeBinPath [ rlwrap coreutils ]}" \
+      --set LEIN_GPG ${gnupg1compat}/bin/gpg \
+      --set JAVA_CMD ${jdk}/bin/java
+  '';
+
+  meta = {
+    homepage = https://leiningen.org/;
+    description = "Project automation for Clojure";
+    license = stdenv.lib.licenses.epl10;
+    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ the-kenny ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/mage/default.nix b/nixpkgs/pkgs/development/tools/build-managers/mage/default.nix
new file mode 100644
index 000000000000..bce8dedbf58a
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/mage/default.nix
@@ -0,0 +1,32 @@
+{ buildGoPackage, fetchFromGitHub, lib }:
+
+with lib;
+
+buildGoPackage rec {
+  name = "mage-${version}";
+  version = "1.7.1";
+
+  goPackagePath = "github.com/magefile/mage";
+  subPackages = [ "." ];
+
+  src = fetchFromGitHub {
+    owner = "magefile";
+    repo = "mage";
+    rev = "v${version}";
+    sha256 = "0n4k5dy338rxwzj654smxzlanmd0zws6mdzv0wc4byqjhr7mqhg2";
+  };
+
+  buildFlagsArray = [ 
+    "-ldflags="
+    "-X github.com/magefile/mage/mage.commitHash=v${version}"
+    "-X github.com/magefile/mage/mage.gitTag=v${version}"
+  ];
+
+  meta = {
+    description = "A Make/Rake-like Build Tool Using Go";
+    license = licenses.asl20;
+    maintainers = [ maintainers.swdunlop ];
+    homepage = https://magefile.org/;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch b/nixpkgs/pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch
new file mode 100644
index 000000000000..382c2f0c05b2
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch
@@ -0,0 +1,25 @@
+--- a/mesonbuild/coredata.py
++++ b/mesonbuild/coredata.py
+@@ -298,18 +298,13 @@
+         '''
+         if option.endswith('dir') and os.path.isabs(value) and \
+            option not in builtin_dir_noprefix_options:
+-            # Value must be a subdir of the prefix
+             # commonpath will always return a path in the native format, so we
+             # must use pathlib.PurePath to do the same conversion before
+             # comparing.
+-            if os.path.commonpath([value, prefix]) != str(PurePath(prefix)):
+-                m = 'The value of the {!r} option is {!r} which must be a ' \
+-                    'subdir of the prefix {!r}.\nNote that if you pass a ' \
+-                    'relative path, it is assumed to be a subdir of prefix.'
+-                raise MesonException(m.format(option, value, prefix))
+-            # Convert path to be relative to prefix
+-            skip = len(prefix) + 1
+-            value = value[skip:]
++            if os.path.commonpath([value, prefix]) == str(PurePath(prefix)):
++                # Convert path to be relative to prefix
++                skip = len(prefix) + 1
++                value = value[skip:]
+         return value
+ 
+     def init_builtins(self):
diff --git a/nixpkgs/pkgs/development/tools/build-managers/meson/default.nix b/nixpkgs/pkgs/development/tools/build-managers/meson/default.nix
new file mode 100644
index 000000000000..13f61fb16177
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/meson/default.nix
@@ -0,0 +1,85 @@
+{ lib, python3Packages, stdenv, writeTextDir, substituteAll, targetPackages }:
+
+python3Packages.buildPythonApplication rec {
+  version = "0.48.2";
+  pname = "meson";
+
+  src = python3Packages.fetchPypi {
+    inherit pname version;
+    sha256 = "1shfbr0mf8gmwpw5ivrmwp8282qw9mfhxmccd7fsgidp4x3nslby";
+  };
+
+  postFixup = ''
+    pushd $out/bin
+    # undo shell wrapper as meson tools are called with python
+    for i in *; do
+      mv ".$i-wrapped" "$i"
+    done
+    popd
+
+    # Do not propagate Python
+    rm $out/nix-support/propagated-build-inputs
+  '';
+
+  patches = [
+    # Upstream insists on not allowing bindir and other dir options
+    # outside of prefix for some reason:
+    # https://github.com/mesonbuild/meson/issues/2561
+    # We remove the check so multiple outputs can work sanely.
+    ./allow-dirs-outside-of-prefix.patch
+
+    # Unlike libtool, vanilla Meson does not pass any information
+    # about the path library will be installed to to g-ir-scanner,
+    # breaking the GIR when path other than ${!outputLib}/lib is used.
+    # We patch Meson to add a --fallback-library-path argument with
+    # library install_dir to g-ir-scanner.
+    ./gir-fallback-path.patch
+
+    # In common distributions, RPATH is only needed for internal libraries so
+    # meson removes everything else. With Nix, the locations of libraries
+    # are not as predictable, therefore we need to keep them in the RPATH.
+    # At the moment we are keeping the paths starting with /nix/store.
+    # https://github.com/NixOS/nixpkgs/issues/31222#issuecomment-365811634
+    (substituteAll {
+      src = ./fix-rpath.patch;
+      inherit (builtins) storeDir;
+    })
+  ];
+
+  setupHook = ./setup-hook.sh;
+
+  crossFile = writeTextDir "cross-file.conf" ''
+    [binaries]
+    c = '${targetPackages.stdenv.cc.targetPrefix}cc'
+    cpp = '${targetPackages.stdenv.cc.targetPrefix}c++'
+    ar = '${targetPackages.stdenv.cc.bintools.targetPrefix}ar'
+    strip = '${targetPackages.stdenv.cc.bintools.targetPrefix}strip'
+    pkgconfig = 'pkg-config'
+
+    [properties]
+    needs_exe_wrapper = true
+
+    [host_machine]
+    system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'
+    cpu_family = '${targetPackages.stdenv.targetPlatform.parsed.cpu.family}'
+    cpu = '${targetPackages.stdenv.targetPlatform.parsed.cpu.name}'
+    endian = ${if targetPackages.stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
+  '';
+
+  # 0.45 update enabled tests but they are failing
+  doCheck = false;
+  # checkInputs = [ ninja pkgconfig ];
+  # checkPhase = "python ./run_project_tests.py";
+
+  inherit (stdenv) cc;
+
+  isCross = stdenv.targetPlatform != stdenv.hostPlatform;
+
+  meta = with lib; {
+    homepage = http://mesonbuild.com;
+    description = "SCons-like build system that use python as a front-end language and Ninja as a building backend";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ mbe rasendubi ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/meson/fix-rpath.patch b/nixpkgs/pkgs/development/tools/build-managers/meson/fix-rpath.patch
new file mode 100644
index 000000000000..30ecb30ee932
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/meson/fix-rpath.patch
@@ -0,0 +1,52 @@
+--- a/mesonbuild/compilers/compilers.py
++++ b/mesonbuild/compilers/compilers.py
+@@ -1112,6 +1112,8 @@
+         for p in rpath_paths:
+             if p == from_dir:
+                 relative = '' # relpath errors out in this case
++            elif os.path.isabs(p):
++                relative = p # These can be outside of build dir.
+             else:
+                 relative = os.path.relpath(os.path.join(build_dir, p), os.path.join(build_dir, from_dir))
+             rel_rpaths.append(relative)
+@@ -1121,8 +1123,10 @@
+             if paths != '':
+                 paths += ':'
+             paths += build_rpath
+-        if len(paths) < len(install_rpath):
+-            padding = 'X' * (len(install_rpath) - len(paths))
++        store_paths = ':'.join(filter(lambda path: path.startswith('@storeDir@'), paths.split(':')))
++        extra_space_needed = len(install_rpath + (':' if install_rpath and store_paths else '') + store_paths) - len(paths)
++        if extra_space_needed > 0:
++            padding = 'X' * extra_space_needed
+             if not paths:
+                 paths = padding
+             else:
+--- a/mesonbuild/scripts/depfixer.py
++++ b/mesonbuild/scripts/depfixer.py
+@@ -303,6 +303,14 @@
+             return
+         self.bf.seek(rp_off)
+         old_rpath = self.read_str()
++
++        if new_rpath:
++            new_rpath += b':'
++        else:
++            new_rpath = b''
++
++        new_rpath += b':'.join(filter(lambda path: path.startswith(b'@storeDir@'), old_rpath.split(b':')))
++
+         if len(old_rpath) < len(new_rpath):
+             sys.exit("New rpath must not be longer than the old one.")
+         # The linker does read-only string deduplication. If there is a
+@@ -316,6 +324,10 @@
+         if not new_rpath:
+             self.remove_rpath_entry(entrynum)
+         else:
++            # clean old rpath to avoid stale references
++            # (see https://github.com/NixOS/nixpkgs/pull/46020)
++            self.bf.seek(rp_off)
++            self.bf.write(b'\0'*len(old_rpath))
+             self.bf.seek(rp_off)
+             self.bf.write(new_rpath)
+             self.bf.write(b'\0')
diff --git a/nixpkgs/pkgs/development/tools/build-managers/meson/gir-fallback-path.patch b/nixpkgs/pkgs/development/tools/build-managers/meson/gir-fallback-path.patch
new file mode 100644
index 000000000000..b7667ed493f2
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/meson/gir-fallback-path.patch
@@ -0,0 +1,16 @@
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -780,6 +780,13 @@
+         scan_command += self._scan_langs(state, [lc[0] for lc in langs_compilers])
+         scan_command += list(external_ldflags)
+ 
++        if len(set([girtarget.get_custom_install_dir()[0] for girtarget in girtargets])) > 1:
++            raise MesonException('generate_gir tries to build multiple libraries with different install_dir at once: {}'.format(','.join([str(girtarget) for girtarget in girtargets])))
++
++        fallback_libpath = girtargets[0].get_custom_install_dir()[0]
++        if fallback_libpath is not None and isinstance(fallback_libpath, str) and len(fallback_libpath) > 0 and fallback_libpath[0] == "/":
++            scan_command += ['--fallback-library-path=' + fallback_libpath]
++
+         scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs)
+ 
+         typelib_output = '%s-%s.typelib' % (ns, nsversion)
diff --git a/nixpkgs/pkgs/development/tools/build-managers/meson/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/meson/setup-hook.sh
new file mode 100644
index 000000000000..06375c1528e0
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/meson/setup-hook.sh
@@ -0,0 +1,41 @@
+mesonConfigurePhase() {
+    runHook preConfigure
+
+    if [ -z "$dontAddPrefix" ]; then
+        mesonFlags="--prefix=$prefix $mesonFlags"
+    fi
+
+    # Build release by default.
+    if [ -n "@isCross@" ]; then
+      crossMesonFlags="--cross-file=@crossFile@/cross-file.conf"
+    fi
+
+    # See multiple-outputs.sh and meson’s coredata.py
+    mesonFlags="\
+        --libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \
+        --bindir=${!outputBin}/bin --sbindir=${!outputBin}/sbin \
+        --includedir=${!outputInclude}/include \
+        --mandir=${!outputMan}/share/man --infodir=${!outputInfo}/share/info \
+        --localedir=${!outputLib}/share/locale \
+        -Dauto_features=disabled \
+        $mesonFlags"
+
+    mesonFlags="${crossMesonFlags+$crossMesonFlags }--buildtype=${mesonBuildType:-release} $mesonFlags"
+
+    echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}"
+
+    CC=@cc@/bin/cc CXX=@cc@/bin/c++ meson build $mesonFlags "${mesonFlagsArray[@]}"
+    cd build
+
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "meson: enabled parallel building"
+    fi
+
+    runHook postConfigure
+}
+
+if [ -z "$dontUseMesonConfigure" -a -z "$configurePhase" ]; then
+    setOutputFlags=
+    configurePhase=mesonConfigurePhase
+fi
diff --git a/nixpkgs/pkgs/development/tools/build-managers/mill/default.nix b/nixpkgs/pkgs/development/tools/build-managers/mill/default.nix
new file mode 100644
index 000000000000..b909b3953fa5
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/mill/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "mill-${version}";
+  version = "0.3.5";
+
+  src = fetchurl {
+    url = "https://github.com/lihaoyi/mill/releases/download/${version}/${version}";
+    sha256 = "19ka81f6vjr85gd8cadn0fv0i0qcdspx2skslfksklxdxs2gasf8";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  unpackPhase = "true";
+  dontConfigure = true;
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm555 "$src" "$out/bin/.mill-wrapped"
+    # can't use wrapProgram because it sets --argv0
+    makeWrapper "$out/bin/.mill-wrapped" "$out/bin/mill" --prefix PATH : ${stdenv.lib.makeBinPath [ jre ]}
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.lihaoyi.com/mill;
+    license = licenses.mit;
+    description = "A build tool for Scala, Java and more";
+    longDescription = ''
+      Mill is a build tool borrowing ideas from modern tools like Bazel, to let you build
+      your projects in a way that's simple, fast, and predictable. Mill has built in
+      support for the Scala programming language, and can serve as a replacement for
+      SBT, but can also be extended to support any other language or platform via
+      modules (written in Java or Scala) or through an external subprocesses.
+    '';
+    maintainers = with maintainers; [ scalavision ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/mk/builder.sh b/nixpkgs/pkgs/development/tools/build-managers/mk/builder.sh
new file mode 100644
index 000000000000..73678ae9f5cc
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/mk/builder.sh
@@ -0,0 +1,4 @@
+source $stdenv/setup
+installFlags="PREFIX=$out"
+preInstall="mkdir -p $out/man/man1 $out/bin"
+genericBuild
diff --git a/nixpkgs/pkgs/development/tools/build-managers/mk/default.nix b/nixpkgs/pkgs/development/tools/build-managers/mk/default.nix
new file mode 100644
index 000000000000..f510752d385a
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/mk/default.nix
@@ -0,0 +1,14 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "mk-2006-01-31";
+  src = fetchurl {
+    url = http://tarballs.nixos.org/mk-20060131.tar.gz;
+    sha256 = "0za8dp1211bdp4584xb59liqpww7w1ql0cmlv34p9y928nibcxsr";
+  };
+  builder = ./builder.sh;
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/ninja/default.nix b/nixpkgs/pkgs/development/tools/build-managers/ninja/default.nix
new file mode 100644
index 000000000000..bb08ae2f3af5
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/ninja/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, python, buildDocs ? true, asciidoc, docbook_xml_dtd_45, docbook_xsl, libxslt, re2c }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "ninja-${version}";
+  version = "1.8.2";
+
+  src = fetchFromGitHub {
+    owner = "ninja-build";
+    repo = "ninja";
+    rev = "v${version}";
+    sha256 = "16scq9hcq6c5ap6sy8j4qi75qps1zvrf3p79j1vbrvnqzp928i5f";
+  };
+
+  nativeBuildInputs = [ python ] ++ optionals buildDocs [ asciidoc docbook_xml_dtd_45 docbook_xsl libxslt.bin re2c ];
+
+  buildPhase = ''
+    python configure.py --bootstrap
+  '' + optionalString buildDocs ''
+    # "./ninja -vn manual" output copied here to support cross compilation.
+    asciidoc -b docbook -d book -o build/manual.xml doc/manual.asciidoc
+    xsltproc --nonet doc/docbook.xsl build/manual.xml > doc/manual.html
+  '';
+
+  installPhase = ''
+    install -Dm555 -t $out/bin ninja
+    install -Dm444 misc/bash-completion $out/share/bash-completion/completions/ninja
+    install -Dm444 misc/zsh-completion $out/share/zsh/site-functions/_ninja
+  '' + optionalString buildDocs ''
+    install -Dm444 -t $out/share/doc/ninja doc/manual.asciidoc doc/manual.html
+  '';
+
+  setupHook = ./setup-hook.sh;
+
+  meta = {
+    description = "Small build system with a focus on speed";
+    longDescription = ''
+      Ninja is a small build system with a focus on speed. It differs from
+      other build systems in two major respects: it is designed to have its
+      input files generated by a higher-level build system, and it is designed
+      to run builds as fast as possible.
+    '';
+    homepage = https://ninja-build.org/;
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice bjornfor orivej ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/ninja/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/ninja/setup-hook.sh
new file mode 100644
index 000000000000..e3c67bd139dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/ninja/setup-hook.sh
@@ -0,0 +1,78 @@
+ninjaBuildPhase() {
+    runHook preBuild
+
+    local buildCores=1
+
+    # Parallel building is enabled by default.
+    if [ "${enableParallelBuilding-1}" ]; then
+        buildCores="$NIX_BUILD_CORES"
+    fi
+
+    local flagsArray=(
+        -j$buildCores -l$NIX_BUILD_CORES
+        $ninjaFlags "${ninjaFlagsArray[@]}"
+    )
+
+    echoCmd 'build flags' "${flagsArray[@]}"
+    ninja "${flagsArray[@]}"
+
+    runHook postBuild
+}
+
+if [ -z "$dontUseNinjaBuild" -a -z "$buildPhase" ]; then
+    buildPhase=ninjaBuildPhase
+fi
+
+ninjaInstallPhase() {
+    runHook preInstall
+
+    # shellcheck disable=SC2086
+    local flagsArray=(
+        $ninjaFlags "${ninjaFlagsArray[@]}"
+        ${installTargets:-install}
+    )
+
+    echoCmd 'install flags' "${flagsArray[@]}"
+    ninja "${flagsArray[@]}"
+
+    runHook postInstall
+}
+
+if [ -z "$dontUseNinjaInstall" -a -z "$installPhase" ]; then
+    installPhase=ninjaInstallPhase
+fi
+
+ninjaCheckPhase() {
+    runHook preCheck
+
+    if [ -z "${checkTarget:-}" ]; then
+        if ninja -t query test >/dev/null 2>&1; then
+            checkTarget=test
+        fi
+    fi
+
+    if [ -z "${checkTarget:-}" ]; then
+        echo "no test target found in ninja, doing nothing"
+    else
+        local buildCores=1
+
+        if [ "${enableParallelChecking-1}" ]; then
+            buildCores="$NIX_BUILD_CORES"
+        fi
+
+        local flagsArray=(
+            -j$buildCores -l$NIX_BUILD_CORES
+            $ninjaFlags "${ninjaFlagsArray[@]}"
+            $checkTarget
+        )
+
+        echoCmd 'check flags' "${flagsArray[@]}"
+        ninja "${flagsArray[@]}"
+    fi
+
+    runHook postCheck
+}
+
+if [ -z "$dontUseNinjaCheck" -a -z "$checkPhase" ]; then
+    checkPhase=ninjaCheckPhase
+fi
diff --git a/nixpkgs/pkgs/development/tools/build-managers/pants/default.nix b/nixpkgs/pkgs/development/tools/build-managers/pants/default.nix
new file mode 100644
index 000000000000..02bf9c23cbac
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/pants/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, pythonPackages }:
+
+with stdenv.lib;
+with pythonPackages;
+
+let
+  version = "1.7.0";
+in buildPythonApplication rec {
+  inherit version;
+  pname = "pantsbuild.pants";
+  name  = "${pname}-${version}";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1d7ff1383287c8e72f2c9855cfef982d362274a64e2707a93c070f988ba80a37";
+  };
+
+  prePatch = ''
+    sed -E -i "s/'([[:alnum:].-]+)[=><][[:digit:]=><.,]*'/'\\1'/g" setup.py
+    substituteInPlace setup.py --replace "requests[security]<2.19,>=2.5.0" "requests[security]<2.20,>=2.5.0"
+  '';
+
+  # Unnecessary, and causes some really weird behavior around .class files, which
+  # this package bundles. See https://github.com/NixOS/nixpkgs/issues/22520.
+  dontStrip = true;
+
+  propagatedBuildInputs = [
+    twitter-common-collections setproctitle ansicolors packaging pathspec
+    scandir twitter-common-dirutil psutil requests pystache pex docutils
+    markdown pygments twitter-common-confluence fasteners pywatchman
+    futures cffi subprocess32 contextlib2 faulthandler pyopenssl wheel
+  ];
+
+  meta = {
+    description = "A build system for software projects in a variety of languages";
+    homepage    = "https://www.pantsbuild.org/";
+    license     = licenses.asl20;
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/qbs/default.nix b/nixpkgs/pkgs/development/tools/build-managers/qbs/default.nix
new file mode 100644
index 000000000000..3c5a485e36fc
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/qbs/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, qmake, qtbase, qtscript }:
+
+stdenv.mkDerivation rec {
+  name = "qbs-${version}";
+
+  version = "1.12.2";
+
+  src = fetchFromGitHub {
+    owner = "qbs";
+    repo = "qbs";
+    rev = "v${version}";
+    sha256 = "0spkkq7nmh27rbx61p23fzkxffx3qdhjqw95pqgsbc76xczd45sv";
+  };
+
+  nativeBuildInputs = [ qmake ];
+
+  qmakeFlags = [ "QBS_INSTALL_PREFIX=$(out)" "qbs.pro" ];
+
+  buildInputs = [ qtbase qtscript ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A tool that helps simplify the build process for developing projects across multiple platforms";
+    license = licenses.lgpl3;
+    maintainers = with maintainers; [ expipiplus1 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile b/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile
new file mode 100644
index 000000000000..bd1ff6faa65c
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile
@@ -0,0 +1,2 @@
+source 'https://rubygems.org'
+gem 'rake'
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile.lock b/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile.lock
new file mode 100644
index 000000000000..6f6bcc41f9b3
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rake/Gemfile.lock
@@ -0,0 +1,13 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    rake (12.3.1)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  rake
+
+BUNDLED WITH
+   1.17.1
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/rake/default.nix
new file mode 100644
index 000000000000..f23edfd5f63f
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rake/default.nix
@@ -0,0 +1,15 @@
+{ lib, bundlerEnv, ruby }:
+
+bundlerEnv {
+  name = "rake-${(import ./gemset.nix).rake.version}";
+
+  inherit ruby;
+  gemdir = ./.;
+
+  meta = with lib; {
+    description = "A software task management and build automation tool";
+    homepage = https://github.com/ruby/rake;
+    license  = with licenses; mit;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rake/gemset.nix b/nixpkgs/pkgs/development/tools/build-managers/rake/gemset.nix
new file mode 100644
index 000000000000..c1a3a511b22d
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rake/gemset.nix
@@ -0,0 +1,10 @@
+{
+  rake = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1idi53jay34ba9j68c3mfr9wwkg3cd9qh0fn9cg42hv72c6q8dyg";
+      type = "gem";
+    };
+    version = "12.3.1";
+  };
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rebar/default.nix b/nixpkgs/pkgs/development/tools/build-managers/rebar/default.nix
new file mode 100644
index 000000000000..98cd7e136d22
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rebar/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, erlang }:
+
+
+let
+  version = "2.5.1";
+in
+stdenv.mkDerivation {
+  name = "rebar-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/rebar/rebar/archive/${version}.tar.gz";
+    sha256 = "1y9b0smw0g5q197xf4iklzmcf8ad6w52p6mwzpf7b0ib1nd89jw6";
+  };
+
+  buildInputs = [ erlang ];
+
+  buildPhase = "escript bootstrap";
+  installPhase = ''
+    mkdir -p $out/bin
+    cp rebar $out/bin/rebar
+  '';
+
+  meta = {
+    homepage = https://github.com/rebar/rebar;
+    description = "Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
+
+    longDescription = ''
+      rebar is a self-contained Erlang script, so it's easy to
+      distribute or even embed directly in a project. Where possible,
+      rebar uses standard Erlang/OTP conventions for project
+      structures, thus minimizing the amount of build configuration
+      work. rebar also provides dependency management, enabling
+      application writers to easily re-use common libraries from a
+      variety of locations (git, hg, etc).
+      '';
+
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.the-kenny ];
+    license = stdenv.lib.licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rebar3/default.nix b/nixpkgs/pkgs/development/tools/build-managers/rebar3/default.nix
new file mode 100644
index 000000000000..e96852602fc7
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rebar3/default.nix
@@ -0,0 +1,127 @@
+{ stdenv, fetchurl,
+  fetchHex, erlang, hermeticRebar3 ? true,
+  tree, hexRegistrySnapshot }:
+
+let
+  version = "3.6.1";
+
+  bootstrapper = ./rebar3-nix-bootstrap;
+
+  erlware_commons = fetchHex {
+    pkg = "erlware_commons";
+    version = "1.2.0";
+    sha256 = "149kkn9gc9cjgvlmakygq475r63q2rry31s29ax0s425dh37sfl7";
+  };
+  ssl_verify_fun = fetchHex {
+    pkg = "ssl_verify_fun";
+    version = "1.1.3";
+    sha256 = "1zljxashfhqmiscmf298vhr880ppwbgi2rl3nbnyvsfn0mjhw4if";
+  };
+  certifi = fetchHex {
+    pkg = "certifi";
+    version = "2.0.0";
+    sha256 = "075v7cvny52jbhnskchd3fp68fxgp7qfvdls0haamcycxrn0dipx";
+  };
+  providers = fetchHex {
+    pkg = "providers";
+    version = "1.7.0";
+    sha256 = "19p4rbsdx9lm2ihgvlhxyld1q76kxpd7qwyqxxsgmhl5r8ln3rlb";
+  };
+  getopt = fetchHex {
+    pkg = "getopt";
+    version = "1.0.1";
+    sha256 = "174mb46c2qd1f4a7507fng4vvscjh1ds7rykfab5rdnfp61spqak";
+  };
+  bbmustache = fetchHex {
+    pkg = "bbmustache";
+    version = "1.5.0";
+    sha256 = "0xg3r4lxhqifrv32nm55b4zmkflacc1s964g15p6y6jfx6v4y1zd";
+  };
+  relx = fetchHex {
+    pkg = "relx";
+    version = "3.26.0";
+    sha256 = "1f810rb01kdidpa985s321ycg3y4hvqpzbk263n6i1bfnqykkvv9";
+  };
+  cf = fetchHex {
+    pkg = "cf";
+    version = "0.2.2";
+    sha256 = "08cvy7skn5d2k4manlx5k3anqgjdvajjhc5jwxbaszxw34q3na28";
+  };
+  cth_readable = fetchHex {
+    pkg = "cth_readable";
+    version = "1.4.2";
+    sha256 = "1pjid4f60pp81ds01rqa6ybksrnzqriw3aibilld1asn9iabxkav";
+  };
+  eunit_formatters = fetchHex {
+    pkg = "eunit_formatters";
+    version = "0.5.0";
+    sha256 = "1jb3hzb216r29x2h4pcjwfmx1k81431rgh5v0mp4x5146hhvmj6n";
+  };
+  rebar3_hex = fetchHex {
+    pkg = "rebar3_hex";
+    version = "4.0.0";
+    sha256 = "0k0ykx1lz62r03dpbi2zxsvrxgnr5hj67yky0hjrls09ynk4682v";
+  };
+
+in
+stdenv.mkDerivation {
+  name = "rebar3-${version}";
+  inherit version;
+
+  src = fetchurl {
+    url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
+    sha256 = "0cqhqymzh10pfyxqiy4hcg3d2myz3chx0y4m2ixmq8zk81acics0";
+  };
+
+  inherit bootstrapper;
+
+  patches = if hermeticRebar3 == true
+  then  [ ./hermetic-rebar3.patch ]
+  else [];
+
+  buildInputs = [ erlang tree  ];
+  propagatedBuildInputs = [ hexRegistrySnapshot ];
+
+  postPatch = ''
+    ${erlang}/bin/escript ${bootstrapper} registry-only
+    mkdir -p _build/default/lib/
+    mkdir -p _build/default/plugins
+    cp --no-preserve=mode -R ${erlware_commons} _build/default/lib/erlware_commons
+    cp --no-preserve=mode -R ${providers} _build/default/lib/providers
+    cp --no-preserve=mode -R ${getopt} _build/default/lib/getopt
+    cp --no-preserve=mode -R ${bbmustache} _build/default/lib/bbmustache
+    cp --no-preserve=mode -R ${certifi} _build/default/lib/certifi
+    cp --no-preserve=mode -R ${cf} _build/default/lib/cf
+    cp --no-preserve=mode -R ${cth_readable} _build/default/lib/cth_readable
+    cp --no-preserve=mode -R ${eunit_formatters} _build/default/lib/eunit_formatters
+    cp --no-preserve=mode -R ${relx} _build/default/lib/relx
+    cp --no-preserve=mode -R ${ssl_verify_fun} _build/default/lib/ssl_verify_fun
+    cp --no-preserve=mode -R ${rebar3_hex} _build/default/plugins/rebar3_hex
+  '';
+
+  buildPhase = ''
+    HOME=. escript bootstrap
+  '';
+  installPhase = ''
+    mkdir -p $out/bin
+    cp rebar3 $out/bin/rebar3
+  '';
+
+  meta = {
+    homepage = https://github.com/rebar/rebar3;
+    description = "rebar 3.0 is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
+
+    longDescription = ''
+      rebar is a self-contained Erlang script, so it's easy to distribute or
+      even embed directly in a project. Where possible, rebar uses standard
+      Erlang/OTP conventions for project structures, thus minimizing the amount
+      of build configuration work. rebar also provides dependency management,
+      enabling application writers to easily re-use common libraries from a
+      variety of locations (hex.pm, git, hg, and so on).
+      '';
+
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ gleber tazjin ];
+    license = stdenv.lib.licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rebar3/hermetic-rebar3.patch b/nixpkgs/pkgs/development/tools/build-managers/rebar3/hermetic-rebar3.patch
new file mode 100644
index 000000000000..59004561126c
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rebar3/hermetic-rebar3.patch
@@ -0,0 +1,103 @@
+diff --git a/bootstrap b/bootstrap
+index 5dedd713..864056c4 100755
+--- a/bootstrap
++++ b/bootstrap
+@@ -101,7 +101,7 @@ extract(Binary) ->
+ request(Url) ->
+     HttpOptions = [{relaxed, true} | get_proxy_auth()],
+ 
+-    case httpc:request(get, {Url, []},
++    case rebar_hermeticity:request(get, {Url, []},
+                        HttpOptions,
+                        [{body_format, binary}],
+                        rebar) of
+diff --git a/src/rebar_hermeticity.erl b/src/rebar_hermeticity.erl
+index e69de29b..8f6cc7d0 100644
+--- a/src/rebar_hermeticity.erl
++++ b/src/rebar_hermeticity.erl
+@@ -0,0 +1,42 @@
++%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
++%% ex: ts=4 sw=4 et
++%% -------------------------------------------------------------------
++%%
++%% rebar: Erlang Build Tools
++%%
++%% Copyright (c) 2016 Eric Merritt (eric@merritt.tech)
++%%
++%% Permission is hereby granted, free of charge, to any person obtaining a copy
++%% of this software and associated documentation files (the "Software"), to deal
++%% in the Software without restriction, including without limitation the rights
++%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++%% copies of the Software, and to permit persons to whom the Software is
++%% furnished to do so, subject to the following conditions:
++%%
++%% The above copyright notice and this permission notice shall be included in
++%% all copies or substantial portions of the Software.
++%%
++%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
++%% THE SOFTWARE.
++%% -------------------------------------------------------------------
++-module(rebar_hermeticity).
++
++-export([request/5]).
++
++-include("rebar.hrl").
++
++%% ====================================================================
++%% Public API
++%% ====================================================================
++
++request(Method, {Url, _Headers}, _HTTPOptions, _Options, _Profile) ->
++    ?ERROR("A request is being made that violates Nix hermicity "
++           "This request has been stopped. Details of the request "
++           "are as follows:", []),
++    ?ERROR("Request: ~p ~s", [Method, Url]),
++    erlang:halt(1).
+diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
+index 2cf167ee..6080aaca 100644
+--- a/src/rebar_pkg_resource.erl
++++ b/src/rebar_pkg_resource.erl
+@@ -127,7 +127,7 @@ make_vsn(_) ->
+ request(Url, ETag) ->
+     HttpOptions = [{ssl, ssl_opts(Url)},
+                    {relaxed, true} | rebar_utils:get_proxy_auth()],
+-    case httpc:request(get, {Url, [{"if-none-match", "\"" ++ ETag ++ "\""}
++    case rebar_hermeticity:request(get, {Url, [{"if-none-match", "\"" ++ ETag ++ "\""}
+                                    || ETag =/= false] ++
+                              [{"User-Agent", rebar_utils:user_agent()}]},
+                        HttpOptions, [{body_format, binary}], rebar) of
+diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
+index 17446311..4d44d794 100644
+--- a/src/rebar_prv_update.erl
++++ b/src/rebar_prv_update.erl
+@@ -38,6 +38,8 @@ init(State) ->
+     {ok, State1}.
+ 
+ -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
++do(State) -> {ok, State}.
++-ifdef(non_hermetic).
+ do(State) ->
+     try
+         case rebar_packages:registry_dir(State) of
+@@ -53,7 +55,7 @@ do(State) ->
+                     {ok, Url} ->
+                         HttpOptions = [{relaxed, true} | rebar_utils:get_proxy_auth()],
+                         ?DEBUG("Fetching registry from ~p", [Url]),
+-                        case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
++                        case rebar_hermeticity:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
+                                            HttpOptions, [{stream, TmpFile}, {sync, true}],
+                                            rebar) of
+                             {ok, saved_to_file} ->
+@@ -77,6 +79,7 @@ do(State) ->
+             ?DEBUG("Error creating package index: ~p ~p", [C, S]),
+             throw(?PRV_ERROR(package_index_write))
+     end.
++-endif.
+ 
+ -spec format_error(any()) -> iolist().
+ format_error({package_parse_cdn, Uri}) ->
diff --git a/nixpkgs/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap b/nixpkgs/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
new file mode 100755
index 000000000000..802f47af6adf
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
@@ -0,0 +1,300 @@
+#!/usr/bin/env escript
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%%! -smp enable
+%%% ---------------------------------------------------------------------------
+%%% @doc
+%%% The purpose of this command is to prepare a rebar3 project so that
+%%% rebar3 understands that the dependencies are all already
+%%% installed. If you want a hygienic build on nix then you must run
+%%% this command before running rebar3. I suggest that you add a
+%%% `Makefile` to your project and have the bootstrap command be a
+%%% dependency of the build commands. See the nix documentation for
+%%% more information.
+%%%
+%%% This command designed to have as few dependencies as possible so
+%%% that it can be a dependency of root level packages like rebar3. To
+%%% that end it does many things in a fairly simplistic way. That is
+%%% by design.
+%%%
+%%% ### Assumptions
+%%%
+%%% This command makes the following assumptions:
+%%%
+%%% * It is run in a nix-shell or nix-build environment
+%%% * that all dependencies have been added to the ERL_LIBS
+%%%   Environment Variable
+
+-record(data, {version
+              , registry_only = false
+              , debug_info = false
+              , compile_ports
+              , erl_libs
+              , plugins
+              , root
+              , name
+              , registry_snapshot}).
+
+-define(HEX_REGISTRY_PATH, ".cache/rebar3/hex/default/registry").
+
+main(Args) ->
+    {ok, ArgData} = parse_args(Args),
+    {ok, RequiredData} = gather_required_data_from_the_environment(ArgData),
+    do_the_bootstrap(RequiredData).
+
+%% @doc There are two modes 'registry_only' where the register is
+%% created from hex and everything else.
+-spec do_the_bootstrap(#data{}) -> ok.
+do_the_bootstrap(RequiredData = #data{registry_only = true}) ->
+    ok = bootstrap_registry(RequiredData);
+do_the_bootstrap(RequiredData) ->
+    ok = bootstrap_registry(RequiredData),
+    ok = bootstrap_configs(RequiredData),
+    ok = bootstrap_plugins(RequiredData),
+    ok = bootstrap_libs(RequiredData).
+
+%% @doc
+%% Argument parsing is super simple only because we want to keep the
+%% dependencies minimal. For now there can be two entries on the
+%% command line, "registry-only" and "debug-info"
+-spec parse_args([string()]) -> #data{}.
+parse_args(Args0) ->
+    PossibleArgs = sets:from_list(["registry-only", "debug-info"]),
+    Args1 = sets:from_list(Args0),
+    Result = sets:subtract(Args1, PossibleArgs),
+    case sets:to_list(Result) of
+        [] ->
+            {ok, #data{registry_only = sets:is_element("registry-only", Args1),
+                       debug_info = sets:is_element("debug-info", Args1)}};
+        UnknownArgs ->
+            io:format("Unexpected command line arguments passed in: ~p~n",
+                      [UnknownArgs]),
+            erlang:halt(120)
+    end.
+
+
+-spec bootstrap_configs(#data{}) -> ok.
+bootstrap_configs(RequiredData)->
+    io:format("Boostrapping app and rebar configurations~n"),
+    ok = if_single_app_project_update_app_src_version(RequiredData),
+    ok = if_compile_ports_add_pc_plugin(RequiredData),
+    ok = if_debug_info_add(RequiredData).
+
+-spec bootstrap_plugins(#data{}) -> ok.
+bootstrap_plugins(#data{plugins = Plugins}) ->
+    io:format("Bootstrapping rebar3 plugins~n"),
+    Target = "_build/default/plugins/",
+    Paths = string:tokens(Plugins, " "),
+    CopiableFiles =
+        lists:foldl(fun(Path, Acc) ->
+                            gather_dependency(Path) ++ Acc
+                    end, [], Paths),
+    lists:foreach(fun (Path) ->
+                          ok = link_app(Path, Target)
+                  end, CopiableFiles).
+
+-spec bootstrap_libs(#data{}) -> ok.
+bootstrap_libs(#data{erl_libs = ErlLibs}) ->
+    io:format("Bootstrapping dependent libraries~n"),
+    Target = "_build/default/lib/",
+    Paths = string:tokens(ErlLibs, ":"),
+    CopiableFiles =
+        lists:foldl(fun(Path, Acc) ->
+                            gather_directory_contents(Path) ++ Acc
+                    end, [], Paths),
+    lists:foreach(fun (Path) ->
+                          ok = link_app(Path, Target)
+                  end, CopiableFiles).
+
+-spec gather_dependency(string()) -> [{string(), string()}].
+gather_dependency(Path) ->
+    FullLibrary = filename:join(Path, "lib/erlang/lib/"),
+    case filelib:is_dir(FullLibrary) of
+        true ->
+            gather_directory_contents(FullLibrary);
+        false ->
+            [raw_hex(Path)]
+    end.
+
+-spec raw_hex(string()) -> {string(), string()}.
+raw_hex(Path) ->
+    [_, Name] = re:split(Path, "-hex-source-"),
+    {Path, erlang:binary_to_list(Name)}.
+
+-spec gather_directory_contents(string()) -> [{string(), string()}].
+gather_directory_contents(Path) ->
+    {ok, Names} = file:list_dir(Path),
+    lists:map(fun(AppName) ->
+                 {filename:join(Path, AppName), fixup_app_name(AppName)}
+              end, Names).
+
+%% @doc
+%% Makes a symlink from the directory pointed at by Path to a
+%% directory of the same name in Target. So if we had a Path of
+%% {`foo/bar/baz/bash`, `baz`} and a Target of `faz/foo/foos`, the symlink
+%% would be `faz/foo/foos/baz`.
+-spec link_app({string(), string()}, string()) -> ok.
+link_app({Path, TargetFile}, TargetDir) ->
+    Target = filename:join(TargetDir, TargetFile),
+    make_symlink(Path, Target).
+
+-spec make_symlink(string(), string()) -> ok.
+make_symlink(Path, TargetFile) ->
+    file:delete(TargetFile),
+    ok = filelib:ensure_dir(TargetFile),
+    io:format("Making symlink from ~s to ~s~n", [Path, TargetFile]),
+    ok = file:make_symlink(Path, TargetFile).
+
+%% @doc
+%% This takes an app name in the standard OTP <name>-<version> format
+%% and returns just the app name. Why? Because rebar doesn't
+%% respect OTP conventions in some cases.
+-spec fixup_app_name(string()) -> string().
+fixup_app_name(FileName) ->
+    case string:tokens(FileName, "-") of
+        [Name] -> Name;
+        [Name, _Version] -> Name;
+        [Name, _Version, _Tag] -> Name
+    end.
+
+-spec bootstrap_registry(#data{}) -> ok.
+bootstrap_registry(#data{registry_snapshot = RegistrySnapshot}) ->
+    io:format("Bootstrapping Hex Registry for Rebar~n"),
+    make_sure_registry_snapshot_exists(RegistrySnapshot),
+    filelib:ensure_dir(?HEX_REGISTRY_PATH),
+    ok = case filelib:is_file(?HEX_REGISTRY_PATH) of
+             true ->
+                 file:delete(?HEX_REGISTRY_PATH);
+             false ->
+                 ok
+         end,
+    ok = file:make_symlink(RegistrySnapshot,
+                           ?HEX_REGISTRY_PATH).
+
+-spec make_sure_registry_snapshot_exists(string()) -> ok.
+make_sure_registry_snapshot_exists(RegistrySnapshot) ->
+    case filelib:is_file(RegistrySnapshot) of
+        true ->
+            ok;
+        false ->
+            stderr("Registry snapshot (~s) does not exist!", [RegistrySnapshot]),
+            erlang:halt(1)
+    end.
+
+-spec gather_required_data_from_the_environment(#data{}) -> {ok, #data{}}.
+gather_required_data_from_the_environment(ArgData) ->
+    {ok, ArgData#data{ version = guard_env("version")
+                     , erl_libs = get_env("ERL_LIBS", [])
+                     , plugins = get_env("buildPlugins", [])
+                     , root = code:root_dir()
+                     , name = guard_env("name")
+                     , compile_ports = nix2bool(get_env("compilePorts", ""))
+                     , registry_snapshot = guard_env("HEX_REGISTRY_SNAPSHOT")}}.
+
+-spec nix2bool(any()) -> boolean().
+nix2bool("1") ->
+    true;
+nix2bool("") ->
+    false.
+
+get_env(Name) ->
+    os:getenv(Name).
+get_env(Name, Def) ->
+    case get_env(Name) of
+        false -> Def;
+        Val ->   Val
+    end.
+
+-spec guard_env(string()) -> string().
+guard_env(Name) ->
+    case get_env(Name) of
+        false ->
+            stderr("Expected Environment variable ~s! Are you sure you are "
+                   "running in a Nix environment? Either a nix-build, "
+                   "nix-shell, etc?~n", [Name]),
+            erlang:halt(1);
+        Variable ->
+            Variable
+    end.
+
+%% @doc
+%% If debug info is set we need to add debug info to the list of compile options
+%%
+-spec if_debug_info_add(#data{}) -> ok.
+if_debug_info_add(#data{debug_info = true}) ->
+    ConfigTerms = add_debug_info(read_rebar_config()),
+    Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end,
+                     ConfigTerms),
+    file:write_file("rebar.config", Text);
+if_debug_info_add(_) ->
+    ok.
+
+-spec add_debug_info([term()]) -> [term()].
+add_debug_info(Config) ->
+    ExistingOpts = case lists:keysearch(erl_opts, 1, Config) of
+                       {value, {erl_opts, ExistingOptsList}} -> ExistingOptsList;
+                       _ -> []
+                   end,
+    case lists:member(debug_info, ExistingOpts) of
+        true ->
+            Config;
+        false ->
+            lists:keystore(erl_opts, 1, Config,
+                           {erl_opts, [debug_info | ExistingOpts]})
+    end.
+
+
+%% @doc
+%% If the compile ports flag is set, rewrite the rebar config to
+%% include the 'pc' plugin.
+-spec if_compile_ports_add_pc_plugin(#data{}) -> ok.
+if_compile_ports_add_pc_plugin(#data{compile_ports = true}) ->
+    ConfigTerms = add_pc_to_plugins(read_rebar_config()),
+    Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end,
+                     ConfigTerms),
+    file:write_file("rebar.config", Text);
+if_compile_ports_add_pc_plugin(_) ->
+    ok.
+
+-spec add_pc_to_plugins([term()]) -> [term()].
+add_pc_to_plugins(Config) ->
+    PluginList = case lists:keysearch(plugins, 1, Config) of
+                     {value, {plugins, ExistingPluginList}} -> ExistingPluginList;
+                     _ -> []
+                 end,
+    lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
+
+-spec read_rebar_config() -> [term()].
+read_rebar_config() ->
+    case file:consult("rebar.config") of
+        {ok, Terms} ->
+            Terms;
+        _ ->
+            stderr("Unable to read rebar config!", []),
+            erlang:halt(1)
+    end.
+
+
+-spec if_single_app_project_update_app_src_version(#data{}) -> ok.
+if_single_app_project_update_app_src_version(#data{name = Name,
+                                                   version = Version}) ->
+    SrcFile = filename:join("src",
+                            lists:concat([Name, ".app.src"])),
+
+    case filelib:is_file(SrcFile) of
+        true ->
+            update_app_src_with_version(SrcFile, Version);
+        false ->
+            ok
+    end.
+
+-spec update_app_src_with_version(string(), string()) -> ok.
+update_app_src_with_version(SrcFile, Version) ->
+    {ok, [{application, Name, Details}]} = file:consult(SrcFile),
+    NewDetails = lists:keyreplace(vsn, 1, Details, {vsn, Version}),
+    ok = file:write_file(SrcFile, io_lib:fwrite("~p.\n", [{application, Name, NewDetails}])).
+
+%% @doc
+%% Write the result of the format string out to stderr.
+-spec stderr(string(), [term()]) -> ok.
+stderr(FormatStr, Args) ->
+    io:put_chars(standard_error, io_lib:format(FormatStr, Args)).
diff --git a/nixpkgs/pkgs/development/tools/build-managers/redo-sh/default.nix b/nixpkgs/pkgs/development/tools/build-managers/redo-sh/default.nix
new file mode 100644
index 000000000000..3036ef235845
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/redo-sh/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  version = "2.0.3";
+  name = "redo-sh-${version}";
+
+  src = fetchurl {
+    url = "http://news.dieweltistgarnichtso.net/bin/archives/redo-sh.tar.gz";
+    sha256 = "1ycx3hik7vnlbwxacn1dzr48fwsn2ials0sg6k9l3gcyrha5wf1n";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  sourceRoot = ".";
+  installPhase = ''
+    mkdir -p "$out/share"
+    mv man "$out/share"
+    mv bin "$out"
+    for p in $out/bin/*; do
+      wrapProgram "$p" --suffix PATH : "$out/bin"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Redo implementation in Bourne Shell";
+    homepage = http://news.dieweltistgarnichtso.net/bin/redo-sh.html;
+    license  = licenses.agpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ sternenseemann ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/redo/default.nix b/nixpkgs/pkgs/development/tools/build-managers/redo/default.nix
new file mode 100644
index 000000000000..97b82d204ad2
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/redo/default.nix
@@ -0,0 +1,28 @@
+{stdenv, fetchurl, perl }:
+
+stdenv.mkDerivation rec {
+  name = "redo-1.4";
+  src = fetchurl {
+    url = "https://jdebp.eu./Repository/freebsd/${name}.tar.gz";
+    sha256 = "1c8gr5h77v4fw78zkhbm9z9adqs3kd7xvxwnmci2zvlf4bqqk4jv";
+  };
+
+  nativeBuildInputs = [ perl /* for pod2man */ ];
+
+  sourceRoot = ".";
+
+  buildPhase = ''
+    ./package/compile
+  '';
+  installPhase = ''
+    ./package/export $out/
+  '';
+
+  meta = {
+    homepage = https://jdebp.eu./Softwares/redo/;
+    description = "A system for building target files from source files";
+    license = stdenv.lib.licenses.bsd2;
+    maintainers = [ stdenv.lib.maintainers.vrthra ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/remake/default.nix b/nixpkgs/pkgs/development/tools/build-managers/remake/default.nix
new file mode 100644
index 000000000000..3eca6f02e45d
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/remake/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, readline }:
+
+stdenv.mkDerivation rec {
+  name = "remake-${version}";
+  remakeVersion = "4.1";
+  dbgVersion = "1.1";
+  version = "${remakeVersion}+dbg-${dbgVersion}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/bashdb/remake/${version}/remake-${remakeVersion}+dbg${dbgVersion}.tar.bz2";
+    sha256 = "1zi16pl7sqn1aa8b7zqm9qnd9vjqyfywqm8s6iap4clf86l7kss2";
+  };
+
+  patches = [
+    ./glibc-2.27-glob.patch
+  ];
+
+  buildInputs = [ readline ];
+
+  meta = {
+    homepage = http://bashdb.sourceforge.net/remake/;
+    license = stdenv.lib.licenses.gpl3;
+    description = "GNU Make with comprehensible tracing and a debugger";
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+    maintainers = with stdenv.lib.maintainers; [ bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/remake/glibc-2.27-glob.patch b/nixpkgs/pkgs/development/tools/build-managers/remake/glibc-2.27-glob.patch
new file mode 100644
index 000000000000..ef876e2fb237
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/remake/glibc-2.27-glob.patch
@@ -0,0 +1,34 @@
+diff --git a/glob/glob.c b/glob/glob.c
+index f3911bcd861..6cb76e8e162 100644
+--- a/glob/glob.c
++++ b/glob/glob.c
+@@ -208,29 +208,8 @@ my_realloc (p, n)
+ #endif /* __GNU_LIBRARY__ || __DJGPP__ */
+ 
+ 
+-#if !defined __alloca && !defined __GNU_LIBRARY__
+-
+-# ifdef	__GNUC__
+-#  undef alloca
+-#  define alloca(n)	__builtin_alloca (n)
+-# else	/* Not GCC.  */
+-#  ifdef HAVE_ALLOCA_H
+-#   include <alloca.h>
+-#  else	/* Not HAVE_ALLOCA_H.  */
+-#   ifndef _AIX
+-#    ifdef WINDOWS32
+-#     include <malloc.h>
+-#    else
+-extern char *alloca ();
+-#    endif /* WINDOWS32 */
+-#   endif /* Not _AIX.  */
+-#  endif /* sparc or HAVE_ALLOCA_H.  */
+-# endif	/* GCC.  */
+-
+ # define __alloca	alloca
+ 
+-#endif
+-
+ #ifndef __GNU_LIBRARY__
+ # define __stat stat
+ # ifdef STAT_MACROS_BROKEN
diff --git a/nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix b/nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix
new file mode 100644
index 000000000000..deea53c9d38b
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub, which, curl, makeWrapper, jdk }:
+
+let
+  rev = "33b1a535656222810572d36d10afc5711515958e";
+  version = "2018-12-04";
+in
+stdenv.mkDerivation {
+  name = "sbt-extras-${version}";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "paulp";
+    repo = "sbt-extras";
+    inherit rev;
+    sha256 = "0195b47a6agzs750il1lirm2rhlz55f59sb8mdi6573fnj6f23d3";
+  };
+
+  dontBuild = true;
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+
+    substituteInPlace bin/sbt --replace 'declare java_cmd="java"' 'declare java_cmd="${jdk}/bin/java"'
+
+    install bin/sbt $out/bin
+
+    wrapProgram $out/bin/sbt --prefix PATH : ${stdenv.lib.makeBinPath [ which curl ]}
+  '';
+
+  meta = {
+    description = "A more featureful runner for sbt, the simple/scala/standard build tool";
+    homepage = https://github.com/paulp/sbt-extras;
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = with stdenv.lib.maintainers; [ puffnfresh ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/sbt/default.nix b/nixpkgs/pkgs/development/tools/build-managers/sbt/default.nix
new file mode 100644
index 000000000000..d6eed35e30ae
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/sbt/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, jre }:
+
+stdenv.mkDerivation rec {
+  name = "sbt-${version}";
+  version = "1.2.7";
+
+  src = fetchurl {
+    urls = [
+      "https://dl.bintray.com/sbt/native-packages/sbt/${version}/${name}.tgz"
+      "https://github.com/sbt/sbt/releases/download/v${version}/sbt-${version}.tgz"
+      "https://cocl.us/sbt-${version}.tgz"
+    ];
+    sha256 = "10g7a1j2knbqmnbpvfhy1rqdg2pflmasz879ax59pv3mvgccn996";
+  };
+
+  patchPhase = ''
+    echo -java-home ${jre.home} >>conf/sbtopts
+  '';
+
+  installPhase = ''
+    mkdir -p $out/share/sbt $out/bin
+    cp -ra . $out/share/sbt
+    ln -s $out/share/sbt/bin/sbt $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.scala-sbt.org/;
+    license = licenses.bsd3;
+    description = "A build tool for Scala, Java and more";
+    maintainers = with maintainers; [ nequissimus rickynils ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/sbt/scala-native.nix b/nixpkgs/pkgs/development/tools/build-managers/sbt/scala-native.nix
new file mode 100644
index 000000000000..70038ed2d3a4
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/sbt/scala-native.nix
@@ -0,0 +1,18 @@
+{ lib, sbt, makeWrapper, boehmgc, libunwind, re2, llvmPackages, zlib }:
+
+sbt.overrideDerivation(old: {
+  nativeBuildInputs = [ makeWrapper ];
+
+  version = "0.13.16";
+
+  sha256 = "033nvklclvbirhpsiy28d3ccmbm26zcs9vb7j8jndsc1ln09awi2";
+
+  postFixup = ''
+    wrapProgram $out/bin/sbt \
+      --set CLANG_PATH      "${llvmPackages.clang}/bin/clang" \
+      --set CLANGPP_PATH    "${llvmPackages.clang}/bin/clang" \
+      --set CPATH           "${lib.makeSearchPathOutput "dev" "include" [ re2 zlib boehmgc libunwind llvmPackages.libcxxabi llvmPackages.libcxx ]}/c++/v1" \
+      --set LIBRARY_PATH    "${lib.makeLibraryPath [ re2 zlib boehmgc libunwind llvmPackages.libcxxabi llvmPackages.libcxx ]}" \
+      --set NIX_CFLAGS_LINK "-lc++abi -lc++"
+  '';
+})
diff --git a/nixpkgs/pkgs/development/tools/build-managers/scons/common.nix b/nixpkgs/pkgs/development/tools/build-managers/scons/common.nix
new file mode 100644
index 000000000000..740d04d853f7
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/scons/common.nix
@@ -0,0 +1,34 @@
+{ version, sha256 }:
+
+{ stdenv, fetchurl, python2Packages }:
+
+let name = "scons";
+in python2Packages.buildPythonApplication {
+  name = "${name}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/scons/${name}-${version}.tar.gz";
+    inherit sha256;
+  };
+
+  # Fix a regression in 3.0.0 (causes build errors for some packages)
+  patches = stdenv.lib.optional (version == "3.0.0") ./print-statements.patch;
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with stdenv.lib; {
+    homepage = http://scons.org/;
+    description = "An improved, cross-platform substitute for Make";
+    license = licenses.mit;
+    longDescription = ''
+      SCons is an Open Source software construction tool. Think of
+      SCons as an improved, cross-platform substitute for the classic
+      Make utility with integrated functionality similar to
+      autoconf/automake and compiler caches such as ccache. In short,
+      SCons is an easier, more reliable and faster way to build
+      software.
+    '';
+    platforms = platforms.all;
+    maintainers = [ maintainers.primeos ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/scons/default.nix b/nixpkgs/pkgs/development/tools/build-managers/scons/default.nix
new file mode 100644
index 000000000000..3bd31523412a
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/scons/default.nix
@@ -0,0 +1,18 @@
+{ callPackage }:
+
+let
+  mkScons = args: callPackage (import ./common.nix args) { };
+in {
+  scons_2_5_1 = mkScons {
+    version = "2.5.1";
+    sha256 = "1wji1z9jdkhnmm99apx6fhld9cs52rr56aigniyrcsmlwy52298b";
+  };
+  scons_3_0_0 = mkScons {
+    version = "3.0.0";
+    sha256 = "05jjykllk4icnq6gfrkgkbc4ggxm7983q6r33mrhpilqbd02ylqg";
+  };
+  scons_3_0_1 = mkScons {
+    version = "3.0.1";
+    sha256 = "0wzid419mlwqw9llrg8gsx4nkzhqy16m4m40r0xnh6cwscw5wir4";
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/scons/print-statements.patch b/nixpkgs/pkgs/development/tools/build-managers/scons/print-statements.patch
new file mode 100644
index 000000000000..a963bf78abab
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/scons/print-statements.patch
@@ -0,0 +1,13 @@
+diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
+index 558e28f9..8fea9c4d 100644
+--- src/engine/SCons/Script/SConscript.py
++++ src/engine/SCons/Script/SConscript.py
+@@ -5,8 +5,6 @@
+ 
+ """
+ 
+-from __future__ import print_function
+-
+ #
+ # __COPYRIGHT__
+ #
diff --git a/nixpkgs/pkgs/development/tools/build-managers/scons/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/scons/setup-hook.sh
new file mode 100644
index 000000000000..55159aa5a93a
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/scons/setup-hook.sh
@@ -0,0 +1,84 @@
+sconsBuildPhase() {
+    runHook preBuild
+
+    if [ -n "$prefix" ]; then
+        mkdir -p "$prefix"
+    fi
+
+    if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then
+        buildFlags="${prefixKey:-prefix=}$prefix $buildFlags"
+    fi
+
+    local flagsArray=(
+      ${enableParallelBuilding:+-j${NIX_BUILD_CORES}}
+      $sconsFlags ${sconsFlagsArray[@]}
+      $buildFlags ${buildFlagsArray[@]}
+    )
+
+    echoCmd 'build flags' "${flagsArray[@]}"
+    scons "${flagsArray[@]}"
+
+    runHook postBuild
+}
+
+sconsInstallPhase() {
+    runHook preInstall
+
+    if [ -n "$prefix" ]; then
+        mkdir -p "$prefix"
+    fi
+
+    if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then
+        installFlags="${prefixKey:-prefix=}$prefix $installFlags"
+    fi
+
+    local flagsArray=(
+        $sconsFlags ${sconsFlagsArray[@]}
+        $installFlags ${installFlagsArray[@]}
+        ${installTargets:-install}
+    )
+
+    echoCmd 'install flags' "${flagsArray[@]}"
+    scons "${flagsArray[@]}"
+
+    runHook postInstall
+}
+
+sconsCheckPhase() {
+    runHook preCheck
+
+    if [ -z "${checkTarget:-}" ]; then
+        if scons -n check >/dev/null 2>&1; then
+            checkTarget=check
+        elif scons -n test >/dev/null 2>&1; then
+            checkTarget=test
+        fi
+    fi
+
+    if [ -z "${checkTarget:-}" ]; then
+        echo "no check/test target found, doing nothing"
+    else
+        local flagsArray=(
+            ${enableParallelChecking:+-j${NIX_BUILD_CORES}}
+            $sconsFlags ${sconsFlagsArray[@]}
+            ${checkFlagsArray[@]}
+        )
+
+        echoCmd 'check flags' "${flagsArray[@]}"
+        scons "${flagsArray[@]}"
+    fi
+
+    runHook postCheck
+}
+
+if [ -z "$buildPhase" ]; then
+    buildPhase=sconsBuildPhase
+fi
+
+if [ -z "$dontUseSconsInstall" -a -z "$installPhase" ]; then
+    installPhase=sconsInstallPhase
+fi
+
+if [ -z "$checkPhase" ]; then
+    checkPhase=sconsCheckPhase
+fi
diff --git a/nixpkgs/pkgs/development/tools/build-managers/shards/default.nix b/nixpkgs/pkgs/development/tools/build-managers/shards/default.nix
new file mode 100644
index 000000000000..02d5adb0c34d
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/shards/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, crystal, pcre, libyaml, which }:
+
+stdenv.mkDerivation rec {
+  name = "shards-${version}";
+  version = "0.8.1";
+
+  src = fetchFromGitHub {
+    owner  = "crystal-lang";
+    repo   = "shards";
+    rev    = "v${version}";
+    sha256 = "1cjn2lafr08yiqzlhyqx14jjjxf1y24i2kk046px07gljpnlgqwk";
+  };
+
+  buildInputs = [ crystal libyaml pcre which ];
+
+  buildFlags = [ "CRFLAGS=--release" ];
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm755 bin/shards $out/bin/shards
+
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Dependency manager for the Crystal language";
+    license     = licenses.asl20;
+    maintainers = with maintainers; [ peterhoeg ];
+    inherit (crystal.meta) homepage platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/tup/default.nix b/nixpkgs/pkgs/development/tools/build-managers/tup/default.nix
new file mode 100644
index 000000000000..fd27d927bd57
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/tup/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchFromGitHub, fuse, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "tup-${version}";
+  version = "0.7.5";
+
+  src = fetchFromGitHub {
+    owner = "gittup";
+    repo = "tup";
+    rev = "v${version}";
+    sha256 = "0jzp1llq6635ldb7j9qb29j2k0x5mblimdqg3179dvva1hv0ia23";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse ];
+
+  configurePhase = ''
+    sed -i 's/`git describe`/v${version}/g' Tupfile
+  '';
+
+  # Regular tup builds require fusermount to have suid, which nix cannot
+  # currently provide in a build environment, so we bootstrap and use 'tup
+  # generate' instead
+  buildPhase = ''
+    ./build.sh
+    ./build/tup generate script.sh
+    ./script.sh
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp tup $out/bin/
+
+    mkdir -p $out/share/man/man1
+    cp tup.1 $out/share/man/man1/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A fast, file-based build system";
+    longDescription = ''
+      Tup is a file-based build system for Linux, OSX, and Windows. It inputs a list
+      of file changes and a directed acyclic graph (DAG), then processes the DAG to
+      execute the appropriate commands required to update dependent files. Updates are
+      performed with very little overhead since tup implements powerful build
+      algorithms to avoid doing unnecessary work. This means you can stay focused on
+      your project rather than on your build system.
+    '';
+    homepage = http://gittup.org/tup/;
+    license = licenses.gpl2;
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/waf/default.nix b/nixpkgs/pkgs/development/tools/build-managers/waf/default.nix
new file mode 100644
index 000000000000..1b884307273e
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/waf/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitLab, python, ensureNewerSourcesForZipFilesHook }:
+
+stdenv.mkDerivation rec {
+  name = "waf-${version}";
+  version = "2.0.13";
+
+  src = fetchFromGitLab {
+    owner = "ita1024";
+    repo = "waf";
+    rev = name;
+    sha256 = "1r4nyxpf07w98bx9zx0xii97rwsc27s6898xi9ph25p0n6hsdxxg";
+  };
+
+  buildInputs = [ python ensureNewerSourcesForZipFilesHook ];
+
+  configurePhase = ''
+    python waf-light configure
+  '';
+  buildPhase = ''
+    python waf-light build
+  '';
+  installPhase = ''
+    install waf $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Meta build system";
+    homepage    = https://waf.io;
+    license     = licenses.bsd3;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ vrthra ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/build-managers/waf/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/waf/setup-hook.sh
new file mode 100644
index 000000000000..b8a448df8ef8
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/build-managers/waf/setup-hook.sh
@@ -0,0 +1,62 @@
+wafConfigurePhase() {
+    runHook preConfigure
+
+    if ! [ -f ./waf ]; then
+        cp @waf@ waf
+    fi
+
+    if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then
+        configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"
+    fi
+
+    local flagsArray=(
+        $configureFlags ${configureFlagsArray[@]}
+        ${configureTargets:-configure}
+    )
+    echoCmd 'configure flags' "${flagsArray[@]}"
+    python waf "${flagsArray[@]}"
+
+    runHook postConfigure
+}
+
+wafBuildPhase () {
+    runHook preBuild
+
+    # set to empty if unset
+    : ${wafFlags=}
+
+    local flagsArray=(
+      ${enableParallelBuilding:+-j ${NIX_BUILD_CORES}}
+      $wafFlags ${wafFlagsArray[@]}
+      $buildFlags ${buildFlagsArray[@]}
+      ${buildTargets:-build}
+    )
+
+    echoCmd 'build flags' "${flagsArray[@]}"
+    python waf "${flagsArray[@]}"
+
+    runHook postBuild
+}
+
+wafInstallPhase() {
+    runHook preInstall
+
+    if [ -n "$prefix" ]; then
+        mkdir -p "$prefix"
+    fi
+
+    local flagsArray=(
+        $wafFlags ${wafFlagsArray[@]}
+        $installFlags ${installFlagsArray[@]}
+	${installTargets:-install}
+    )
+
+    echoCmd 'install flags' "${flagsArray[@]}"
+    python waf "${flagsArray[@]}"
+
+    runHook postInstall
+}
+
+configurePhase=wafConfigurePhase
+buildPhase=wafBuildPhase
+installPhase=wafInstallPhase