From 81a2e8c043cbefa44ef265ec0529f34001c1fb31 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Wed, 12 Apr 2023 15:55:42 -0500 Subject: [PATCH] fix: use 'watchman' from nixpkgs, delete hacks, enable on aarch64-linux Summary: Thanks to the heroic effort of several nixpkgs contributors, watchman was finally updated to a (much) more recent build, and aarch64 support came along with it! This allows us to support aarch64-linux, delete our own binary- based package, and delete some special case hacks in Buck, as well. Overall a win. Test Plan: use 'watchman' on my laptop --- .envrc | 2 - .../nix/buck2/aarch64-linux-notify-hack.patch | 35 --------- buck/nix/buck2/default.nix | 5 -- buck/nix/buck2/watchman.nix | 71 ------------------- buck/nix/flake.nix | 6 +- 5 files changed, 1 insertion(+), 118 deletions(-) delete mode 100644 buck/nix/buck2/aarch64-linux-notify-hack.patch delete mode 100644 buck/nix/buck2/watchman.nix diff --git a/.envrc b/.envrc index ea695ca..bec62d5 100644 --- a/.envrc +++ b/.envrc @@ -78,8 +78,6 @@ export BUCK2_TEST_DISABLE_LOG_UPLOAD=true if [ "$(uname)" = "Darwin" ]; then # XXX FIXME (aseipp): macOS support echo "direnv: watchman: not enabling, because we're on macOS" -elif [ "$(uname -m)" = "aarch64" ]; then - echo "direnv: watchman: skipping, because watchman isn't supported on aarch64-linux (yet)" elif [ ! -f .use_watchman ] && [ -z "$CI_RUNNING" ]; then # XXX FIXME (aseipp): prompt about this file to the user echo "direnv: watchman: not enabled, because .use_watchman is missing, and we're not in a CI build" diff --git a/buck/nix/buck2/aarch64-linux-notify-hack.patch b/buck/nix/buck2/aarch64-linux-notify-hack.patch deleted file mode 100644 index bb83fd8..0000000 --- a/buck/nix/buck2/aarch64-linux-notify-hack.patch +++ /dev/null @@ -1,35 +0,0 @@ -commit b29855732a7bedbdb94bc2bd74fc445a939283b9 -Author: Austin Seipp -Date: Sat Dec 24 21:28:50 2022 -0600 - - hack(file_watcher): short-circuit aarch64-linux to "notify" - - Watchman doesn't even have binaries for this platform yet, so supporting - it isn't needed. - - Signed-off-by: Austin Seipp - -diff --git a/app/buck2_server/src/file_watcher/mod.rs b/app/buck2_server/src/file_watcher/mod.rs -index 229b6de8..47c4585b 100644 ---- a/app/buck2_server/src/file_watcher/mod.rs -+++ b/app/buck2_server/src/file_watcher/mod.rs -@@ -47,7 +47,18 @@ impl dyn FileWatcher { - "watchman" - }; - -- match root_config.get("buck2", "file_watcher").unwrap_or(default) { -+ let choice = if cfg!(target_arch = "aarch64") && cfg!(target_os = "linux") { -+ // XXX FIXME (aseipp): always default to notify on aarch64, as watchman -+ // doesn't even exist on that platform. -+ // -+ // see also: https://github.com/facebookincubator/buck2/issues/59 -+ "notify" -+ } else { -+ // otherwise, return what they asked. -+ root_config.get("buck2", "file_watcher").unwrap_or(default) -+ }; -+ -+ match choice { - "watchman" => Ok(Arc::new(WatchmanFileWatcher::new( - project_root.root(), - root_config, diff --git a/buck/nix/buck2/default.nix b/buck/nix/buck2/default.nix index 387e684..ff7055c 100644 --- a/buck/nix/buck2/default.nix +++ b/buck/nix/buck2/default.nix @@ -51,11 +51,6 @@ in rustPlatform.buildRustPackage rec { dontStrip = true; # XXX (aseipp): cargo will delete dwarf info but leave symbols for backtraces patches = [ - # XXX FIXME (aseipp): Disable watchman support entirely and always short- - # circuit to 'notify' on aarch64; this lets us keep things compatible on - # both aarch64-linux and x86_64-linux - ./aarch64-linux-notify-hack.patch - # XXX FIXME (aseipp): Use a version of 'prost' with a new API for boxing # large structs that buck2 needs ./update-prost-fork.patch diff --git a/buck/nix/buck2/watchman.nix b/buck/nix/buck2/watchman.nix deleted file mode 100644 index 07ba661..0000000 --- a/buck/nix/buck2/watchman.nix +++ /dev/null @@ -1,71 +0,0 @@ -{ stdenv, gcc12, gcc12Stdenv -, fetchurl, fetchFromGitHub -, dpkg -, 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_ubuntu22.04_v${version}.deb"; - }."${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-YMHClrPfZSZrsituge266RI96YY5kOk9iYryQaXqhL4="; - }; - - unpackPhase = "dpkg --fsys-tarfile $src | tar -xvf -"; - - buildInputs = [ - openssl libevent glog0 gflags libsodium - zlib bzip2 xz lz4 snappy zstd gcc12.cc.lib - libunwind pcre2 boost174 double-conversion - ]; - nativeBuildInputs = [ autoPatchelfHook dpkg ]; - dontConfigure = true; - - installPhase = '' - ls usr/local - mkdir -p $out - mv usr/local/bin/ $out/bin - ''; -} diff --git a/buck/nix/flake.nix b/buck/nix/flake.nix index dc8977b..cca6e59 100644 --- a/buck/nix/flake.nix +++ b/buck/nix/flake.nix @@ -117,16 +117,12 @@ inherit (pkgs) coreutils curl # downloading and fundamental scripts tagref sapling jq getopt jujutsu # utilities + watchman # fs integration ; # Finally, any globally useful tools we package here go next. This is primarily # buck, in our case... buck2 = pkgs.callPackage ./buck2 { }; - }) // (pkgs.lib.optionalAttrs (system == flake-utils.lib.system.x86_64-linux) { - # watchman is only supported on x86_64-linux for now; in theory it - # should be possible to port to aarch64-linux through the github - # release... - watchman = pkgs.callPackage ./buck2/watchman.nix { }; }); # The default Nix shell. This is populated by direnv and used for the