Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ bison
2, cacert
3, fetchFromGitHub
4, flex
5, php
6, lib, stdenv
7, installShellFiles
8, which
9, python3
10}:
11
12# Make a custom wrapper. If `wrapProgram` is used, arcanist thinks .arc-wrapped is being
13# invoked and complains about it being an unknown toolset. We could use `makeWrapper`, but
14# then we’d need to still craft a script that does the `php libexec/arcanist/bin/...` dance
15# anyway... So just do everything at once.
16let makeArcWrapper = toolset: ''
17 cat << WRAPPER > $out/bin/${toolset}
18 #!$shell -e
19 export PATH='${php}/bin:${which}/bin'\''${PATH:+':'}\$PATH
20 exec ${php}/bin/php $out/libexec/arcanist/bin/${toolset} "\$@"
21 WRAPPER
22 chmod +x $out/bin/${toolset}
23'';
24
25in
26stdenv.mkDerivation {
27 pname = "arcanist";
28 version = "20230530";
29
30 src = fetchFromGitHub {
31 owner = "phacility";
32 repo = "arcanist";
33 rev = "e50d1bc4eabac9c37e3220e9f3fb8e37ae20b957";
34 hash = "sha256-u+HRsaCuAAyLrEihrZtLrdZ6NTVjPshieJATK3t5Fo4=";
35 };
36
37 patches = [
38 ./dont-require-python3-in-path.patch
39 ./shellcomplete-strlen-null.patch
40 ];
41
42 buildInputs = [ php python3 ];
43
44 nativeBuildInputs = [ bison flex installShellFiles ];
45
46 postPatch = lib.optionalString stdenv.isAarch64 ''
47 substituteInPlace support/xhpast/Makefile \
48 --replace "-minline-all-stringops" ""
49 '';
50
51 buildPhase = ''
52 runHook preBuild
53 make cleanall -C support/xhpast $makeFlags "''${makeFlagsArray[@]}" -j $NIX_BUILD_CORES
54 make xhpast -C support/xhpast $makeFlags "''${makeFlagsArray[@]}" -j $NIX_BUILD_CORES
55 runHook postBuild
56 '';
57
58 installPhase = ''
59 runHook preInstall
60 mkdir -p $out/bin $out/libexec
61 make install -C support/xhpast $makeFlags "''${makeFlagsArray[@]}" -j $NIX_BUILD_CORES
62 make cleanall -C support/xhpast $makeFlags "''${makeFlagsArray[@]}" -j $NIX_BUILD_CORES
63 cp -R . $out/libexec/arcanist
64 ln -sf ${cacert}/etc/ssl/certs/ca-bundle.crt $out/libexec/arcanist/resources/ssl/default.pem
65
66 ${makeArcWrapper "arc"}
67 ${makeArcWrapper "phage"}
68
69 $out/bin/arc shell-complete --generate --
70 installShellCompletion --cmd arc --bash $out/libexec/arcanist/support/shell/rules/bash-rules.sh
71 installShellCompletion --cmd phage --bash $out/libexec/arcanist/support/shell/rules/bash-rules.sh
72 runHook postInstall
73 '';
74
75 doInstallCheck = true;
76 installCheckPhase = ''
77 $out/bin/arc help diff -- > /dev/null
78 $out/bin/phage help alias -- > /dev/null
79 '';
80
81 meta = {
82 description = "Command line interface to Phabricator";
83 homepage = "https://www.phacility.com/";
84 license = lib.licenses.asl20;
85 platforms = lib.platforms.unix;
86 maintainers = [ lib.maintainers.thoughtpolice ];
87 };
88}