summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers/buck/default.nix
blob: 5d486f47844eb8ef14d607ab4e1f6089243e4bfc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ stdenv, fetchFromGitHub, jdk, ant, python2, python2Packages, watchman, unzip, bash, makeWrapper }:

stdenv.mkDerivation rec {
  name = "buck-${version}";
  version = "v2017.10.01.01";

  src = fetchFromGitHub {
    owner = "facebook";
    repo = "buck";
    rev = "2025fd74327477728b524eafdd4619a0170a24ea";
    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;
  };
}