diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix index e5c81b95c..c3264ba02 100644 --- a/nix/dev-shell.nix +++ b/nix/dev-shell.nix @@ -1,122 +1,110 @@ { mkShell , stdenv , lib , amqp-cpp , arcanist , aws-sdk-cpp , better-prompt , boost , cargo , cmake , cmake-format , cocoapods , corrosion , cryptopp , darwin , double-conversion , folly , fmt , glog , grpc , gtest , libiconv , libuv , mariadb , nodejs-16_x , olm , openjdk8 , openssl , pkg-config , protobuf_3_15_cmake , python3 , rustc , shellcheck , sqlite , watchman , rustfmt , yarn }: mkShell { # programs which are meant to be executed should go here nativeBuildInputs = [ # generic development arcanist shellcheck # node development mariadb nodejs-16_x yarn watchman # react native python3 # native dependencies # C/CXX toolchains are already brought in with mkShell # Identity Service cargo # includes rustc rustc # allow for direct invocation of rustc rustfmt # Tunnelbroker + CMake amqp-cpp cryptopp cmake cmake-format # linting libuv pkg-config protobuf_3_15_cmake grpc ] ++ lib.optionals stdenv.isDarwin [ cocoapods # needed for ios ]; # include any libraries buildInputs buildInputs = [ # protobuf exposes both a library and a command # thus should appear in both inputs protobuf_3_15_cmake aws-sdk-cpp # tunnelbroker corrosion # tunnelbroker double-conversion # tunnelbroker glog # tunnelbroker gtest # testing services folly # cpp tools fmt # needed for folly boost # needed for folly olm # needed for CryptoTools sqlite # needed for sqlite_orm openssl # needed for grpc ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices Security libiconv # identity service ]); JAVA_HOME = openjdk8.passthru.home; # shell commands to be ran upon entering shell - shellHook = let - socket = "mysql.sock"; - in '' - if [[ "$OSTYPE" == 'linux'* ]]; then - export MYSQL_UNIX_PORT=''${XDG_RUNTIME_DIR:-/run/user/$UID}/${socket} - export ANDROID_SDK_ROOT=''${ANDROID_SDK_ROOT:-$HOME/Android/Sdk} - fi - - if [[ "$OSTYPE" == 'darwin'* ]]; then - # Many commands for cocoapods expect the native BSD versions of commands - export PATH=/usr/bin:$PATH - MARIADB_DIR=''${XDG_DATA_HOME:-$HOME/.local/share}/MariaDB - export MYSQL_UNIX_PORT="$MARIADB_DIR"/${socket} - export ANDROID_SDK_ROOT=''${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk} - fi + shellHook = '' + # Set development environment variable defaults + source "${../scripts/source_development_defaults.sh}" # Provide decent bash prompt source "${better-prompt}/bin/better-prompt" echo "Welcome to Comm dev environment! :)" ''; } diff --git a/scripts/source_development_defaults.sh b/scripts/source_development_defaults.sh new file mode 100644 index 000000000..fff9965a1 --- /dev/null +++ b/scripts/source_development_defaults.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [[ "$OSTYPE" == 'linux'* ]]; then + export MYSQL_UNIX_PORT=${XDG_RUNTIME_DIR:-/run/user/$UID}/mysql.sock + export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-$HOME/Android/Sdk} +fi + +if [[ "$OSTYPE" == 'darwin'* ]]; then + # Many commands for cocoapods expect the native BSD versions of commands + export PATH="/usr/bin:$PATH" + MARIADB_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/MariaDB + export MYSQL_UNIX_PORT="$MARIADB_DIR"/mysql.sock + export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk} +fi