From 1b9bc1648ac1c72ab9827c1b5512a3bd99052b55 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Thu, 25 Jan 2024 03:41:08 +0800 Subject: [PATCH 1/2] fix: use proto from env if present --- libs/realtime-entity/build.rs | 11 +++++++---- shell.nix | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 shell.nix diff --git a/libs/realtime-entity/build.rs b/libs/realtime-entity/build.rs index 4b11e89e..d78928fb 100644 --- a/libs/realtime-entity/build.rs +++ b/libs/realtime-entity/build.rs @@ -1,11 +1,14 @@ use std::process::Command; fn main() -> Result<(), Box> { - let protoc_path = protoc_bin_vendored::protoc_bin_path().expect("protoc bin path"); - let protoc_path_str = protoc_path.to_str().expect("protoc path to str"); + // If the `PROTOC` environment variable is set, don't use vendored `protoc` + std::env::var("PROTOC").map(|_| ()).unwrap_or_else(|_| { + let protoc_path = protoc_bin_vendored::protoc_bin_path().expect("protoc bin path"); + let protoc_path_str = protoc_path.to_str().expect("protoc path to str"); - // Set the `PROTOC` environment variable to the path of the `protoc` binary. - std::env::set_var("PROTOC", protoc_path_str); + // Set the `PROTOC` environment variable to the path of the `protoc` binary. + std::env::set_var("PROTOC", protoc_path_str); + }); prost_build::Config::new() .out_dir("src/") diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..511d2a6d --- /dev/null +++ b/shell.nix @@ -0,0 +1,11 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + packages = with pkgs; [ + pkg-config rustup + grpc-tools openssl + ]; + shellHook = '' + export PROTOC=$(which protoc) + ''; +} From 66b6d773c8eb52f3d73fae230eac4d13f75c8128 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Thu, 25 Jan 2024 10:37:31 +0800 Subject: [PATCH 2/2] chore: add nix shell to gitignore --- .gitignore | 3 ++- shell.nix | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 0bd4b23d..a2771d3c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ node_modules **/libs/AppFlowy-Collab/ data/ .env -.logs \ No newline at end of file +.logs +shell.nix diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 511d2a6d..00000000 --- a/shell.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - packages = with pkgs; [ - pkg-config rustup - grpc-tools openssl - ]; - shellHook = '' - export PROTOC=$(which protoc) - ''; -}