Skip to content

Commit

Permalink
feat(nix): add watchman package
Browse files Browse the repository at this point in the history
Summary: After some pain, I was able to get a (possibly functioning) watchman package working.

Test Plan: `touch .envrc && watchman --version`
  • Loading branch information
thoughtpolice committed Dec 21, 2022
1 parent e1a3a87 commit 6c45ab1
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
71 changes: 71 additions & 0 deletions buck/nix/buck2/watchman.nix
@@ -0,0 +1,71 @@
{ stdenv, gcc12, gcc12Stdenv
, fetchurl, fetchFromGitHub
, rpmextract
, autoPatchelfHook
, openssl
, zlib, bzip2, xz, lz4, snappy, zstd
, libevent
, libunwind
, pcre2
, glog, gflags, gtest, cmake
, boost174
, libsodium
, double-conversion
}:

let
version = "2022.12.19.00";

file = {
x86_64-linux = "watchman-20221218.010722.0-1.fc36.x86_64.rpm"; # XXX FIXME (aseipp): name is wrong?
}."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

baseurl = "https://github.com/facebook/watchman/releases/download";

dlbin = sha256: fetchurl {
url = "${baseurl}/v${version}/${file}";
sha256 = sha256."${stdenv.hostPlatform.system}";
};

glog0 = stdenv.mkDerivation rec {
pname = "glog";
version = "0.4.0";

src = fetchFromGitHub {
owner = "google";
repo = "glog";
rev = "v${version}";
hash = "sha256-K3X199xY2uLDeNeScDufu1tRemF05ZwYrH25G6Oqo/U=";
};

nativeBuildInputs = [ cmake ];
buildInputs = [ gtest ];
propagatedBuildInputs = [ gflags ];

cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
};
in
gcc12Stdenv.mkDerivation {
pname = "fbwatchman";
inherit version;

src = dlbin {
x86_64-linux = "sha256-259AKteVefGs+bF7sE3PXE8jtdZ4BnOoqZKu+Bvt8Hs=";
};

unpackPhase = "rpmextract $src";

buildInputs = [
openssl libevent glog0 gflags libsodium
zlib bzip2 xz lz4 snappy zstd gcc12.cc.lib
libunwind pcre2 boost174 double-conversion
];
nativeBuildInputs = [ autoPatchelfHook rpmextract ];
dontConfigure = true;

installPhase = ''
ls usr/local
mkdir -p $out
mv usr/local/bin/ $out/bin
'';
}
1 change: 1 addition & 0 deletions buck/nix/flake.nix
Expand Up @@ -54,6 +54,7 @@
tagref sapling jq getopt jujutsu
;

watchman = pkgs.callPackage ./buck2/watchman.nix { };
buck2 = pkgs.callPackage ./buck2 { };
};

Expand Down

0 comments on commit 6c45ab1

Please sign in to comment.