diff --git a/Makefile b/Makefile index 4b69638572..7ae7bb1aa8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean clean-nix react-native test release _list +.PHONY: clean clean-nix react-native-android react-native-ios react-native-desktop test release _list help: ##@other Show this help @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST) @@ -81,7 +81,7 @@ release-windows-desktop: ##@build build release for desktop release @$(MAKE) prod-build-desktop && \ scripts/build-desktop.sh -release-desktop: export TARGET_OS ?= $(HOST_OS) +prod-build: export TARGET_OS ?= all prod-build: scripts/prepare-for-platform.sh android && \ scripts/prepare-for-platform.sh ios && \ @@ -89,18 +89,15 @@ prod-build: prod-build-android: export TARGET_OS ?= android prod-build-android: - scripts/prepare-for-platform.sh android && \ lein prod-build-android prod-build-ios: export TARGET_OS ?= ios prod-build-ios: - scripts/prepare-for-platform.sh ios && \ lein prod-build-ios -prod-build-android: export TARGET_OS ?= android +prod-build-desktop: export TARGET_OS ?= $(HOST_OS) prod-build-desktop: git clean -qdxf -f ./index.desktop.js desktop/ && \ - scripts/prepare-for-platform.sh desktop && \ lein prod-build-desktop #-------------- @@ -110,7 +107,6 @@ prod-build-desktop: _watch-%: ##@watch Start development for device $(eval SYSTEM := $(word 2, $(subst -, , $@))) $(eval DEVICE := $(word 3, $(subst -, , $@))) - scripts/prepare-for-platform.sh $(SYSTEM) clj -R:dev build.clj watch --platform $(SYSTEM) --$(SYSTEM)-device $(DEVICE) watch-ios-real: export TARGET_OS ?= ios @@ -130,12 +126,10 @@ watch-android-genymotion: _watch-android-genymotion ##@watch Start development f watch-desktop: export TARGET_OS ?= $(HOST_OS) watch-desktop: ##@watch Start development for Desktop - @scripts/prepare-for-platform.sh desktop && \ clj -R:dev build.clj watch --platform desktop desktop-server: export TARGET_OS ?= $(HOST_OS) desktop-server: - @scripts/prepare-for-platform.sh desktop && \ node ubuntu-server.js #-------------- @@ -143,12 +137,10 @@ desktop-server: # ------------- _run-%: $(eval SYSTEM := $(word 2, $(subst -, , $@))) - @scripts/prepare-for-platform.sh $(SYSTEM) && \ react-native run-$(SYSTEM) run-android: export TARGET_OS ?= android run-android: ##@run Run Android build - @scripts/prepare-for-platform.sh android && \ react-native run-android --appIdSuffix debug run-desktop: export TARGET_OS ?= $(HOST_OS) @@ -158,10 +150,8 @@ SIMULATOR= run-ios: export TARGET_OS ?= ios run-ios: ##@run Run iOS build ifneq ("$(SIMULATOR)", "") - @scripts/prepare-for-platform.sh ios && \ react-native run-ios --simulator="$(SIMULATOR)" else - @scripts/prepare-for-platform.sh ios && \ react-native run-ios endif @@ -178,8 +168,16 @@ test-auto: ##@test Run tests in interactive (auto) mode in NodeJS #-------------- # Other #-------------- -run-desktop: export TARGET_OS ?= $(HOST_OS) -react-native: ##@other Start react native packager +react-native-desktop: export TARGET_OS ?= $(HOST_OS) +react-native-desktop: ##@other Start react native packager + @scripts/start-react-native.sh + +react-native-android: export TARGET_OS ?= android +react-native-android: ##@other Start react native packager for Android client + @scripts/start-react-native.sh + +react-native-ios: export TARGET_OS ?= ios +react-native-ios: ##@other Start react native packager for Android client @scripts/start-react-native.sh geth-connect: export TARGET_OS ?= android @@ -211,7 +209,6 @@ _unknown-startdev-target-%: _startdev-%: $(eval SYSTEM := $(word 2, $(subst -, , $@))) $(eval DEVICE := $(word 3, $(subst -, , $@))) - scripts/prepare-for-platform.sh ${SYSTEM} || exit 1 @ if [ -z "$(DEVICE)" ]; then \ $(MAKE) watch-$(SYSTEM) || $(MAKE) _unknown-startdev-target-$@; \ else \ diff --git a/ci/common.groovy b/ci/common.groovy index 9cbdf520a1..999a21179c 100644 --- a/ci/common.groovy +++ b/ci/common.groovy @@ -77,7 +77,7 @@ def prep(type = 'nightly') { prepareTarget='desktop' } /* node deps, pods, and status-go download */ - utils.nix_sh "scripts/prepare-for-platform.sh ${prepareTarget}" + utils.nix_impure_sh "scripts/prepare-for-platform.sh ${prepareTarget}" } return this diff --git a/ci/desktop.groovy b/ci/desktop.groovy index 69b3c31d09..f79f3c084a 100644 --- a/ci/desktop.groovy +++ b/ci/desktop.groovy @@ -84,7 +84,7 @@ def bundleMacOS(type = 'nightly') { string(credentialsId: 'desktop-gpg-inner-pass', variable: 'GPG_PASS_INNER'), string(credentialsId: 'desktop-keychain-pass', variable: 'KEYCHAIN_PASS') ]) { - utils.nix_sh """ + utils.nix_impure_sh """ ../scripts/sign-macos-pkg.sh Status.app ../deployment/macos/macos-developer-id.keychain-db.gpg && \ ../node_modules/appdmg/bin/appdmg.js ../deployment/macos/status-dmg.json ${pkg} && \ ../scripts/sign-macos-pkg.sh ${pkg} ../deployment/macos/macos-developer-id.keychain-db.gpg diff --git a/ci/utils.groovy b/ci/utils.groovy index 7a1cf380c8..8b11433099 100644 --- a/ci/utils.groovy +++ b/ci/utils.groovy @@ -15,8 +15,16 @@ def getToolVersion(name) { return version } +def nix_impure_sh(cmd) { + _nix_sh(cmd, true) +} + def nix_sh(cmd) { - def isPure = env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios' && !cmd.contains('prepare-for-platform.sh') + _nix_sh(cmd, false) +} + +def _nix_sh(cmd, forceImpure) { + def isPure = !forceImpure && env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios' def pureFlag = isPure ? '--pure --keep LOCALE_ARCHIVE_2_27 --keep REALM_DISABLE_ANALYTICS --keep STATUS_RELEASE_STORE_FILE --keep STATUS_RELEASE_STORE_PASSWORD --keep STATUS_RELEASE_KEY_ALIAS --keep STATUS_RELEASE_KEY_PASSWORD --keep GPG_PASS_OUTER --keep GPG_PASS_INNER --keep KEYCHAIN_PASS --keep VERBOSE_LEVEL' : '' sh """ diff --git a/nix/shell.sh b/nix/shell.sh index e08c48ed3f..73cf36c769 100755 --- a/nix/shell.sh +++ b/nix/shell.sh @@ -13,7 +13,7 @@ shift # we remove the first -c from arguments if ! command -v "nix" >/dev/null 2>&1; then if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh - else + elif [ "$IN_NIX_SHELL" != 'pure' ]; then echo -e "${GREEN}Setting up environment...${NC}" ./scripts/setup @@ -22,8 +22,13 @@ if ! command -v "nix" >/dev/null 2>&1; then fi if command -v "nix" >/dev/null 2>&1; then + platform=${TARGET_OS:=all} + if [ "$platform" != 'all' ]; then + # This is a dirty workaround to the fact that 'yarn install' is an impure operation, so we need to call it from an impure shell. Hopefull we'll be able to fix this later on with something like yarn2nix + nix-shell --show-trace --argstr target-os ${TARGET_OS} --run "scripts/prepare-for-platform.sh $platform" + fi if [[ $@ == "ENTER_NIX_SHELL" ]]; then - echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}" + echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS}'...${NC}" exec nix-shell --show-trace --argstr target-os ${TARGET_OS} else is_pure='' @@ -31,7 +36,7 @@ if command -v "nix" >/dev/null 2>&1; then is_pure='--pure' pure_desc='pure ' fi - echo -e "${GREEN}Configuring ${pure_desc}Nix shell for target '${TARGET_OS:=all}'...${NC}" + echo -e "${GREEN}Configuring ${pure_desc}Nix shell for target '${TARGET_OS}'...${NC}" exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@" fi fi diff --git a/scripts/lib/setup/platform.sh b/scripts/lib/setup/platform.sh index 9933ee3f04..6a7981d011 100755 --- a/scripts/lib/setup/platform.sh +++ b/scripts/lib/setup/platform.sh @@ -15,6 +15,14 @@ function is_nixos() { } function exit_unless_os_supported() { + if [ "$IN_NIX_SHELL" == 'pure' ]; then + cecho "@red[[This install script is not supported in a pure Nix shell]] + + echo + + exit 1 + fi + if ! is_macos && ! is_linux; then cecho "@red[[This install script currently supports Mac OS X and Linux \ via apt. To manually install, please visit the docs for more information:]] diff --git a/scripts/prepare-for-platform.sh b/scripts/prepare-for-platform.sh index 4dda5c7cc3..77e14d1f40 100755 --- a/scripts/prepare-for-platform.sh +++ b/scripts/prepare-for-platform.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +################################################################################################### +# +# Impure setup (any setup here should be minimized and instead be moved to Nix for a pure setup) +# +################################################################################################### + set -e GIT_ROOT=$(git rev-parse --show-toplevel) @@ -16,7 +22,7 @@ RCTSTATUS_DIR="$GIT_ROOT/modules/react-native-status/ios/RCTStatus" #if no arguments passed, inform user about possible ones if [ $# -eq 0 ]; then - echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios', or 'desktop'${NC}" + echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios', 'desktop', 'windows', 'linux', 'macos' or 'darwin'${NC}" echo "If invoked with 'android' argument it will link: " echo "mobile_files/package.json.orig -> package.json" echo "etc.." @@ -26,6 +32,9 @@ else android | ios) PLATFORM='mobile' ;; + windows | linux | macos | darwin) + PLATFORM='desktop' + ;; *) PLATFORM=$1 ;; diff --git a/scripts/setup b/scripts/setup index 31fadcdd60..7521ce5864 100755 --- a/scripts/setup +++ b/scripts/setup @@ -3,6 +3,7 @@ ######################################################################## # This install script will setup your development dependencies on OS X # or Ubuntu. Ubuntu 18.04 is the only tested version. +# It is not required or supported in NixOS. # # Usage: scripts/setup ######################################################################## diff --git a/shell.nix b/shell.nix index 46a318be71..40eb330745 100644 --- a/shell.nix +++ b/shell.nix @@ -43,7 +43,7 @@ in mkShell' { ${projectDeps.shellHook} ${lib.optionalString useFastlanePkg fastlane'.shellHook} - if [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then + if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then $STATUS_REACT_HOME/scripts/setup touch $STATUS_REACT_HOME/.ran-setup fi