diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix index 3da0b4320..5d5993a60 100644 --- a/nix/dev-shell.nix +++ b/nix/dev-shell.nix @@ -1,159 +1,161 @@ { mkShell , stdenv , lib , awscli2 , arcanist , better-prompt , boost , bundler , c-ares_cmake-config , cargo-lambda , cargo-udeps , cmake , cmake-format , cocoapods , corrosion , darwin , double-conversion , emscripten , folly , fmt , glog , grpc , libiconv , libuv , localstack , mariadb , mariadb-up , nodejs , olm , openjdk11 , openssl , pkg-config , protobuf3_21 , python3 , rabbitmq-server , redis , redis-up , rustup , shellcheck , sops , sqlite , terraform , rustfmt , wasm-pack , yarn , protoc-gen-grpc-web }: mkShell { # programs which are meant to be executed should go here nativeBuildInputs = [ # generic development or tools arcanist awscli2 shellcheck sops terraform emscripten # android openjdk11 # node development mariadb nodejs yarn python3 redis wasm-pack protoc-gen-grpc-web # native dependencies # C/CXX toolchains are already brought in with mkShell # Identity Service rustfmt rustup cargo-lambda cargo-udeps # Tunnelbroker + CMake c-ares_cmake-config cmake cmake-format # linting libuv localstack pkg-config protobuf3_21 grpc rabbitmq-server # runtime service ] ++ lib.optionals stdenv.isDarwin [ cocoapods # needed for ios bundler ]; # include any libraries buildInputs buildInputs = [ # protobuf exposes both a library and a command # thus should appear in both inputs protobuf3_21 corrosion # tunnelbroker double-conversion # tunnelbroker glog # tunnelbroker folly # cpp tools fmt # needed for folly boost # needed for folly olm # needed for CryptoTools sqlite # needed for sqlite database openssl # needed for grpc ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices Security # required until https://github.com/seanmonstar/reqwest/issues/2006 is resolved SystemConfiguration libiconv # identity service ]); JAVA_HOME = openjdk11.passthru.home; # shell commands to be ran upon entering shell shellHook = '' PRJ_ROOT=$(git rev-parse --show-toplevel) # Set development environment variable defaults source "${../scripts/source_development_defaults.sh}" # Cache development path for some use cases such as XCode "$PRJ_ROOT/scripts/save_path.sh" '' # Darwin condition can be removed once linux services are supported + lib.optionalString stdenv.isDarwin '' # Start MariaDB development services "${mariadb-up}"/bin/mariadb-up & mariadb_pid=$! "${redis-up}"/bin/redis-up & redis_pid=$! wait "$mariadb_pid" "$redis_pid" ${../scripts}/install_homebrew_macos.sh ${../scripts}/install_homebrew_deps.sh watchman '' + '' # Render default configuration for keyserver $PRJ_ROOT/scripts/create_url_facts.sh # Ensure rustup tooling is installed $PRJ_ROOT/scripts/ensure_rustup_setup.sh # Provide decent bash prompt source "${better-prompt}/bin/better-prompt" + $PRJ_ROOT/scripts/set-up-authoritative-keyserver.sh + echo "Welcome to Comm dev environment! :)" ''; } diff --git a/scripts/set-up-authoritative-keyserver.sh b/scripts/set-up-authoritative-keyserver.sh index 0dba91652..e6e50812c 100755 --- a/scripts/set-up-authoritative-keyserver.sh +++ b/scripts/set-up-authoritative-keyserver.sh @@ -1,48 +1,52 @@ #!/usr/bin/env bash PRJ_ROOT="$(git rev-parse --show-toplevel)" user_credentials_file="$PRJ_ROOT/keyserver/secrets/user_credentials.json" set_up_or_abort() { - read -r -p "Do you want to set up a new authoritative keyserver? (y/N) " user_input + read -t 60 -r -p "Do you want to set up a new authoritative keyserver? (y/N) " user_input if [[ $user_input != "Y" && $user_input != "y" ]]; then exit 1 fi if ! (mysql -u "$USER" -Bse "USE comm;" 2>/dev/null); then echo "Database comm doesn't exist. Please re-enter 'nix develop'" exit 1 fi num_of_tables=$(mysql -u "$USER" -Bse "USE comm; SHOW TABLES;" | wc -l); if [[ "$num_of_tables" -gt 0 ]]; then # Create backup db and move all tables from comm timestamp=$(date +%s) db_version_name="comm_backup$timestamp" echo "backup db name: $db_version_name" mysql -u "$USER" -Bse "CREATE DATABASE $db_version_name;"\ -Bse "GRANT ALL ON $db_version_name"'.*'" TO comm@localhost;" for table in $(mysql -u "$USER" -Bse "USE comm; SHOW TABLES FROM comm;"); do mysql -u "$USER" -Bse "USE comm; RENAME TABLE comm.$table TO $db_version_name.$table;"; done; fi node "$PRJ_ROOT"/scripts/set-user-credentials.js "$PRJ_ROOT" } +if [[ -n "$BUILDKITE" || -n "$GITHUB_ACTIONS" ]]; then + exit +fi + if grep -q '"usingIdentityCredentials":.*true' "$user_credentials_file"; then if ! (mysql -u "$USER" -Bse "USE comm; SELECT * FROM metadata" 2>/dev/null | grep "db_version">/dev/null); then echo -e "'usingIdentityCredentials' is set to true, but the database is not set up.\n" \ "This was likely caused by the keyserver failing to login with the provided credentials,"\ "or the keyserver never being run" set_up_or_abort fi else echo "'usingIdentityCredentials' is missing or set to false in user_credentials.json." set_up_or_abort fi