summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers/buck/default.nix
blob: d283e1e321db7f0e0c36d86c9a0d8e3feccb38c7 (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
{ lib, stdenv, fetchFromGitHub, jdk8, ant, python3, watchman, bash, makeWrapper }:

stdenv.mkDerivation rec {
  pname = "buck";
  version = "2022.05.05.01";

  src = fetchFromGitHub {
    owner = "facebook";
    repo = pname;
    rev = "v${version}";
    sha256 = "15v4sk1l43pgd5jxr5lxnh0ks6vb3xk5253n66s7vvsnph48j14q";
  };

  patches = [ ./pex-mtime.patch ];

  postPatch = ''
    grep -l -r '/bin/bash' --null | xargs -0 sed -i -e "s!/bin/bash!${bash}/bin/bash!g"
  '';

  nativeBuildInputs = [ makeWrapper python3 jdk8 ant watchman ];

  buildPhase = ''
    # Set correct version, see https://github.com/facebook/buck/issues/2607
    echo v${version} > .buckrelease

    ant

    PYTHONDONTWRITEBYTECODE=true ./bin/buck build -c buck.release_version=${version} buck
  '';

  installPhase = ''
    install -D -m755 buck-out/gen/*/programs/buck.pex $out/bin/buck
    wrapProgram $out/bin/buck \
      --prefix PATH : "${lib.makeBinPath [ jdk8 watchman python3 ]}"
  '';

  meta = with lib; {
    homepage = "https://buck.build/";
    description = "A high-performance build tool";
    maintainers = [ maintainers.jgertm maintainers.marsam ];
    license = licenses.asl20;
    platforms = platforms.all;
    # https://github.com/facebook/buck/issues/2666
    broken = stdenv.isDarwin && stdenv.isAarch64;
  };
}