From 48c910611f8a592426cbf6dee1cb3c212aa3299b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20J=C3=A4ger?= Date: Tue, 6 Jun 2017 20:35:29 -0700 Subject: [PATCH 1/3] buck: init at v2017.05.31.01 --- .../tools/build-managers/buck/default.nix | 46 +++++++++++++++++++ .../tools/build-managers/buck/pex-mtime.patch | 21 +++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 69 insertions(+) create mode 100644 pkgs/development/tools/build-managers/buck/default.nix create mode 100644 pkgs/development/tools/build-managers/buck/pex-mtime.patch diff --git a/pkgs/development/tools/build-managers/buck/default.nix b/pkgs/development/tools/build-managers/buck/default.nix new file mode 100644 index 00000000000..020750393cd --- /dev/null +++ b/pkgs/development/tools/build-managers/buck/default.nix @@ -0,0 +1,46 @@ + { stdenv, pkgs, fetchFromGitHub, fetchgit, jdk, ant, python2, watchman, unzip, bash }: + +stdenv.mkDerivation rec { + name = "buck-${version}"; + version = "v2017.05.31.01"; + + src = fetchFromGitHub { + owner = "facebook"; + repo = "buck"; + rev = "0b8b3828a11afa79dc128832cb55b106f07e48aa"; + sha256 = "1g3yg8qq91cdhsq7zmir7wxw3767l120f5zhq969gppdw9apqy0s"; + }; + + patches = [ ./pex-mtime.patch ]; + + postPatch = '' + for f in $(grep -l -r '/bin/bash'); do + substituteInPlace "$f" --replace '/bin/bash' '${bash}/bin/bash' + done + ''; + + buildInputs = [ jdk ant ]; + + propagatedBuildInputs = [ python2 watchman pkgs.python27Packages.pywatchman ]; + + buildPhase = + '' + ant + ./bin/buck --version + ./bin/buck build buck + ''; + + installPhase = + '' + mkdir -p $out/bin + cp buck-out/gen/programs/buck.pex $out/bin/buck + ''; + + 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/pkgs/development/tools/build-managers/buck/pex-mtime.patch b/pkgs/development/tools/build-managers/buck/pex-mtime.patch new file mode 100644 index 00000000000..01640f342ae --- /dev/null +++ b/pkgs/development/tools/build-managers/buck/pex-mtime.patch @@ -0,0 +1,21 @@ +diff --git a/third-party/py/pex/pex/common.py b/third-party/py/pex/pex/common.py +index 76459ce23..491dcfc0b 100644 +--- a/third-party/py/pex/pex/common.py ++++ b/third-party/py/pex/pex/common.py +@@ -12,6 +12,7 @@ import stat + import sys + import tempfile + import threading ++import time + import zipfile + from collections import defaultdict + from uuid import uuid4 +@@ -328,4 +329,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) ++ file = os.path.join(self.chroot, f) ++ instant = 315532800 ++ os.utime(file, (instant, instant)) ++ zf.write(file, arcname=f, compress_type=zipfile.ZIP_DEFLATED) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8bca3cee890..7f84f3ac9e6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6552,6 +6552,8 @@ with pkgs; wxGTK = wxGTK30; }; + buck = callPackage ../development/tools/build-managers/buck { }; + buildbot = callPackage ../development/tools/build-managers/buildbot { pythonPackages = python2Packages; }; From dffbe98dd696fe3579c9ce430524cce689d85508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 8 Jun 2017 08:36:59 +0100 Subject: [PATCH 2/3] buck: make propagatedBuildInputs runtime deps --- .../tools/build-managers/buck/default.nix | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/pkgs/development/tools/build-managers/buck/default.nix b/pkgs/development/tools/build-managers/buck/default.nix index 020750393cd..dadea794466 100644 --- a/pkgs/development/tools/build-managers/buck/default.nix +++ b/pkgs/development/tools/build-managers/buck/default.nix @@ -1,6 +1,8 @@ - { stdenv, pkgs, fetchFromGitHub, fetchgit, jdk, ant, python2, watchman, unzip, bash }: +{ stdenv, fetchFromGitHub, jdk, ant, python2, python2Packages, watchman, unzip, bash, jre, makeWrapper }: -stdenv.mkDerivation rec { + +let +in stdenv.mkDerivation rec { name = "buck-${version}"; version = "v2017.05.31.01"; @@ -14,27 +16,23 @@ stdenv.mkDerivation rec { patches = [ ./pex-mtime.patch ]; postPatch = '' - for f in $(grep -l -r '/bin/bash'); do - substituteInPlace "$f" --replace '/bin/bash' '${bash}/bin/bash' - done + grep -l -r '/bin/bash' --null | xargs -0 sed -i -e "s!/bin/bash!${bash}/bin/bash!g" ''; - buildInputs = [ jdk ant ]; + buildInputs = [ jdk ant python2 watchman python2Packages.pywatchman ]; + nativeBuildInputs = [ makeWrapper ]; - propagatedBuildInputs = [ python2 watchman pkgs.python27Packages.pywatchman ]; + buildPhase = '' + ant + ./bin/buck build buck + ''; - buildPhase = - '' - ant - ./bin/buck --version - ./bin/buck build buck - ''; - - installPhase = - '' - mkdir -p $out/bin - cp buck-out/gen/programs/buck.pex $out/bin/buck - ''; + installPhase = '' + install -D -m755 buck-out/gen/programs/buck.pex $out/bin/buck + wrapProgram $out/bin/buck \ + --prefix PYTHONPATH : $PYTHONPATH \ + --prefix PATH : "${stdenv.lib.makeBinPath [jre watchman]}" + ''; meta = with stdenv.lib; { homepage = https://buckbuild.com/; From 926f3eada8f2a45345781a7074f33fe5f25f2402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20J=C3=A4ger?= Date: Thu, 8 Jun 2017 11:26:42 -0700 Subject: [PATCH 3/3] buck: cleanup --- .../tools/build-managers/buck/default.nix | 8 +++----- .../tools/build-managers/buck/pex-mtime.patch | 20 ++++++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pkgs/development/tools/build-managers/buck/default.nix b/pkgs/development/tools/build-managers/buck/default.nix index dadea794466..bb21d34c957 100644 --- a/pkgs/development/tools/build-managers/buck/default.nix +++ b/pkgs/development/tools/build-managers/buck/default.nix @@ -1,8 +1,6 @@ -{ stdenv, fetchFromGitHub, jdk, ant, python2, python2Packages, watchman, unzip, bash, jre, makeWrapper }: +{ stdenv, fetchFromGitHub, jdk, ant, python2, python2Packages, watchman, unzip, bash, makeWrapper }: - -let -in stdenv.mkDerivation rec { +stdenv.mkDerivation rec { name = "buck-${version}"; version = "v2017.05.31.01"; @@ -31,7 +29,7 @@ in stdenv.mkDerivation rec { install -D -m755 buck-out/gen/programs/buck.pex $out/bin/buck wrapProgram $out/bin/buck \ --prefix PYTHONPATH : $PYTHONPATH \ - --prefix PATH : "${stdenv.lib.makeBinPath [jre watchman]}" + --prefix PATH : "${stdenv.lib.makeBinPath [jdk watchman]}" ''; meta = with stdenv.lib; { diff --git a/pkgs/development/tools/build-managers/buck/pex-mtime.patch b/pkgs/development/tools/build-managers/buck/pex-mtime.patch index 01640f342ae..b8726e64a60 100644 --- a/pkgs/development/tools/build-managers/buck/pex-mtime.patch +++ b/pkgs/development/tools/build-managers/buck/pex-mtime.patch @@ -1,21 +1,13 @@ diff --git a/third-party/py/pex/pex/common.py b/third-party/py/pex/pex/common.py -index 76459ce23..491dcfc0b 100644 +index 76459ce23..eff411b20 100644 --- a/third-party/py/pex/pex/common.py +++ b/third-party/py/pex/pex/common.py -@@ -12,6 +12,7 @@ import stat - import sys - import tempfile - import threading -+import time - import zipfile - from collections import defaultdict - from uuid import uuid4 -@@ -328,4 +329,7 @@ class Chroot(object): +@@ -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) -+ file = os.path.join(self.chroot, f) -+ instant = 315532800 -+ os.utime(file, (instant, instant)) -+ zf.write(file, 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)