1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 jdk8,
6 ant,
7 python3,
8 watchman,
9 bash,
10 makeWrapper,
11}:
12
13stdenv.mkDerivation rec {
14 pname = "buck";
15 version = "2022.05.05.01";
16
17 src = fetchFromGitHub {
18 owner = "facebook";
19 repo = pname;
20 rev = "v${version}";
21 sha256 = "15v4sk1l43pgd5jxr5lxnh0ks6vb3xk5253n66s7vvsnph48j14q";
22 };
23
24 patches = [ ./pex-mtime.patch ];
25
26 postPatch = ''
27 grep -l -r '/bin/bash' --null | xargs -0 sed -i -e "s!/bin/bash!${bash}/bin/bash!g"
28 '';
29
30 nativeBuildInputs = [
31 makeWrapper
32 python3
33 jdk8
34 ant
35 watchman
36 ];
37
38 buildPhase = ''
39 # Set correct version, see https://github.com/facebook/buck/issues/2607
40 echo v${version} > .buckrelease
41
42 ant
43
44 PYTHONDONTWRITEBYTECODE=true ./bin/buck build -c buck.release_version=${version} buck
45 '';
46
47 installPhase = ''
48 install -D -m755 buck-out/gen/*/programs/buck.pex $out/bin/buck
49 wrapProgram $out/bin/buck \
50 --prefix PATH : "${
51 lib.makeBinPath [
52 jdk8
53 watchman
54 python3
55 ]
56 }"
57 '';
58
59 meta = with lib; {
60 homepage = "https://buck.build/";
61 description = "High-performance build tool";
62 mainProgram = "buck";
63 maintainers = [ maintainers.jgertm ];
64 license = licenses.asl20;
65 platforms = platforms.all;
66 # https://github.com/facebook/buck/issues/2666
67 broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
68 };
69}