major nix refactor

Changes:
- Adds a new `nix-gc` Makefile target for removing old packages
- Moves all `nix/*.sh` files to `nix/scripts/*.sh` to make things more tidy
- Renames `TARGET_OS` into `TARGET` and makes it effective only with `nix/scripts/shell.sh`
- Renames `target-os` Nix argument to just `target` and makes it effective only with `shell.nix`
- Drops `IN_CI_ENVIRONMENT` env variable which was useless
- Drops use of `target-os` argument outside of `shell.nix` (with few exceptions, but just in naming)
- `nix/platform.nix` has been made obsolete and removed
- Moves the definition of all major targets to `nix/targets.nix`
- Moves the definition of all major shells to `nix/shells.nix`
- Makes `default.nix` and `shell.nix` just thin wrappers around `nix/default.nix`
- `nix/nixpkgs-bootstrap.nix` has been moved to `nix/pkgs.nix`
- All package and tool overrides have been moved to `nix/pkgs.nix`
- Explicit passing of contents of `pkgs` has been removed in favor of `callPackage` doing it for us
- `nix/bootstrapped-shell.nix` has been moved to `nix/tools/mkShell.nix`
- A new `mergeSh` tool has been added to `pkgs` from `nix/tools/mergeSh.nix`
  - This tool is used to merge shells created using `mkShell`
- `mobile/targets/jsbundle.nix` has been moved to `mobile/android/jsbundle/default.nix`
- Moves `status-go` version sanitization to `nix/status-go/utils.nix`
- Renames version to rawVersion and versionName to cleanVersion in status-go derivation
- Ports nix/mobile/ios/install-pods-and-status-go.sh to Nix sub-shells
- Moves adjustment of `inotify/max_user_watches` out into `scripts/inotify_fix.sh`
- Makes iOS builds use the Nix version of Fastlane

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-11-29 11:20:08 +01:00
parent b471f53cb3
commit aca703a011
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
61 changed files with 845 additions and 834 deletions

112
Makefile
View File

@ -42,6 +42,10 @@ export NIX_CONF_DIR = $(PWD)/nix
# Defines which variables will be kept for Nix pure shell, use semicolon as divider
export _NIX_KEEP ?= TMPDIR,BUILD_ENV,STATUS_GO_SRC_OVERRIDE
export _NIX_ROOT = /nix
# legacy TARGET_OS variable support
ifdef TARGET_OS
export TARGET ?= $(TARGET_OS)
endif
# MacOS root is read-only, read nix/README.md for details
UNAME_S := $(shell uname -s)
@ -58,7 +62,7 @@ endif
ifdef IN_NIX_SHELL
SHELL := env bash
else
SHELL := ./nix/shell.sh
SHELL := ./nix/scripts/shell.sh
endif
shell: ##@prepare Enter into a pre-configured shell
@ -68,30 +72,32 @@ else
@echo "${YELLOW}Nix shell is already active$(RESET)"
endif
nix-gc: ##@nix Garbage collect all packages older than 20 days from /nix/store
nix-collect-garbage --delete-old --delete-older-than 20d
nix-clean: ##@nix Remove all status-react build artifacts from /nix/store
nix/clean.sh
nix/scripts/clean.sh
nix-purge: SHELL := /bin/sh
nix-purge: ##@nix Completely remove the complete Nix setup
sudo rm -rf $(_NIX_ROOT) ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
sudo rm -rf $(_NIX_ROOT)/* ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
nix-add-gcroots: export TARGET_OS := none
nix-add-gcroots: export TARGET := default
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
scripts/add-nix-gcroots.sh
nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup
nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh
nix-update-lein: export TARGET_OS := none
nix-update-lein: export TARGET := lein
nix-update-lein: ##@nix Update maven nix expressions based on current lein setup
nix/tools/lein/generate-nix.sh nix/lein
nix-update-gems: export TARGET_OS := none
nix-update-gems: export _NIX_ATTR := targets.leiningen.shell
nix-update-gems: export TARGET := lein
nix-update-gems: ##@nix Update Ruby gems in fastlane/Gemfile.lock and fastlane/gemset.nix
fastlane/update.sh
nix-update-pods: export TARGET_OS := ios
nix-update-pods: export TARGET := ios
nix-update-pods: ##@nix Update CocoaPods in ios/Podfile.lock
cd ios && pod update
@ -118,7 +124,7 @@ clean: SHELL := /bin/sh
clean: _fix-node-perms _tmpdir-rm ##@prepare Remove all output folders
git clean -dxf
watchman-clean: export _NIX_ATTR := targets.watchman.shell
watchman-clean: export TARGET := watchman
watchman-clean: ##@prepare Delete repo directory from watchman
watchman watch-del $${STATUS_REACT_HOME}
@ -130,7 +136,7 @@ disable-githooks: ##@prepare Disables lein githooks
-e 's|:pre-commit|;; :pre-commit|' project.clj; \
rm project.clj~
pod-install: export TARGET_OS := ios
pod-install: export TARGET := ios
pod-install: ##@prepare Run 'pod install' to install podfiles and update Podfile.lock
cd ios && pod install; cd --
@ -139,7 +145,7 @@ pod-install: ##@prepare Run 'pod install' to install podfiles and update Podfile
#----------------
release: release-android release-ios ##@build build release for Android and iOS
release-android: export TARGET_OS ?= android
release-android: export TARGET ?= android
release-android: export BUILD_ENV ?= prod
release-android: export BUILD_TYPE ?= nightly
release-android: export BUILD_NUMBER ?= 9999
@ -149,7 +155,7 @@ release-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86
release-android: ##@build build release for Android
scripts/release-android.sh
release-ios: export TARGET_OS ?= ios
release-ios: export TARGET ?= ios
release-ios: export BUILD_ENV ?= prod
release-ios: watchman-clean ##@build build release for iOS release
@git clean -dxf -f target/ios && \
@ -157,14 +163,14 @@ release-ios: watchman-clean ##@build build release for iOS release
scripts/copy-translations.sh && \
xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration Release -destination 'generic/platform=iOS' -UseModernBuildSystem=N clean archive
release-desktop: export TARGET_OS ?= $(HOST_OS)
release-desktop: ##@build build release for desktop release based on TARGET_OS
release-desktop: export TARGET ?= $(HOST_OS)
release-desktop: ##@build build release for desktop release based on TARGET
@$(MAKE) jsbundle-desktop && \
scripts/copy-translations.sh && \
scripts/build-desktop.sh; \
$(MAKE) watchman-clean
release-windows-desktop: export TARGET_OS ?= windows
release-windows-desktop: export TARGET ?= windows
release-windows-desktop: ##@build build release for windows desktop release
@$(MAKE) jsbundle-desktop && \
scripts/copy-translations.sh && \
@ -175,28 +181,28 @@ prod-build-android: jsbundle-android ##@legacy temporary legacy alias for jsbund
@echo "${YELLOW}This a deprecated target name, use jsbundle-android.$(RESET)"
jsbundle-android: SHELL := /bin/sh
jsbundle-android: export TARGET_OS ?= android
jsbundle-android: export TARGET ?= android
jsbundle-android: export BUILD_ENV ?= prod
jsbundle-android: ##@jsbundle Compile JavaScript and Clojure into index.android.js
# Call nix-build to build the 'targets.mobile.jsbundle' attribute and copy the index.android.js file to the project root
@git clean -dxf ./index.$(TARGET_OS).js
nix/build.sh targets.mobile.jsbundle && \
mv result/index.$(TARGET_OS).js ./
# Call nix-build to build the 'targets.mobile.android.jsbundle' attribute and copy the index.android.js file to the project root
@git clean -dxf ./index.$(TARGET).js
nix/scripts/build.sh targets.mobile.android.jsbundle && \
mv result/index.$(TARGET).js ./
prod-build-ios: jsbundle-ios ##@legacy temporary legacy alias for jsbundle-ios
@echo "${YELLOW}This a deprecated target name, use jsbundle-ios.$(RESET)"
jsbundle-ios: export TARGET_OS ?= ios
jsbundle-ios: export TARGET ?= ios
jsbundle-ios: export BUILD_ENV ?= prod
jsbundle-ios: ##@jsbundle Compile JavaScript and Clojure into index.ios.js
@git clean -dxf -f ./index.$(TARGET_OS).js && \
@git clean -dxf -f ./index.$(TARGET).js && \
lein jsbundle-ios && \
node prepare-modules.js
prod-build-desktop: jsbundle-desktop ##@legacy temporary legacy alias for jsbundle-desktop
@echo "${YELLOW}This a deprecated target name, use jsbundle-desktop.$(RESET)"
jsbundle-desktop: export TARGET_OS ?= $(HOST_OS)
jsbundle-desktop: export TARGET ?= $(HOST_OS)
jsbundle-desktop: export BUILD_ENV ?= prod
jsbundle-desktop: ##@jsbundle Compile JavaScript and Clojure into index.desktop.js
git clean -qdxf -f ./index.desktop.js desktop/ && \
@ -212,26 +218,26 @@ _watch-%: ##@watch Start development for device
$(eval DEVICE := $(word 3, $(subst -, , $@)))
clj -R:dev build.clj watch --platform $(SYSTEM) --$(SYSTEM)-device $(DEVICE)
watch-ios-real: export TARGET_OS ?= ios
watch-ios-real: export TARGET := ios
watch-ios-real: _watch-ios-real ##@watch Start development for iOS real device
watch-ios-simulator: export TARGET_OS ?= ios
watch-ios-simulator: export TARGET := ios
watch-ios-simulator: _watch-ios-simulator ##@watch Start development for iOS simulator
watch-android-real: export TARGET_OS ?= android
watch-android-real: export TARGET := android
watch-android-real: _watch-android-real ##@watch Start development for Android real device
watch-android-avd: export TARGET_OS ?= android
watch-android-avd: export TARGET := android
watch-android-avd: _watch-android-avd ##@watch Start development for Android AVD
watch-android-genymotion: export TARGET_OS ?= android
watch-android-genymotion: export TARGET ?= android
watch-android-genymotion: _watch-android-genymotion ##@watch Start development for Android Genymotion
watch-desktop: export TARGET_OS ?= $(HOST_OS)
watch-desktop: export TARGET ?= $(HOST_OS)
watch-desktop: ##@watch Start development for Desktop
clj -R:dev build.clj watch --platform desktop
desktop-server: export TARGET_OS ?= $(HOST_OS)
desktop-server: export TARGET ?= $(HOST_OS)
desktop-server:
node ubuntu-server.js
@ -243,15 +249,15 @@ _run-%:
npx react-native run-$(SYSTEM)
# TODO: Migrate this to a Nix recipe, much the same way as nix/mobile/android/targets/release-android.nix
run-android: export TARGET_OS ?= android
run-android: export TARGET := android
run-android: ##@run Run Android build
npx react-native run-android --appIdSuffix debug
run-desktop: export TARGET_OS ?= $(HOST_OS)
run-desktop: export TARGET ?= $(HOST_OS)
run-desktop: _run-desktop ##@run Run Desktop build
SIMULATOR=
run-ios: export TARGET_OS ?= ios
run-ios: export TARGET := ios
run-ios: ##@run Run iOS build
ifneq ("$(SIMULATOR)", "")
npx react-native run-ios --simulator="$(SIMULATOR)"
@ -263,15 +269,15 @@ endif
# Tests
#--------------
lint: export _NIX_ATTR := targets.leiningen.shell
lint: export TARGET := lein
lint: ##@test Run code style checks
lein cljfmt check
test: export _NIX_ATTR := targets.leiningen.shell
test: export TARGET := lein
test: ##@test Run tests once in NodeJS
lein with-profile test doo node test once
test-auto: export _NIX_ATTR := targets.leiningen.shell
test-auto: export TARGET := lein
test-auto: ##@test Run tests in interactive (auto) mode in NodeJS
lein with-profile test doo node test
@ -281,52 +287,46 @@ coverage: ##@test Run tests once in NodeJS generating coverage
#--------------
# Other
#--------------
react-native-desktop: export TARGET_OS ?= $(HOST_OS)
react-native-desktop: export TARGET ?= $(HOST_OS)
react-native-desktop: export _NIX_PURE ?= true
react-native-desktop: ##@other Start react native packager
@scripts/start-react-native.sh
react-native-android: export TARGET_OS ?= android
react-native-android: export TARGET := android
react-native-android: export _NIX_PURE ?= true
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: export TARGET := ios
react-native-ios: export _NIX_PURE ?= true
react-native-ios: ##@other Start react native packager for Android client
@scripts/start-react-native.sh
geth-connect: export _NIX_ATTR := targets.mobile.android.adb.shell
geth-connect: export TARGET_OS ?= android
geth-connect: export TARGET := adb
geth-connect: ##@other Connect to Geth on the device
adb forward tcp:8545 tcp:8545 && \
build/bin/geth attach http://localhost:8545
android-clean: export TARGET_OS ?= android
android-clean: ##@prepare Clean Gradle state
git clean -dxf -f ./android/app/build
[ -d android/.gradle ] && cd android && ./gradlew clean
android-ports: export _NIX_ATTR := targets.mobile.android.adb.shell
android-ports: export TARGET_OS ?= android
android-ports: export TARGET := adb
android-ports: ##@other Add proxies to Android Device/Simulator
adb reverse tcp:8081 tcp:8081 && \
adb reverse tcp:3449 tcp:3449 && \
adb reverse tcp:4567 tcp:4567 && \
adb forward tcp:5561 tcp:5561
android-devices: export _NIX_ATTR := targets.mobile.android.adb.shell
android-devices: export TARGET_OS ?= android
android-devices: export TARGET := adb
android-devices: ##@other Invoke adb devices
adb devices
android-logcat: export _NIX_ATTR := targets.mobile.android.adb.shell
android-logcat: export TARGET_OS ?= android
android-logcat: export TARGET := adb
android-logcat: ##@other Read status-react logs from Android phone using adb
adb logcat | grep -e RNBootstrap -e ReactNativeJS -e ReactNative -e StatusModule -e StatusNativeLogs -e 'F DEBUG :' -e 'Go :' -e 'GoLog :' -e 'libc :'
android-install: export _NIX_ATTR := targets.mobile.android.adb.shell
android-install: export TARGET_OS ?= android
android-install: export TARGET := adb
android-install: export BUILD_TYPE ?= release
android-install:
adb install result/app-$(BUILD_TYPE).apk
@ -351,15 +351,15 @@ _startdev-%:
$(MAKE) watch-$(SYSTEM)-$(DEVICE) || $(MAKE) _unknown-startdev-target-$@; \
fi
startdev-android-avd: export TARGET_OS = android
startdev-android-avd: export TARGET = android
startdev-android-avd: _startdev-android-avd
startdev-android-genymotion: export TARGET_OS = android
startdev-android-genymotion: export TARGET = android
startdev-android-genymotion: _startdev-android-genymotion
startdev-android-real: export TARGET_OS = android
startdev-android-real: export TARGET = android
startdev-android-real: _startdev-android-real
startdev-desktop: export TARGET_OS ?= $(HOST_OS)
startdev-desktop: export TARGET ?= $(HOST_OS)
startdev-desktop: _startdev-desktop
startdev-ios-real: export TARGET_OS = ios
startdev-ios-real: export TARGET = ios
startdev-ios-real: _startdev-ios-real
startdev-ios-simulator: export TARGET_OS = ios
startdev-ios-simulator: export TARGET = ios
startdev-ios-simulator: _startdev-ios-simulator

View File

@ -98,4 +98,4 @@ System's local adb and Nix's adb differ. As adb include of server/client process
## Solution
Always use respective `make` commands, e.g. `make android-ports`, `make android-devices`, etc.
Alternatively, run adb commands only from `TARGET_OS=android make shell` shell. Don't forget the `TARGET_OS=android` env var setting - otherwise adb will still be selected from the system's default location. You can double-check this by running `which adb`.
Alternatively, run adb commands only from `make shell TARGET=android` shell. Don't forget the `TARGET=android` env var setting - otherwise `adb` will still be selected from the system's default location. You can double-check this by running `which adb`.

View File

@ -25,7 +25,7 @@ pipeline {
LANG = "en_US.UTF-8"
LC_ALL = "en_US.UTF-8"
LANGUAGE = "en_US.UTF-8"
TARGET_OS = 'android'
TARGET = 'android'
BUILD_ENV = 'prod'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
FASTLANE_DISABLE_COLORS = 1
@ -58,7 +58,7 @@ pipeline {
/* Build implicit dependencies if needed (we run `lein deps :tree` but it's not really required, for this purpose)
Implicit dependencies include building a patched node_modules, fetching maven dependencies, and anything else required.
We do this before the parallel steps so we have a known starting situation. */
script { cmn.nix.shell('lein deps :tree', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein deps :tree', attr: 'shells.lein') }
}
}
stage('Parallel Assemble') {
@ -66,12 +66,12 @@ pipeline {
stage('Checks') { stages {
stage('Lint') {
steps {
script { cmn.nix.shell('lein cljfmt check', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein cljfmt check', attr: 'shells.lein') }
}
}
stage('Tests') {
steps {
script { cmn.nix.shell('lein test-cljs', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein test-cljs', attr: 'shells.lein') }
}
}
} }

View File

@ -5,7 +5,7 @@ pipeline {
LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8'
TARGET_OS = 'ios'
TARGET = 'ios'
FASTLANE_DISABLE_COLORS = 1
/* See nix/README.md */
NIX_IGNORE_SYMLINK_STORE = 1
@ -29,7 +29,7 @@ pipeline {
nix = load('ci/nix.groovy')
nix.shell(
'bundle install --gemfile=fastlane/Gemfile',
attr: 'targets.mobile.fastlane.shell'
attr: 'shells.fastlane'
)
} }
}
@ -44,8 +44,8 @@ pipeline {
]) {
nix.shell(
'bundle exec --gemfile=fastlane/Gemfile fastlane ios clean',
attr: 'targets.mobile.fastlane.shell',
keep: ['FASTLANE_APPLE_ID', 'FASTLANE_PASSWORD']
attr: 'shells.fastlane',
)
}
} }

View File

@ -25,7 +25,7 @@ pipeline {
LANG = "en_US.UTF-8"
LC_ALL = "en_US.UTF-8"
LANGUAGE = "en_US.UTF-8"
TARGET_OS = 'ios'
TARGET = 'ios'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
/* See nix/README.md */
NIX_IGNORE_SYMLINK_STORE = 1
@ -55,12 +55,12 @@ pipeline {
stage('Checks') { stages {
stage('Lint') {
steps {
script { cmn.nix.shell('lein cljfmt check', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein cljfmt check', attr: 'shells.lein') }
}
}
stage('Tests') {
steps {
script { cmn.nix.shell('lein test-cljs', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein test-cljs', attr: 'shells.lein') }
}
}
} }

View File

@ -29,7 +29,7 @@ pipeline {
LANG = "en_US.UTF-8"
LC_ALL = "en_US.UTF-8"
LANGUAGE = "en_US.UTF-8"
TARGET_OS = 'linux'
TARGET = 'linux'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
VERBOSE_LEVEL = '3'
/* We use EXECUTOR_NUMBER to avoid multiple instances clashing */
@ -58,12 +58,12 @@ pipeline {
stage('Checks') { stages {
stage('Lint') {
steps {
script { cmn.nix.shell('lein cljfmt check', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein cljfmt check', attr: 'shells.lein') }
}
}
stage('Tests') {
steps {
script { cmn.nix.shell('lein test-cljs', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein test-cljs', attr: 'shells.lein') }
}
}
} }

View File

@ -25,7 +25,7 @@ pipeline {
LANG = "en_US.UTF-8"
LC_ALL = "en_US.UTF-8"
LANGUAGE = "en_US.UTF-8"
TARGET_OS = 'macos'
TARGET = 'macos'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
/* See nix/README.md */
NIX_IGNORE_SYMLINK_STORE = 1
@ -56,12 +56,12 @@ pipeline {
stage('Checks') { stages {
stage('Lint') {
steps {
script { cmn.nix.shell('lein cljfmt check', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein cljfmt check', attr: 'shells.lein') }
}
}
stage('Tests') {
steps {
script { cmn.nix.shell('lein test-cljs', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein test-cljs', attr: 'shells.lein') }
}
}
} }

View File

@ -32,16 +32,20 @@ pipeline {
}
stage('Setup') {
steps { script {
sh 'scripts/setup'
nix.shell('nix-env -i openssh', pure: false)
/* some build targets don't build on MacOS */
uname = sh(script: 'uname', returnStdout: true)
} }
}
stage('Build status-go') {
steps { script {
['android', 'desktop', 'ios'].each { os ->
def platforms = ['android', 'desktop', 'ios']
if (uname != "Darwin") {
platforms.removeAll { it == "ios" }
}
platforms.each { os ->
nix.build(
attr: "targets.status-go.${os}.buildInputs",
args: ['target-os': 'all'],
link: false
)
}
@ -52,8 +56,7 @@ pipeline {
/* build/fetch things required to produce a js-bundle for android
* (e.g. maven and node repos) */
nix.build(
attr: 'targets.mobile.jsbundle',
args: ['target-os': 'android'],
attr: 'targets.mobile.android.jsbundle',
pure: false,
link: false
)
@ -64,7 +67,6 @@ pipeline {
/* build/fetch things required to build jsbundle and android */
nix.build(
attr: 'targets.mobile.android.buildInputs',
args: ['target-os': 'android'],
pure: false,
link: false
)
@ -72,10 +74,9 @@ pipeline {
}
stage('Build nix shell deps') {
steps { script {
/* build/fetch things required to instantiate shell.nix for TARGET_OS=all */
/* build/fetch things required to instantiate shell.nix for TARGET=all */
nix.build(
attr: 'shell',
args: ['target-os': 'all'],
attr: 'shells.default.buildInputs',
link: false
)
} }
@ -97,7 +98,7 @@ pipeline {
post {
always { script {
nix.shell('nix-store --optimize', pure: false)
nix.shell('nix/clean.sh', pure: false)
nix.shell('nix/scripts/clean.sh', pure: false)
} }
}
}

View File

@ -29,7 +29,7 @@ pipeline {
LANG = "en_US.UTF-8"
LC_ALL = "en_US.UTF-8"
LANGUAGE = "en_US.UTF-8"
TARGET_OS = 'windows'
TARGET = 'windows'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
VERBOSE_LEVEL = '3'
/* Conan settings */
@ -61,12 +61,12 @@ pipeline {
stage('Checks') { stages {
stage('Lint') {
steps {
script { cmn.nix.shell('lein cljfmt check', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein cljfmt check', attr: 'shells.lein') }
}
}
stage('Tests') {
steps {
script { cmn.nix.shell('lein test-cljs', attr: 'targets.leiningen.shell') }
script { cmn.nix.shell('lein test-cljs', attr: 'shells.lein') }
}
}
} }

View File

@ -107,8 +107,8 @@ def uploadToPlayStore(type = 'nightly') {
]) {
nix.shell(
"fastlane android ${type}",
attr: 'targets.mobile.fastlane.shell',
keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'GOOGLE_PLAY_JSON_KEY']
keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'GOOGLE_PLAY_JSON_KEY'],
attr: 'shells.fastlane'
)
}
}
@ -130,11 +130,11 @@ def uploadToSauceLabs() {
]) {
nix.shell(
'fastlane android saucelabs',
attr: 'targets.mobile.fastlane.shell',
keep: [
'FASTLANE_DISABLE_COLORS', 'APK_PATHS',
'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME', 'SAUCE_LABS_NAME'
],
attr: 'shells.fastlane',
pure: false
)
}
@ -147,8 +147,8 @@ def uploadToDiawi() {
]) {
nix.shell(
'fastlane android upload_diawi',
attr: 'targets.mobile.fastlane.shell',
keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'DIAWI_TOKEN'],
attr: 'shells.fastlane',
pure: false
)
}

View File

@ -43,28 +43,26 @@ def prep(type = 'nightly') {
/* pick right .env and update from params */
utils.updateEnv(type)
if (env.TARGET_OS == 'android' || env.TARGET_OS == 'ios') {
if (['android', 'ios'].contains(env.TARGET)) {
/* Run at start to void mismatched numbers */
utils.genBuildNumber()
}
nix.shell('watchman watch-del-all', attr: 'targets.watchman.shell')
nix.shell('watchman watch-del-all', attr: 'shells.watchman')
if (env.TARGET_OS == 'ios') {
if (env.TARGET == 'ios') {
/* install ruby dependencies */
nix.shell(
'bundle install --gemfile=fastlane/Gemfile --quiet',
attr: 'targets.mobile.fastlane.shell')
attr: 'shells.fastlane')
}
if (env.TARGET_OS == 'macos' || env.TARGET_OS == 'linux' || env.TARGET_OS == 'windows') {
if (['macos', 'linux', 'windows'].contains(env.TARGET)) {
/* node deps, pods, and status-go download */
nix.shell('scripts/prepare-for-desktop-platform.sh', pure: false)
sh('scripts/copy-translations.sh')
} else if (env.TARGET_OS != 'android') {
// run script in the nix shell so that node_modules gets instantiated before attempting the copies
nix.shell('scripts/copy-translations.sh chmod')
}
/* run script in the nix shell so that node_modules gets instantiated before attempting the copies */
nix.shell('scripts/copy-translations.sh chmod', attr: "shells.${env.TARGET}")
}
def uploadArtifact(path) {

View File

@ -11,7 +11,7 @@ utils = load 'ci/utils.groovy'
def buildObj(success) {
def pkg_url = env.PKG_URL
/* a bare ipa file is not installable on iOS */
if (env.TARGET_OS == 'ios') {
if (env.TARGET == 'ios') {
pkg_url = env.DIAWI_URL
}
/* assemble build object valid for ghcmgr */
@ -19,7 +19,7 @@ def buildObj(success) {
id: env.BUILD_DISPLAY_NAME,
commit: GIT_COMMIT.take(8),
success: success != null ? success : true,
platform: env.TARGET_OS + (utils.getBuildType() == 'e2e' ? '-e2e' : ''),
platform: env.TARGET + (utils.getBuildType() == 'e2e' ? '-e2e' : ''),
duration: utils.buildDuration(),
url: currentBuild.absoluteUrl,
pkg_url: pkg_url,

View File

@ -63,7 +63,7 @@ def notifyPRSuccess() {
def type = ghcmgr.utils.getBuildType() == 'e2e' ? ' e2e' : ''
msg += "[${env.JOB_NAME}${currentBuild.displayName}](${currentBuild.absoluteUrl}) ${d} "
msg += "${ghcmgr.utils.buildDuration()} ${d} ${GIT_COMMIT.take(8)} ${d} "
msg += "[:package: ${env.TARGET_OS}${type} package](${env.PKG_URL})"
msg += "[:package: ${env.TARGET}${type} package](${env.PKG_URL})"
notify(msg)
}

View File

@ -17,9 +17,9 @@ def bundle() {
default: target = 'nightly';
}
/* configure build metadata */
nix.shell(plutil('CFBundleShortVersionString', utils.getVersion()), attr: 'targets.mobile.ios.shell')
nix.shell(plutil('CFBundleVersion', utils.genBuildNumber()), attr: 'targets.mobile.ios.shell')
nix.shell(plutil('CFBundleBuildUrl', currentBuild.absoluteUrl), attr: 'targets.mobile.ios.shell')
nix.shell(plutil('CFBundleShortVersionString', utils.getVersion()), attr: 'shells.ios')
nix.shell(plutil('CFBundleVersion', utils.genBuildNumber()), attr: 'shells.ios')
nix.shell(plutil('CFBundleBuildUrl', currentBuild.absoluteUrl), attr: 'shells.ios')
/* the dir might not exist */
sh 'mkdir -p status-e2e'
/* build the actual app */
@ -38,7 +38,8 @@ def bundle() {
'FASTLANE_DISABLE_COLORS',
'FASTLANE_PASSWORD', 'KEYCHAIN_PASSWORD',
'MATCH_PASSWORD', 'FASTLANE_APPLE_ID',
]
],
attr: 'shells.ios'
)
}
/* rename built file for uploads and archivization */
@ -64,8 +65,8 @@ def uploadToDiawi() {
]) {
nix.shell(
'bundle exec --gemfile=fastlane/Gemfile fastlane ios upload_diawi',
attr: 'targets.mobile.fastlane.shell',
keep: ['FASTLANE_DISABLE_COLORS', 'DIAWI_TOKEN']
keep: ['FASTLANE_DISABLE_COLORS', 'DIAWI_TOKEN'],
attr: 'shells.fastlane'
)
}
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
@ -90,8 +91,8 @@ def uploadToSauceLabs() {
]) {
nix.shell(
'bundle exec --gemfile=fastlane/Gemfile fastlane ios saucelabs',
attr: 'targets.mobile.fastlane.shell',
keep: ['FASTLANE_DISABLE_COLORS', 'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME']
keep: ['FASTLANE_DISABLE_COLORS', 'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME'],
attr: 'shells.fastlane'
)
}
return env.SAUCE_LABS_NAME

View File

@ -7,22 +7,21 @@
def shell(Map opts = [:], String cmd) {
def defaults = [
pure: true,
args: ['target-os': env.TARGET_OS ? env.TARGET_OS : 'none'],
keep: ['LOCALE_ARCHIVE_2_27', 'IN_CI_ENVIRONMENT'],
args: ['target': env.TARGET ? env.TARGET : 'default'],
keep: ['LOCALE_ARCHIVE_2_27'],
]
/* merge defaults with received opts */
opts = defaults + opts
/* previous merge overwrites the array */
opts.keep = (opts.keep + defaults.keep).unique()
/* not all targets can use a pure build */
if (env.TARGET_OS in ['windows', 'ios']) {
if (env.TARGET in ['windows', 'ios']) {
opts.pure = false
}
sh("""
set +x
. ~/.nix-profile/etc/profile.d/nix.sh
set -x
IN_CI_ENVIRONMENT=1 \\
nix-shell --run \'${cmd}\' ${_getNixCommandArgs(opts, true)}
""")
}
@ -38,13 +37,11 @@ def shell(Map opts = [:], String cmd) {
* - safeEnv - Name of env variables to pass securely through to Nix build (they won't get captured in Nix derivation file)
**/
def build(Map opts = [:]) {
env.IN_CI_ENVIRONMENT = '1'
def defaults = [
pure: true,
link: true,
args: ['target-os': env.TARGET_OS],
keep: ['IN_CI_ENVIRONMENT'],
args: ['target': env.TARGET],
keep: [],
attr: null,
sbox: [],
safeEnv: [],
@ -140,7 +137,7 @@ private def _getNixCommandArgs(Map opts = [:], boolean isShell) {
}
def prepEnv() {
if (env.TARGET_OS in ['linux', 'windows', 'android']) {
if (env.TARGET in ['linux', 'windows', 'android']) {
def glibcLocales = sh(
returnStdout: true,
script: """

View File

@ -1,16 +1,9 @@
# target-os = [ 'windows' 'linux' 'macos' 'darwin' 'android' 'ios' 'all' ]
{ config ? { },
nixpkgs-bootstrap ? import ./nix/nixpkgs-bootstrap.nix { inherit config; },
pkgs ? nixpkgs-bootstrap.pkgs,
stdenv ? pkgs.stdenv,
target-os ? "none" }:
let deriv = pkgs.callPackage ./nix/derivation.nix { inherit pkgs target-os; inherit (nixpkgs-bootstrap) config; };
{
config ? { }, # for passing status_go.src_override
}:
let
main = import ./nix/default.nix { inherit config; };
in {
targets = {
inherit (deriv) mobile leiningen watchman status-go;
};
inherit (deriv) shell;
inherit (main) pkgs targets shells;
}

View File

@ -1,14 +1,14 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- FBLazyVector (0.61.0)
- FBReactNativeSpec (0.61.0):
- FBLazyVector (0.61.5)
- FBReactNativeSpec (0.61.5):
- Folly (= 2018.10.22.00)
- RCTRequired (= 0.61.0)
- RCTTypeSafety (= 0.61.0)
- React-Core (= 0.61.0)
- React-jsi (= 0.61.0)
- ReactCommon/turbomodule/core (= 0.61.0)
- RCTRequired (= 0.61.5)
- RCTTypeSafety (= 0.61.5)
- React-Core (= 0.61.5)
- React-jsi (= 0.61.5)
- ReactCommon/turbomodule/core (= 0.61.5)
- Folly (2018.10.22.00):
- boost-for-react-native
- DoubleConversion
@ -20,169 +20,169 @@ PODS:
- glog
- glog (0.3.5)
- QBImagePickerController (3.4.0)
- RCTRequired (0.61.0)
- RCTTypeSafety (0.61.0):
- FBLazyVector (= 0.61.0)
- RCTRequired (0.61.5)
- RCTTypeSafety (0.61.5):
- FBLazyVector (= 0.61.5)
- Folly (= 2018.10.22.00)
- RCTRequired (= 0.61.0)
- React-Core (= 0.61.0)
- React (0.61.0):
- React-Core (= 0.61.0)
- React-Core/DevSupport (= 0.61.0)
- React-Core/RCTWebSocket (= 0.61.0)
- React-RCTActionSheet (= 0.61.0)
- React-RCTAnimation (= 0.61.0)
- React-RCTBlob (= 0.61.0)
- React-RCTImage (= 0.61.0)
- React-RCTLinking (= 0.61.0)
- React-RCTNetwork (= 0.61.0)
- React-RCTSettings (= 0.61.0)
- React-RCTText (= 0.61.0)
- React-RCTVibration (= 0.61.0)
- React-Core (0.61.0):
- RCTRequired (= 0.61.5)
- React-Core (= 0.61.5)
- React (0.61.5):
- React-Core (= 0.61.5)
- React-Core/DevSupport (= 0.61.5)
- React-Core/RCTWebSocket (= 0.61.5)
- React-RCTActionSheet (= 0.61.5)
- React-RCTAnimation (= 0.61.5)
- React-RCTBlob (= 0.61.5)
- React-RCTImage (= 0.61.5)
- React-RCTLinking (= 0.61.5)
- React-RCTNetwork (= 0.61.5)
- React-RCTSettings (= 0.61.5)
- React-RCTText (= 0.61.5)
- React-RCTVibration (= 0.61.5)
- React-Core (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default (= 0.61.0)
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-Core/Default (= 0.61.5)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/CoreModulesHeaders (0.61.0):
- React-Core/CoreModulesHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/Default (0.61.0):
- React-Core/Default (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/DevSupport (0.61.0):
- React-Core/DevSupport (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default (= 0.61.0)
- React-Core/RCTWebSocket (= 0.61.0)
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-jsinspector (= 0.61.0)
- React-Core/Default (= 0.61.5)
- React-Core/RCTWebSocket (= 0.61.5)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- React-jsinspector (= 0.61.5)
- Yoga
- React-Core/RCTActionSheetHeaders (0.61.0):
- React-Core/RCTActionSheetHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTAnimationHeaders (0.61.0):
- React-Core/RCTAnimationHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTBlobHeaders (0.61.0):
- React-Core/RCTBlobHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTImageHeaders (0.61.0):
- React-Core/RCTImageHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTLinkingHeaders (0.61.0):
- React-Core/RCTLinkingHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTNetworkHeaders (0.61.0):
- React-Core/RCTNetworkHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTSettingsHeaders (0.61.0):
- React-Core/RCTSettingsHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTTextHeaders (0.61.0):
- React-Core/RCTTextHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTVibrationHeaders (0.61.0):
- React-Core/RCTVibrationHeaders (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-Core/RCTWebSocket (0.61.0):
- React-Core/RCTWebSocket (0.61.5):
- Folly (= 2018.10.22.00)
- glog
- React-Core/Default (= 0.61.0)
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsiexecutor (= 0.61.0)
- React-Core/Default (= 0.61.5)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsiexecutor (= 0.61.5)
- Yoga
- React-CoreModules (0.61.0):
- FBReactNativeSpec (= 0.61.0)
- React-CoreModules (0.61.5):
- FBReactNativeSpec (= 0.61.5)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.61.0)
- React-Core/CoreModulesHeaders (= 0.61.0)
- React-RCTImage (= 0.61.0)
- ReactCommon/turbomodule/core (= 0.61.0)
- React-cxxreact (0.61.0):
- RCTTypeSafety (= 0.61.5)
- React-Core/CoreModulesHeaders (= 0.61.5)
- React-RCTImage (= 0.61.5)
- ReactCommon/turbomodule/core (= 0.61.5)
- React-cxxreact (0.61.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsinspector (= 0.61.0)
- React-jsi (0.61.0):
- React-jsinspector (= 0.61.5)
- React-jsi (0.61.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsi/Default (= 0.61.0)
- React-jsi/Default (0.61.0):
- React-jsi/Default (= 0.61.5)
- React-jsi/Default (0.61.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsiexecutor (0.61.0):
- React-jsiexecutor (0.61.5):
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- React-jsinspector (0.61.0)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsinspector (0.61.5)
- react-native-background-timer (2.1.1):
- React
- react-native-camera (3.6.0):
@ -209,41 +209,41 @@ PODS:
- React
- react-native-webview-bridge (0.33.17):
- React
- React-RCTActionSheet (0.61.0):
- React-Core/RCTActionSheetHeaders (= 0.61.0)
- React-RCTAnimation (0.61.0):
- React-Core/RCTAnimationHeaders (= 0.61.0)
- React-RCTBlob (0.61.0):
- React-Core/RCTBlobHeaders (= 0.61.0)
- React-Core/RCTWebSocket (= 0.61.0)
- React-jsi (= 0.61.0)
- React-RCTNetwork (= 0.61.0)
- React-RCTImage (0.61.0):
- React-Core/RCTImageHeaders (= 0.61.0)
- React-RCTNetwork (= 0.61.0)
- React-RCTLinking (0.61.0):
- React-Core/RCTLinkingHeaders (= 0.61.0)
- React-RCTNetwork (0.61.0):
- React-Core/RCTNetworkHeaders (= 0.61.0)
- React-RCTSettings (0.61.0):
- React-Core/RCTSettingsHeaders (= 0.61.0)
- React-RCTText (0.61.0):
- React-Core/RCTTextHeaders (= 0.61.0)
- React-RCTVibration (0.61.0):
- React-Core/RCTVibrationHeaders (= 0.61.0)
- ReactCommon/jscallinvoker (0.61.0):
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
- React-RCTAnimation (0.61.5):
- React-Core/RCTAnimationHeaders (= 0.61.5)
- React-RCTBlob (0.61.5):
- React-Core/RCTBlobHeaders (= 0.61.5)
- React-Core/RCTWebSocket (= 0.61.5)
- React-jsi (= 0.61.5)
- React-RCTNetwork (= 0.61.5)
- React-RCTImage (0.61.5):
- React-Core/RCTImageHeaders (= 0.61.5)
- React-RCTNetwork (= 0.61.5)
- React-RCTLinking (0.61.5):
- React-Core/RCTLinkingHeaders (= 0.61.5)
- React-RCTNetwork (0.61.5):
- React-Core/RCTNetworkHeaders (= 0.61.5)
- React-RCTSettings (0.61.5):
- React-Core/RCTSettingsHeaders (= 0.61.5)
- React-RCTText (0.61.5):
- React-Core/RCTTextHeaders (= 0.61.5)
- React-RCTVibration (0.61.5):
- React-Core/RCTVibrationHeaders (= 0.61.5)
- ReactCommon/jscallinvoker (0.61.5):
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-cxxreact (= 0.61.0)
- ReactCommon/turbomodule/core (0.61.0):
- React-cxxreact (= 0.61.5)
- ReactCommon/turbomodule/core (0.61.5):
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-Core (= 0.61.0)
- React-cxxreact (= 0.61.0)
- React-jsi (= 0.61.0)
- ReactCommon/jscallinvoker (= 0.61.0)
- React-Core (= 0.61.5)
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- ReactCommon/jscallinvoker (= 0.61.5)
- RNFS (2.14.1):
- React
- RNGestureHandler (1.4.1):
@ -323,7 +323,7 @@ DEPENDENCIES:
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
https://github.com/CocoaPods/Specs.git:
- boost-for-react-native
- QBImagePickerController
- RSKImageCropper
@ -421,53 +421,53 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
FBLazyVector: cb37b5590a27600f0a889222d7c1f019625f4168
FBReactNativeSpec: 6fda0eee5b059ee8ea0f845f4060620ff96b5b55
FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f
FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 353a32027a69db3807b94c7cbc2900fc4370098c
QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022
RCTRequired: 81db8debffc2eb932841fa02dcf5a2e911af74c1
RCTTypeSafety: 39a7d8643abe2460aef0adeb9acbe9401b579fff
React: 89f2294058332cf7c4feee644e17d5024da1f531
React-Core: c55956aa434fae94816b665f99d51d50f48d5993
React-CoreModules: c70b9db4f48e31474bb022716fff41983b335ce2
React-cxxreact: 1dbe583c02d15d269f13451d203e645bb233fc96
React-jsi: f9126dd5818fbd8fbf869be9bbc1c0543973e1a1
React-jsiexecutor: 752f034d0f007d1141a1c52ba9ef3fd9668fbfa7
React-jsinspector: 044105eea064aec81adc5e4d777a8f6589e7d094
react-native-background-timer: bb7a98c8e97fc7c290de2d423dd09ddb73dcbcbb
react-native-camera: 9c50d7def800895e7991ccda6203929553ceec9c
react-native-image-resizer: 04a3409e7d4ad646c4468671c69dec490def139c
react-native-mail: ff4aba592530d80ac96eea6c1ca03114b84d630a
react-native-netinfo: a91b5cf92ed3ada997cfe2bf067633386eb19fd8
react-native-safe-area-context: 686e5d98bb021d8ca415ec5cf2a30dfc0d7d0d93
react-native-shake: e9d1368d6f0ec7e48c8afc91e379b81006b9ba42
react-native-splash-screen: a49be22f0f6648b8416f3bd28258645eeaa5b42b
react-native-webview: ad9581723f4d401c22cb3a371811d4dc9310df56
react-native-webview-bridge: c712d20bbe7e2a2fabdd5d8ccdfec5e704455763
React-RCTActionSheet: 49433f6e3659ba5d3ee650e44b9c18743ef9a7fc
React-RCTAnimation: 12f86a4e3542032329366b03bca2cc254a7c64a9
React-RCTBlob: ba90a4144ad478a022b79a4e8a1f150548d39425
React-RCTImage: f652d97e49f4b0f26c7df336e723a0d259179967
React-RCTLinking: e738422857085a1c40c57505a25920160d365783
React-RCTNetwork: d0d635ad07deed0c05a1b1499d1ab4ce5c41ac97
React-RCTSettings: ae6f8b64ee5c5e4fc629f5109042e122fd0fd14b
React-RCTText: 3f24042210886ee8c02613758013010be04b291e
React-RCTVibration: d55e1365be416980217914fe009e9d55dec02e03
ReactCommon: eb96b70a2a5bed775e919151fd77699fed52944c
RNFS: 6a2bfb5d0b14cf0ad72667f76202358abba4aacf
RNGestureHandler: 311e3b1cef021a7c9ef31e97e7dc31970cc6288d
RNImageCropPicker: c406db73f02f11bf3a887f856ff04ee50af173f4
RNKeychain: 627c6095cef215dd3d9804a9a9cf45ab96aa3997
RNLanguages: e3ae05ef105937645218272429dac0c3f7633451
RNScreens: 354046589421edc3d83d5c6212475bf1fb9a731d
RNSVG: 2e097b92aaa6d4e0f354fd7c49cbf3b17f8b3920
RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1
RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320
React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78
React-Core: 688b451f7d616cc1134ac95295b593d1b5158a04
React-CoreModules: d04f8494c1a328b69ec11db9d1137d667f916dcb
React-cxxreact: d0f7bcafa196ae410e5300736b424455e7fb7ba7
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b
react-native-camera: b6a6a61bcdbd619c19df3df581fcb009131938bf
react-native-image-resizer: 4516052af6ae0248caf4ccf356caecefe60072d7
react-native-mail: 7e37dfbe93ff0d4c7df346b738854dbed533e86f
react-native-netinfo: 6bb847e64f45a2d69c6173741111cfd95c669301
react-native-safe-area-context: d288138da2c800caa111f9352e9333f186a06ead
react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
react-native-webview: 0658813bcc4b6c22f3cbb035a2227aa896a8cbc0
react-native-webview-bridge: 3023f6b0e84cdf8e4a96511d2b04e73b038f95f0
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
React-RCTImage: 6b8e8df449eb7c814c99a92d6b52de6fe39dea4e
React-RCTLinking: 121bb231c7503cf9094f4d8461b96a130fabf4a5
React-RCTNetwork: fb353640aafcee84ca8b78957297bd395f065c9a
React-RCTSettings: 8db258ea2a5efee381fcf7a6d5044e2f8b68b640
React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe
React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
RNFS: a8fbe7060fa49157d819466404794ad9c58e58cf
RNGestureHandler: 4cb47a93019c1a201df2644413a0a1569a51c8aa
RNImageCropPicker: bfb3ea9c8622f290532e2fe63f369e0d5a52f597
RNKeychain: 216f37338fcb9e5c3a2530f1e3295f737a690cb1
RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e
RNScreens: f28b48b8345f2f5f39ed6195518291515032a788
RNSVG: be27aa7c58819f97399388ae53d7fa0572f32c7f
RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a
SQLCipher: f9fcf29b2e59ced7defc2a2bdd0ebe79b40d4990
SSZipArchive: fa16b8cc4cdeceb698e5e5d9f67e9558532fbf23
TouchID: b0640fedb86fa2db2fe1df15b61594ad49e76288
Yoga: 6af72bedeaea291a3a3717772d6d41836f23a1b9
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
PODFILE CHECKSUM: e8a3c84ad33b072f07411f663eebeba6d10436ee
PODFILE CHECKSUM: 0483a7693bfa7c6ef9f214cdc7f614f67dec7448
COCOAPODS: 1.5.3
COCOAPODS: 1.8.4

View File

@ -527,7 +527,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm-resources.sh",
"${PODS_ROOT}/Target Support Files/Pods-StatusIm/Pods-StatusIm-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/QBImagePickerController/QBImagePicker.bundle",
"${PODS_ROOT}/RSKImageCropper/RSKImageCropper/RSKImageCropperStrings.bundle",
);
@ -538,7 +538,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm-resources.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-StatusIm/Pods-StatusIm-resources.sh\"\n";
showEnvVarsInLog = 0;
};
2EAC54E16AB243C3EBBFE1BA /* [CP] Check Pods Manifest.lock */ = {

View File

@ -12,17 +12,17 @@ __NOTE:__ If you are in Asia you might want to add the `https://nix-cache-cn.sta
In order to access an interactive Nix shell a user should run `make shell`.
The Nix shell is started in this repo via the [`nix/shell.sh`](/nix/shell.sh) script, which is a wrapper around the `nix-shell` command and is intended for use with our main [`Makefile`](/Makefile). This allows for an implicit use of `nix-shell` as the default shell in the `Makefile`.
The Nix shell is started in this repo via the [`nix/scripts/shell.sh`](/nix/scripts/shell.sh) script, which is a wrapper around the `nix-shell` command and is intended for use with our main [`Makefile`](/Makefile). This allows for an implicit use of `nix-shell` as the default shell in the `Makefile`.
By default the shell starts without any specific target platform, if you want to change that you should export the `TARGET_OS` env variable with the right value:
Normally the shell starts without any specific target platform, if you want to change that you should export the `TARGET` env variable with appropriate value:
```bash
make shell TARGET_OS=android
make shell TARGET=android
```
This way your shell and all other nix commands should run in a setup that is tailored towards Android development.
For valid values you can check the [`nix/platform.nix`](/nix/platform.nix) file.
For valid values you can check the [`nix/shells.nix`](/nix/shells.nix) file.
## Using a local status-go repository

View File

@ -1,32 +0,0 @@
#
# This Nix expression appends/modifies an existing attribute set in order to run scripts/setup if needed,
# as well as define STATUS_REACT_HOME
#
{ stdenv, mkShell, target-os, git }:
# Declare a specialized mkShell function which adds some bootstrapping
# so that e.g. STATUS_REACT_HOME is automatically available in the shell
attrs:
(mkShell.override({ inherit stdenv; }) attrs)
.overrideAttrs(super: {
nativeBuildInputs = (super.nativeBuildInputs or [ ]) ++ [ git ];
TARGET_OS = target-os;
shellHook = ''
set -e
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export STATUS_REACT_HOME=$(git rev-parse --show-toplevel)
${super.shellHook or ""}
if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
$STATUS_REACT_HOME/scripts/setup
touch $STATUS_REACT_HOME/.ran-setup
fi
set +e
'';
})

12
nix/default.nix Normal file
View File

@ -0,0 +1,12 @@
{
config ? {},
pkgs ? import ./pkgs.nix { inherit config; }
}:
let
# put all main targets and shells together for easy import
shells = pkgs.callPackage ./shells.nix { };
targets = pkgs.callPackage ./targets.nix { };
in {
inherit pkgs targets shells;
}

View File

@ -1,78 +0,0 @@
{ system ? builtins.currentSystem
, config ? { android_sdk.accept_license = true; }, overlays ? []
, pkgs ? (import <nixpkgs> { inherit system config overlays; })
, target-os }:
let
inherit (stdenv) isDarwin;
inherit (stdenv.lib) catAttrs concatStrings optional unique;
platform = pkgs.callPackage ./platform.nix { inherit target-os; };
# Declare a specialized mkShell function which adds some bootstrapping
# so that e.g. STATUS_REACT_HOME is automatically available in the shell
mkShell = (import ./bootstrapped-shell.nix {
inherit stdenv target-os;
inherit (pkgs) mkShell git;
});
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
stdenv = pkgs.stdenvNoCC;
maven = pkgs.maven;
baseGo = pkgs.go_1_13;
go = pkgs.callPackage ./patched-go { inherit baseGo; };
buildGoPackage = pkgs.buildGoPackage.override { inherit go; };
desktop = pkgs.callPackage ./desktop { inherit target-os stdenv status-go pkgs go nodejs; inherit (pkgs) darwin; };
mobile = pkgs.callPackage ./mobile { inherit target-os config stdenv pkgs mkShell nodejs yarn status-go maven localMavenRepoBuilder mkFilter; inherit (pkgs.xcodeenv) composeXcodeWrapper; };
status-go = pkgs.callPackage ./status-go { inherit target-os config go buildGoPackage mkFilter; inherit (mobile.ios) xcodeWrapper; androidPkgs = mobile.android.androidComposition; };
# mkFilter is a function that allows filtering a directory structure (used for filtering source files being captured in a closure)
mkFilter = import ./tools/mkFilter.nix { inherit (stdenv) lib; };
localMavenRepoBuilder =
pkgs.callPackage ./tools/maven/maven-repo-builder.nix {
inherit (pkgs) stdenv;
};
nodejs = pkgs.nodejs-10_x;
yarn = pkgs.yarn.override { inherit nodejs; };
selectedSources =
optional platform.targetDesktop desktop ++
optional platform.targetMobile mobile;
# TARGETS
leiningen-shell = mkShell {
buildInputs = with pkgs; [
clojure leiningen flock maven nodejs openjdk
] ++ optional isDarwin pkgs.cocoapods;
shellHook =
if target-os == "android" then mobile.android.shellHook else
if target-os == "ios" then mobile.ios.shellHook else "";
};
watchman-shell = mkShell {
buildInputs = with pkgs; [ watchman ];
};
in {
# CHILD DERIVATIONS
inherit mobile status-go;
# TARGETS
leiningen = {
shell = leiningen-shell;
};
watchman = {
shell = watchman-shell;
};
shell = {
buildInputs = unique ([
yarn
nodejs
pkgs.python27 # for e.g. gyp
] ++ optional isDarwin pkgs.cocoapods
++ optional (isDarwin && !platform.targetIOS) pkgs.clang
++ optional (!isDarwin) pkgs.gcc8
++ catAttrs "buildInputs" selectedSources);
shellHook = ''
export PATH="$STATUS_REACT_HOME/node_modules/.bin:$PATH"
${concatStrings (catAttrs "shellHook" selectedSources)}
'';
};
}

View File

@ -1,23 +1,26 @@
{ stdenv, pkgs, callPackage, target-os,
cmake, extra-cmake-modules, file, moreutils, status-go, go,
darwin, nodejs }:
{ stdenv, mkShell, callPackage, status-go,
cmake, extra-cmake-modules, file, moreutils, go, darwin, nodejs }:
let
inherit (stdenv.lib) catAttrs concatStrings optional unique;
platform = callPackage ../platform.nix { inherit target-os; };
baseImageFactory = callPackage ./base-image { inherit stdenv; };
linuxPlatform = callPackage ./linux { inherit stdenv status-go baseImageFactory; };
darwinPlatform = callPackage ./macos { inherit stdenv status-go darwin baseImageFactory pkgs; };
windowsPlatform = callPackage ./windows { inherit stdenv go baseImageFactory; };
snoreNotifySources = callPackage ./cmake/snorenotify { };
qtkeychainSources = callPackage ./cmake/qtkeychain { };
selectedSources =
optional platform.targetLinux linuxPlatform ++
optional platform.targetDarwin darwinPlatform ++
optional platform.targetWindows windowsPlatform;
in {
# main targets
linux = callPackage ./linux { inherit stdenv status-go baseImageFactory; };
macos = callPackage ./macos { inherit stdenv status-go darwin baseImageFactory; };
windows = callPackage ./windows { inherit stdenv go baseImageFactory; };
selectedSources =
optional stdenv.isLinux linux ++
optional stdenv.isLinux windows ++
optional stdenv.isDarwin macos;
in rec {
inherit linux macos windows;
buildInputs = unique ([
cmake
extra-cmake-modules
@ -27,5 +30,10 @@ in {
qtkeychainSources
] ++ catAttrs "buildInputs" selectedSources);
shellHook = concatStrings (catAttrs "shellHook" (selectedSources ++ [ snoreNotifySources qtkeychainSources ]));
shell = mkShell {
inherit buildInputs;
shellHook = concatStrings (catAttrs "shellHook" (
selectedSources ++ [ snoreNotifySources qtkeychainSources ]
));
};
}

View File

@ -1,4 +1,4 @@
{ stdenv, callPackage,
{ stdenv, mkShell, callPackage,
appimagekit, patchelf, qt5, status-go, baseImageFactory }:
with stdenv;
@ -11,7 +11,7 @@ let
appimagekit = callPackage ./appimagekit { };
linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; };
in {
in rec {
buildInputs = [
appimagekit
linuxdeployqt
@ -19,10 +19,12 @@ in {
qt5.full
] ++ status-go.buildInputs;
shellHook =
concatStrings (catAttrs "shellHook" [ baseImage status-go ] ) + ''
shell = mkShell {
inherit buildInputs;
shellHook = concatStrings (catAttrs "shellHook" [ baseImage status-go ]) + ''
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${qt5.full}/bin:$PATH"
'';
};
}

View File

@ -1,17 +1,16 @@
{ stdenv, callPackage, pkgs,
darwin, qt5, status-go, baseImageFactory }:
{ stdenv, lib, callPackage, mkShell,
gnupg22, darwin, qt5, status-go, baseImageFactory }:
with darwin.apple_sdk.frameworks;
assert stdenv.isDarwin;
let
inherit (stdenv.lib) concatStrings catAttrs;
inherit (lib) concatStrings catAttrs;
baseImage = baseImageFactory "macos";
in {
in rec {
buildInputs = [
pkgs.gnupg22
gnupg22
baseImage
qt5.full
AppKit
@ -21,11 +20,13 @@ in {
OpenGL
] ++ status-go.buildInputs;
shellHook =
concatStrings (catAttrs "shellHook" [ baseImage status-go ] ) + ''
shell = mkShell {
inherit buildInputs;
shellHook = baseImage.shellHook + ''
export NIX_TARGET_LDFLAGS="-F${CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_TARGET_LDFLAGS"
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${qt5.full}/bin:$PATH"
'';
};
}

View File

@ -1,12 +1,11 @@
{ stdenv, callPackage,
conan, nsis, go, baseImageFactory }:
{ stdenv, mkShell, conan, nsis, go, baseImageFactory }:
assert stdenv.isLinux;
let
baseImage = baseImageFactory "windows";
in {
in rec {
buildInputs = stdenv.lib.optionals stdenv.isLinux [
conan
nsis
@ -14,8 +13,11 @@ in {
go # Needed for Windows build only
];
shellHook = ''
${baseImage.shellHook}
unset QT_PATH
'';
shell = mkShell {
inherit buildInputs;
shellHook = ''
${baseImage.shellHook}
unset QT_PATH
'';
};
}

View File

@ -2,12 +2,9 @@
# This Nix expression centralizes the configuration for the Android development environment
#
{ stdenv, config, target-os, callPackage,
androidenv, openjdk }:
{ stdenv, config, callPackage, androidenv, openjdk, mkShell }:
let
platform = callPackage ../../platform.nix { inherit target-os; };
androidComposition = androidenv.composeAndroidPackages {
toolsVersion = "26.1.1";
platformToolsVersion = "29.0.5";
@ -29,25 +26,25 @@ let
licensedAndroidEnv = stdenv.mkDerivation rec {
name = "licensed-android-sdk";
version = "licensed";
phases = [ "installPhase" ];
phases = [ "installPhase" "licensePhase" ];
installPhase = ''
mkdir -p $out/libexec/android-sdk
ln -s "${androidComposition.androidsdk}/bin" $out/bin
for d in ${androidComposition.androidsdk}/libexec/android-sdk/*; do
ln -s $d $out/$(basename $d)
done
${stdenv.lib.optionalString config.android_sdk.accept_license ''
'';
licensePhase = stdenv.lib.optionalString config.android_sdk.accept_license ''
mkdir -p $out/licenses
echo -e "\n601085b94cd77f0b54ff86406957099ebe79c4d6" > "$out/licenses/android-googletv-license"
echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$out/licenses/android-sdk-license"
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$out/licenses/android-sdk-preview-license"
echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "$out/licenses/intel-android-extra-license"
echo -e "\n33b6a2b64607f11b759f320ef9dff4ae5c47d97a" > "$out/licenses/google-gdk-license"
''}
'';
};
shellHook = assert platform.targetAndroid;
''
shell = mkShell {
shellHook = ''
export JAVA_HOME="${openjdk}"
export ANDROID_HOME="${licensedAndroidEnv}"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
@ -56,7 +53,9 @@ let
export ANDROID_NDK="$ANDROID_NDK_ROOT"
export PATH="$ANDROID_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools:$PATH"
'';
};
in {
inherit androidComposition licensedAndroidEnv shellHook;
drv = licensedAndroidEnv;
inherit androidComposition shell;
}

View File

@ -1,49 +1,64 @@
{ config, stdenv, stdenvNoCC, target-os ? "android", callPackage, mkShell,
mkFilter, androidenv, fetchurl, flock, openjdk, nodejs, bash, maven, zlib,
status-go, localMavenRepoBuilder, projectNodePackage, jsbundle }:
{ config, lib, callPackage, mkShell, mergeSh, androidenv, flock, openjdk,
status-go, localMavenRepoBuilder, projectNodePackage }:
let
platform = callPackage ../../platform.nix { inherit target-os; };
androidEnv = callPackage ./android-env.nix { inherit target-os openjdk; };
gradle = callPackage ./gradle.nix { };
androidEnv = callPackage ./android-env.nix { };
leinProjectDeps = import ../../lein/lein-project-deps.nix { };
# Import a jsbundle compiled out of clojure codebase
jsbundle = callPackage ./jsbundle/default.nix {
inherit leinProjectDeps localMavenRepoBuilder projectNodePackage;
};
# Import a patched version of watchman (important for sandboxed builds on macOS)
watchmanFactory = callPackage ./watchman.nix { };
# Import a local patched version of node_modules, together with a local version of the Maven repo
mavenAndNpmDeps = callPackage ./maven-and-npm-deps { inherit stdenv stdenvNoCC gradle bash nodejs zlib localMavenRepoBuilder mkFilter projectNodePackage; };
mavenAndNpmDeps = callPackage ./maven-and-npm-deps {
inherit gradle localMavenRepoBuilder projectNodePackage;
};
# TARGETS
release = callPackage ./targets/release-android.nix { inherit target-os config gradle mavenAndNpmDeps mkFilter nodejs jsbundle status-go zlib watchmanFactory; androidEnvShellHook = androidEnv.shellHook; };
generate-maven-and-npm-deps-shell = callPackage ./maven-and-npm-deps/maven/shell.nix { inherit mkShell gradle maven nodejs projectNodePackage status-go; androidEnvShellHook = androidEnv.shellHook; };
adb-shell = mkShell {
buildInputs = [ androidEnv.licensedAndroidEnv ];
inherit (androidEnv) shellHook;
release = callPackage ./targets/release-android.nix {
inherit config gradle mavenAndNpmDeps jsbundle status-go watchmanFactory;
androidEnvShellHook = androidEnv.shell.shellHook;
};
generate-maven-and-npm-deps-shell = callPackage ./maven-and-npm-deps/maven/shell.nix {
inherit gradle projectNodePackage status-go;
androidEnvShellHook = androidEnv.shell.shellHook;
};
buildInputs = [
mavenAndNpmDeps.drv openjdk gradle
flock # used in reset-node_modules.sh
];
in {
# TARGETS
inherit release jsbundle generate-maven-and-npm-deps-shell buildInputs;
inherit (androidEnv) androidComposition;
buildInputs = assert platform.targetAndroid; [
mavenAndNpmDeps.deriv
flock # used in reset-node_modules.sh
openjdk
gradle
];
shellHook =
let
inherit (stdenv.lib) catAttrs concatStrings;
in ''
${concatStrings (catAttrs "shellHook" [ mavenAndNpmDeps androidEnv ])}
shell = mergeSh
(mkShell {
inherit buildInputs;
inputsFrom = [ release gradle ];
shellHook = ''
pushd "$STATUS_REACT_HOME" > /dev/null
{
./scripts/generate-keystore.sh
# check if node modules changed and if so install them
./nix/mobile/reset-node_modules.sh "${mavenAndNpmDeps.drv}/project"
}
'';
})
(lib.catAttrs "shell" [ status-go mavenAndNpmDeps androidEnv ]);
$STATUS_REACT_HOME/scripts/generate-keystore.sh
$STATUS_REACT_HOME/nix/mobile/reset-node_modules.sh "${mavenAndNpmDeps.deriv}/project" || exit
'';
# TARGETS
inherit release generate-maven-and-npm-deps-shell;
adb = {
shell = adb-shell;
shell = mkShell {
buildInputs = [ androidEnv.drv ];
inherit (androidEnv.shell) shellHook;
};
};
}

View File

@ -2,18 +2,18 @@
# This Nix expression builds an index.*.js file for the current repository given a node modules Nix expression
#
{ stdenv, stdenvNoCC, lib, target-os, callPackage, pkgs,
mkFilter, clojure, leiningen, maven, nodejs, localMavenRepoBuilder, projectNodePackage }:
{ target-os ? "android",
stdenv, mkFilter, clojure, leiningen, nodejs,
leinProjectDeps, localMavenRepoBuilder, projectNodePackage }:
let
lein-command = if target-os == "all" then "lein jsbundle" else "lein jsbundle-${target-os}";
lein-project-deps = import ../lein/lein-project-deps.nix { };
leinProjectDepsLocalRepo = localMavenRepoBuilder "lein-project-deps" lein-project-deps;
leinProjectDepsLocalRepo = localMavenRepoBuilder "lein-project-deps" leinProjectDeps;
in stdenv.mkDerivation {
name = "status-react-build-jsbundle-${target-os}";
src =
let path = ./../..;
let path = ./../../../..;
in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control
inherit path;
name = "status-react-source-jsbundle";

View File

@ -3,15 +3,15 @@
# as well as a local version of the Maven repository required by Gradle scripts
#
{ stdenv, stdenvNoCC, lib, callPackage,
{ stdenv, lib, callPackage, mkShell,
gradle, bash, file, nodejs, zlib,
projectNodePackage, localMavenRepoBuilder, mkFilter }:
let
mavenLocalRepo = callPackage ./maven { inherit localMavenRepoBuilder; stdenv = if stdenv.isLinux then stdenv else stdenvNoCC; };
mavenLocalRepo = callPackage ./maven { inherit localMavenRepoBuilder stdenv; };
# Import the native dependencies for React Native Android builds
react-native-deps = callPackage ./maven/reactnative-android-native-deps.nix { inherit stdenvNoCC; };
react-native-deps = callPackage ./maven/reactnative-android-native-deps.nix { };
createMobileFilesSymlinks = root: ''
ln -sf ${root}/mobile/js_files/package.json ${root}/package.json
@ -190,11 +190,12 @@ let
};
in {
deriv = deps;
drv = deps;
shell = mkShell {
shellHook = ''
${createMobileFilesSymlinks "$STATUS_REACT_HOME"}
shellHook = ''
${createMobileFilesSymlinks "$STATUS_REACT_HOME"}
export STATUSREACT_NIX_MAVEN_REPO="${deps}/.m2/repository"
'';
export STATUSREACT_NIX_MAVEN_REPO="${deps}/.m2/repository"
'';
};
}

View File

@ -21,7 +21,7 @@ inputs2nix=$(realpath --relative-to="${current_dir}" "${GIT_ROOT}/nix/tools/mave
echo "Regenerating Nix files, this process should take about 90 minutes"
nix-shell --run "set -Eeuo pipefail; LC_ALL=C ${current_dir}/fetch-maven-deps.sh | sort -u -o ${inputs_file_path}" \
--pure -A targets.mobile.android.generate-maven-and-npm-deps-shell --argstr target-os android --show-trace "${GIT_ROOT}/default.nix"
--pure -A targets.mobile.android.generate-maven-and-npm-deps-shell --show-trace "${GIT_ROOT}/default.nix"
pushd ${current_dir}
${inputs2nix} ${inputs_file_path} > ${output_nix_file_path}

View File

@ -14,7 +14,7 @@ mkShell {
];
shellHook = ''
${androidEnvShellHook}
${status-go.shellHook}
${status-go.shell.shellHook}
$STATUS_REACT_HOME/nix/mobile/reset-node_modules.sh "${projectNodePackage}"
'';
}

View File

@ -1,4 +1,4 @@
{ stdenv, stdenvNoCC, lib, config, target-os, callPackage,
{ stdenv, lib, config, callPackage,
mkFilter, bash, file, gnumake, watchmanFactory, gradle,
androidEnvShellHook, mavenAndNpmDeps,
nodejs, openjdk, jsbundle, status-go, unzip, zlib }:
@ -15,15 +15,15 @@
assert (builtins.stringLength watchmanSockPath) > 0 -> stdenv.isDarwin;
let
inherit (stdenv.lib) hasAttrByPath optionalAttrs;
inherit (lib) hasAttrByPath optionalAttrs;
env' = env // optionalAttrs (hasAttrByPath ["status_go" "src_override"] config) {
STATUS_GO_SRC_OVERRIDE = config.status_go.src_override;
};
baseName = "release-${target-os}";
baseName = "release-android";
name = "status-react-build-${baseName}";
gradleHome = "$NIX_BUILD_TOP/.gradle";
localMavenRepo = "${mavenAndNpmDeps.deriv}/.m2/repository";
sourceProjectDir = "${mavenAndNpmDeps.deriv}/project";
localMavenRepo = "${mavenAndNpmDeps.drv}/.m2/repository";
sourceProjectDir = "${mavenAndNpmDeps.drv}/project";
envFileName =
if (build-type == "release" || build-type == "nightly" || build-type == "e2e") then ".env.${build-type}" else
if build-type != "" then ".env.jenkins" else ".env";
@ -116,7 +116,7 @@ in stdenv.mkDerivation {
${if secrets-file != "" then "source ${secrets-file}" else ""}
${androidEnvShellHook}
${concatStrings (catAttrs "shellHook" [ mavenAndNpmDeps status-go ])}
${concatStrings (catAttrs "shellHook" [ mavenAndNpmDeps.shell status-go.shell ])}
pushd $sourceRoot/android
${adhocEnvVars} ./gradlew -PversionCode=${build-number} assemble${capitalizedBuildType} || exit

View File

@ -1,38 +1,41 @@
{ config, stdenv, pkgs, callPackage, mkShell, fetchurl, fetchFromGitHub, target-os,
mkFilter, localMavenRepoBuilder, maven, status-go, composeXcodeWrapper, nodejs, yarn }:
{ config, lib, stdenvNoCC, callPackage,status-go,
localMavenRepoBuilder, composeXcodeWrapper, mkShell, mergeSh }:
let
inherit (stdenv.lib) catAttrs concatStrings optional unique;
inherit (lib) catAttrs concatStrings optional unique;
platform = callPackage ../platform.nix { inherit target-os; };
xcodewrapperArgs = {
version = "11.2.1";
};
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
androidPlatform = callPackage ./android { inherit config target-os mkShell mkFilter nodejs maven localMavenRepoBuilder projectNodePackage jsbundle; status-go = status-go.android; };
iosPlatform = callPackage ./ios { inherit config mkFilter mkShell xcodeWrapper projectNodePackage fastlane; status-go = status-go.ios; };
fastlane = callPackage ./fastlane { inherit stdenv target-os mkShell; };
fastlane = callPackage ./fastlane { };
androidPlatform = callPackage ./android {
inherit localMavenRepoBuilder projectNodePackage;
status-go = status-go.android;
};
iosPlatform = callPackage ./ios {
inherit xcodeWrapper projectNodePackage fastlane;
status-go = status-go.ios;
};
selectedSources = [
fastlane
status-go.android
status-go.ios
] ++
optional platform.targetAndroid androidPlatform ++
optional platform.targetIOS iosPlatform;
fastlane
status-go.android
status-go.ios
androidPlatform
iosPlatform
];
projectNodePackage = callPackage ./node-package.nix { inherit pkgs nodejs yarn; inherit (stdenv.lib) importJSON; };
# TARGETS
jsbundle = pkgs.callPackage ../targets/jsbundle.nix { inherit stdenv pkgs target-os nodejs localMavenRepoBuilder mkFilter projectNodePackage; };
projectNodePackage = callPackage ./node-package.nix { inherit (lib) importJSON; };
in {
buildInputs = unique (catAttrs "buildInputs" selectedSources);
shellHook = concatStrings (catAttrs "shellHook" selectedSources);
shell = mergeSh (mkShell {}) (catAttrs "shell" selectedSources);
# CHILD DERIVATIONS
android = androidPlatform;
ios = iosPlatform;
# TARGETS
inherit jsbundle fastlane;
inherit fastlane xcodeWrapper;
}

View File

@ -1,10 +1,9 @@
{ stdenv, target-os, callPackage, mkShell, makeWrapper,
bundlerEnv, bundler, ruby, curl }:
{ lib, stdenv, callPackage, mkShell,
bundlerEnv, cocoapods, bundler, ruby, curl }:
let
inherit (stdenv.lib) optionals optionalString unique;
inherit (lib) optionals optionalString unique;
platform = callPackage ../../platform.nix { inherit target-os; };
fastlane = callPackage ../../../fastlane {
bundlerEnv = _:
bundlerEnv {
@ -12,24 +11,18 @@ let
gemdir = ../../../fastlane;
};
};
bundlerDeps = optionals platform.targetMobile [
bundler
ruby
]; # bundler/ruby used for fastlane on macOS
inherit (fastlane) shellHook;
# TARGETS
shell = mkShell {
buildInputs = [ fastlane curl ] ++ bundlerDeps;
inherit shellHook;
};
buildInputs = [ ruby bundler fastlane curl ]
++ optionals stdenv.isDarwin [ cocoapods ];
in {
# We only include bundler in regular shell if targetting iOS, because that's how the CI builds the whole project
buildInputs = unique (optionals platform.targetIOS bundlerDeps);
drv = fastlane;
inherit shellHook;
# HELPERS
inherit shellHook buildInputs;
# TARGETS
inherit shell;
drv = fastlane;
shell = mkShell {
inherit shellHook buildInputs;
};
}

View File

@ -1,16 +1,14 @@
{ config, stdenv, stdenvNoCC, callPackage, mkShell, fastlane, cocoapods,
xcodeWrapper, mkFilter, fetchurl, flock, nodejs, bash, zlib, procps,
status-go, projectNodePackage }:
{ callPackage, lib, stdenv, mkShell, mergeSh, mkFilter,
xcodeWrapper, projectNodePackage, status-go,
flock, procps, watchman, bundler, fastlane }:
let
inherit (stdenv.lib) catAttrs concatStrings unique;
inherit (lib) catAttrs unique;
createMobileFilesSymlinks = root: ''
# Set up symlinks to mobile enviroment in project root
ln -sf ${root}/mobile/js_files/package.json ${root}/package.json
ln -sf ${root}/mobile/js_files/metro.config.js ${root}/metro.config.js
ln -sf ${root}/mobile/js_files/yarn.lock ${root}/yarn.lock
'';
pod = callPackage ./pod-shell.nix { };
status-go-shell = callPackage ./status-go-shell.nix { inherit status-go; };
selectedSources = [ status-go fastlane ];
src =
let path = ./../../..;
@ -27,32 +25,33 @@ let
};
};
selectedSources = [ fastlane status-go ];
buildInputs = unique ([
cocoapods
fastlane.drv
xcodeWrapper
xcodeWrapper watchman bundler procps
flock # used in reset-node_modules.sh
procps
] ++ catAttrs "buildInputs" selectedSources);
shellHook = ''
${status-go.shellHook}
${fastlane.shellHook}
pushd "$STATUS_REACT_HOME" > /dev/null
{
# Set up symlinks to mobile enviroment in project root
ln -sf ./mobile/js_files/metro.config.js ./metro.config.js
ln -sf ./mobile/js_files/package.json ./package.json
ln -sf ./mobile/js_files/yarn.lock ./yarn.lock
${createMobileFilesSymlinks "$STATUS_REACT_HOME"}
$STATUS_REACT_HOME/nix/mobile/reset-node_modules.sh "${projectNodePackage}" && \
$STATUS_REACT_HOME/nix/mobile/ios/install-pods-and-status-go.sh || \
exit
# check if node modules changed and if so install them
./nix/mobile/reset-node_modules.sh "${projectNodePackage}"
}
popd > /dev/null
'';
in {
inherit xcodeWrapper shellHook buildInputs;
# TARGETS
shell = mkShell {
localShell = mkShell {
inherit buildInputs shellHook;
};
in {
inherit shellHook buildInputs pod;
shell = mergeSh localShell [
fastlane.shell status-go-shell pod.shell
];
}

View File

@ -1,30 +0,0 @@
#!/usr/bin/env bash
set -e
if [ -z "$RCTSTATUS_FILEPATH" ]; then
echo "RCTSTATUS_FILEPATH is not defined! Aborting."
exit 1
fi
RCTSTATUS_DIR="$STATUS_REACT_HOME/modules/react-native-status/ios/RCTStatus"
targetBasename='Statusgo.framework'
# Compare target folder with source to see if copying is required
if [ -d "$RCTSTATUS_DIR/$targetBasename" ] && [ -d $STATUS_REACT_HOME/ios/Pods/ ] && \
diff -q --no-dereference --recursive $RCTSTATUS_DIR/$targetBasename/ $RCTSTATUS_FILEPATH/ > /dev/null; then
echo "$RCTSTATUS_DIR/$targetBasename already in place"
else
sourceBasename="$(basename $RCTSTATUS_FILEPATH)"
echo "Copying $sourceBasename from Nix store to $RCTSTATUS_DIR"
rm -rf "$RCTSTATUS_DIR/$targetBasename/"
cp -a $RCTSTATUS_FILEPATH $RCTSTATUS_DIR && chmod -R 755 "$RCTSTATUS_DIR/$targetBasename"
if [ "$sourceBasename" != "$targetBasename" ]; then
mv "$RCTSTATUS_DIR/$sourceBasename" "$RCTSTATUS_DIR/$targetBasename"
fi
if [ "$(uname)" == 'Darwin' ]; then
# CocoaPods are trash and can't handle other pod instances running at the same time
$STATUS_REACT_HOME/scripts/wait-for.sh 240 'pod install'
pushd $STATUS_REACT_HOME/ios && pod install; popd
fi
fi

View File

@ -0,0 +1,26 @@
{ mkShell, cocoapods }:
let
# source of what pod should install
podfileLock = "ios/Podfile.lock";
# current state of pods installed by pod
manifestLock = "ios/Pods/Manifest.lock";
in {
shell = mkShell {
buildInputs = [ cocoapods ];
shellHook = ''
pushd "$STATUS_REACT_HOME" > /dev/null
{
echo "Checking for modifications in ios/Pods..."
if diff -q ${podfileLock} ${manifestLock}; then
echo "No modifications detected."
else
# CocoaPods are trash and can't handle other pod instances running
./scripts/wait-for.sh 240 'pod install'
(cd ios && pod install)
fi
}
popd > /dev/null
'';
};
}

View File

@ -0,0 +1,31 @@
{ mkShell, mergeSh, status-go }:
let
shell = mkShell {
shellHook = ''
if [ -z "$RCTSTATUS_FILEPATH" ]; then
echo "RCTSTATUS_FILEPATH is not defined! Aborting."
exit 1
fi
RCTSTATUS_DIR="$STATUS_REACT_HOME/modules/react-native-status/ios/RCTStatus"
targetBasename='Statusgo.framework'
# Compare target folder with source to see if copying is required
if [ -d "$RCTSTATUS_DIR/$targetBasename" ] && [ -d $STATUS_REACT_HOME/ios/Pods/ ] && \
diff -q --no-dereference --recursive $RCTSTATUS_DIR/$targetBasename/ $RCTSTATUS_FILEPATH/ > /dev/null; then
echo "$RCTSTATUS_DIR/$targetBasename already in place"
else
sourceBasename="$(basename $RCTSTATUS_FILEPATH)"
echo "Copying $sourceBasename from Nix store to $RCTSTATUS_DIR"
rm -rf "$RCTSTATUS_DIR/$targetBasename/"
cp -a $RCTSTATUS_FILEPATH $RCTSTATUS_DIR
chmod -R 755 "$RCTSTATUS_DIR/$targetBasename"
if [ "$sourceBasename" != "$targetBasename" ]; then
mv "$RCTSTATUS_DIR/$sourceBasename" "$RCTSTATUS_DIR/$targetBasename"
fi
fi
'';
};
in
mergeSh status-go.shell [ shell ]

View File

@ -1,25 +0,0 @@
# This file controls the pinned version of nixpkgs we use for our Nix environment
let
inherit (import <nixpkgs> { }) fetchFromGitHub;
defaultConfig = { android_sdk.accept_license = true; };
nixpkgsSrc = {
name = "nixpkgs-source";
owner = "status-im";
repo = "nixpkgs";
rev = "d9b2c6b8add87098adb8ee34042e39d15f3658c4";
sha256 = "19wnp97nlkyd825pjd9vm9rngy3gcil9bwqncwscivsmaz5c7l37";
# To get the compressed Nix sha256, use:
# nix-prefetch-url --unpack https://github.com/${ORG}/nixpkgs/archive/${REV}.tar.gz
# The last line will be the hash.
};
in {
config ? { },
config' ? defaultConfig // config,
pkgs ? (import (fetchFromGitHub nixpkgsSrc)) { config = config'; }
}:
{
inherit pkgs;
config = config';
}

38
nix/pkgs.nix Normal file
View File

@ -0,0 +1,38 @@
# This file controls the pinned version of nixpkgs we use for our Nix environment
# as well as which versions of package we use, including their overrides.
{ config ? { } }:
let
inherit (import <nixpkgs> { }) fetchFromGitHub;
nixpkgsSrc = {
name = "nixpkgs-source";
owner = "status-im";
repo = "nixpkgs";
rev = "d9b2c6b8add87098adb8ee34042e39d15f3658c4";
sha256 = "19wnp97nlkyd825pjd9vm9rngy3gcil9bwqncwscivsmaz5c7l37";
# To get the compressed Nix sha256, use:
# nix-prefetch-url --unpack https://github.com/${ORG}/nixpkgs/archive/${REV}.tar.gz
# The last line will be the hash.
};
defaultConfig = {
android_sdk.accept_license = true;
# Override some package versions
packageOverrides = pkgs: rec {
# utilities
mkFilter = import ./tools/mkFilter.nix { inherit (pkgs.stdenv) lib; };
mkShell = import ./tools/mkShell.nix { inherit pkgs; stdenv = pkgs.stdenvNoCC; };
mergeSh = import ./tools/mergeSh.nix { inherit (pkgs.stdenv) lib; };
# custom packages
nodejs = pkgs.nodejs-10_x;
yarn = pkgs.yarn.override { inherit nodejs; };
clojure = pkgs.clojure.overrideAttrs (old: rec { version = "1.10.0.411"; });
go = pkgs.callPackage ./patched-go { baseGo = pkgs.go_1_13; };
# custom builders
buildGoPackage = pkgs.buildGoPackage.override { inherit go; };
};
};
pkgs = (import (fetchFromGitHub nixpkgsSrc)) { config = defaultConfig // config; };
in
pkgs

View File

@ -1,59 +0,0 @@
{ target-os, stdenv }:
# We allow for "none" value because `make shell` can be called with `TARGET_OS` not set.
# We don't want to assume `all`, because that will rebuild status-go for all platforms.
assert stdenv.lib.assertOneOf "target-os" target-os [
"linux"
"android"
"windows"
"macos"
"darwin"
"ios"
"all"
"none"
];
let
inherit (stdenv) isDarwin isLinux;
# based on the value passed in through target-os, check if we're targetting a desktop platform
targetDesktop = {
"linux" = true;
"windows" = true;
"macos" = true;
"darwin" = true;
"all" = true;
}.${target-os} or false;
# based on the value passed in through target-os, check if we're targetting a mobile platform
targetMobile = {
"android" = true;
"ios" = true;
"all" = true;
}.${target-os} or false;
targetAndroid = {
"android" = true;
"all" = true;
}.${target-os} or false;
targetIOS = {
"ios" = true;
"all" = isDarwin;
}.${target-os} or false;
targetLinux = {
"linux" = true;
"all" = isLinux;
}.${target-os} or false;
targetDarwin = {
"macos" = true;
"darwin" = true;
"all" = isDarwin;
}.${target-os} or false;
targetWindows = {
"windows" = true;
"all" = isLinux;
}.${target-os} or false;
in {
inherit targetDesktop targetMobile;
inherit targetAndroid targetIOS;
inherit targetLinux targetDarwin targetWindows;
}

View File

@ -2,17 +2,17 @@
set -e
gitRoot=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
resultPath="${gitRoot}/result/"
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
resultPath="${GIT_ROOT}/result/"
# cleanup for artifacts created during builds
function cleanup() {
# clear trapped signals
trap - EXIT ERR INT QUIT
# do the actual cleanup, ignore failure
if ./nix/clean.sh "${nixResultPath}"; then
if ${GIT_ROOT}/nix/scripts/clean.sh "${nixResultPath}"; then
echo "Successful cleanup!"
elif [[ -n "${IN_CI_ENVIRONMENT}" ]]; then
elif [[ -n "${JENKINS_URL}" ]]; then
# in CI removing some paths can fail due to parallel builds
echo "Ignoring cleanup failure in CI."
else
@ -29,6 +29,7 @@ function extractResults() {
mkdir -p "${resultPath}"
cp -vfr ${nixResultPath}/* "${resultPath}"
chmod -R u+w "${resultPath}"
ls -l "${resultPath}"
}
# Load Nix profile
@ -49,7 +50,6 @@ nixOpts=(
"--fallback"
"--no-out-link"
"--show-trace"
"--argstr target-os ${TARGET_OS}"
"--attr ${targetAttr}"
"${@}"
"default.nix"

View File

@ -3,7 +3,7 @@
#
# This script is used by the Makefile to have an implicit nix-shell.
# The following environment variables modify the script behavior:
# - TARGET_OS: This attribute is passed as `target-os` to Nix, limiting the scope
# - TARGET: This attribute is passed as `targets` arg to Nix, limiting the scope
# of the Nix expressions.
# - _NIX_ATTR: Used to specify an attribute set from inside the expression in `default.nix`.
# This allows for drilling down into a specific attribute in Nix expressions.
@ -38,13 +38,13 @@ shellArgs=(
"--show-trace"
)
if [[ -n "${TARGET_OS}" ]]; then
shellArgs+=("--argstr target-os ${TARGET_OS}")
if [[ -n "${TARGET}" ]]; then
shellArgs+=("--argstr target ${TARGET}")
else
echo -e "${YELLOW}Env is missing TARGET_OS, assuming no target platform.${NC} See nix/README.md for more details." 1>&2
echo -e "${YELLOW}Env is missing TARGET, assuming default target.${NC} See nix/README.md for more details." 1>&2
fi
if [[ "$TARGET_OS" =~ (linux|windows|darwin|macos) ]]; then
if [[ "$TARGET" =~ (linux|windows|darwin|macos) ]]; then
# This is a dirty workaround because 'yarn install' is an impure operation,
# so we need to call it from an impure shell.
# Hopefully we'll be able to fix this later on with something like yarn2nix
@ -65,7 +65,7 @@ fi
# ENTER_NIX_SHELL is the fake command used when `make shell` is run.
# It is just a special string, not a variable, and a marker to not use `--run`.
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS:-none}'...${NC}" 1>&2
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET:-default}'...${NC}" 1>&2
exec nix-shell ${shellArgs[@]} ${entryPoint}
else
# Not all builds are ready to be run in a pure environment
@ -78,6 +78,6 @@ else
if [[ -n "${_NIX_KEEP}" ]]; then
shellArgs+=("--keep ${_NIX_KEEP//;/ --keep }")
fi
echo -e "${GREEN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS}'...${NC}" 1>&2
echo -e "${GREEN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET}'...${NC}" 1>&2
exec nix-shell ${shellArgs[@]} --run "$@" ${entryPoint}
fi

65
nix/shells.nix Normal file
View File

@ -0,0 +1,65 @@
# This file defines custom shells as well as shortcuts
# for accessing more nested shells.
{
config ? {},
pkgs ? import ./pkgs.nix { inherit config; }
}:
let
# everything else we define in nix/ dir
targets = pkgs.callPackage ./targets.nix { };
# for calling lein targets in CI or Makefile
leiningen-sh = pkgs.mkShell {
buildInputs = with pkgs; [ clojure leiningen flock maven nodejs openjdk ];
};
# for running fastlane commands alone
fastlane-sh = targets.mobile.fastlane.shell;
# for 'make watchman-clean'
watchman-sh = pkgs.mkShell {
buildInputs = [ pkgs.watchman ];
};
# the default shell that is used when target is not specified
default = pkgs.mkShell {
name = "status-react-shell"; # for identifying all shells
buildInputs = with pkgs; lib.unique ([
# core utilities that should always be present in a shell
bash curl wget file unzip flock git gnumake jq ncurses
# build specific utilities
clojure leiningen maven watchman
# other nice to have stuff
yarn nodejs python27
] # and some special cases
++ lib.optionals stdenv.isDarwin [ cocoapods clang ]
++ lib.optionals (!stdenv.isDarwin) [ gcc8 ]
);
# just a nicety for easy access to node scripts
shellHook = ''
export PATH="$STATUS_REACT_HOME/node_modules/.bin:$PATH"
'';
};
# values here can be selected using `nix-shell --argstr target $TARGET`
# the nix/scripts/shell.sh wrapper does this for us and expects TARGET to be set
in with pkgs; rec {
inherit default;
lein = leiningen-sh;
watchman = watchman-sh;
fastlane = fastlane-sh;
adb = targets.mobile.android.adb.shell;
# helpers for use with target argument
linux = targets.desktop.linux.shell;
macos = targets.desktop.macos.shell;
windows = targets.desktop.windows.shell;
android = targets.mobile.android.shell;
ios = targets.mobile.ios.shell;
# all shells together depending on host OS
all = mergeSh (mkShell {}) (lib.unique (
lib.optionals stdenv.isLinux [ android linux windows ] ++
lib.optionals stdenv.isDarwin [ android macos ios ]
));
}

View File

@ -1,9 +1,6 @@
{ stdenv, utils, callPackage, buildGoPackage, go, xcodeWrapper }:
{ stdenv, utils, callPackage,
buildGoPackage, go, xcodeWrapper }:
{ owner, repo, rev, version, goPackagePath, src, host,
{ owner, repo, rev, cleanVersion, goPackagePath, src, host,
# desktop-only arguments
goBuildFlags, goBuildLdFlags,
outputFileName,

View File

@ -1,8 +1,7 @@
{ stdenv, utils, callPackage,
buildGoPackage, go, gomobile, openjdk, xcodeWrapper }:
{ owner, repo, rev, version, sanitizedVersion, goPackagePath, src, host,
{ owner, repo, rev, cleanVersion, goPackagePath, src, host,
# mobile-only arguments
goBuildFlags, goBuildLdFlags,
@ -12,7 +11,9 @@ let
inherit (stdenv.lib) concatStringsSep makeBinPath optional;
targetConfig = config;
buildStatusGo = callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
buildStatusGo = callPackage ./build-status-go.nix {
inherit buildGoPackage go xcodeWrapper utils;
};
# Remove mobile-only arguments from args
args = removeAttrs args' [

View File

@ -1,6 +1,6 @@
{ buildGoPackage, go, xcodeWrapper, stdenv, utils }:
{ owner, repo, rev, version, sanitizedVersion, goPackagePath, src, host,
{ owner, repo, rev, cleanVersion, goPackagePath, src, host,
nativeBuildInputs ? [],
buildPhase, buildMessage,
installPhase ? "",
@ -19,7 +19,7 @@ let
args = removeAttrs args' [ "buildMessage" ]; # Remove our arguments from args before passing them on to buildGoPackage
buildStatusGo = buildGoPackage (args // {
pname = repo;
version = "${sanitizedVersion}-${strings.substring 0 7 rev}-${host}";
version = "${cleanVersion}-${strings.substring 0 7 rev}-${host}";
nativeBuildInputs =
nativeBuildInputs ++

View File

@ -1,16 +1,14 @@
{ target-os, config, stdenv, callPackage,
buildGoPackage, go, fetchFromGitHub, mkFilter, openjdk,
androidPkgs, xcodeWrapper }:
{ config, stdenv, callPackage, mkShell, mergeSh, buildGoPackage, go,
fetchFromGitHub, mkFilter, openjdk, androidPkgs, xcodeWrapper }:
let
inherit (stdenv.lib)
catAttrs concatStrings fileContents importJSON makeBinPath
optional optionalString removePrefix strings attrValues mapAttrs attrByPath
optional optionalString strings attrValues mapAttrs attrByPath
traceValFn;
platform = callPackage ../platform.nix { inherit target-os; };
utils = callPackage ../utils.nix { inherit xcodeWrapper; };
gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit target-os xcodeWrapper utils buildGoPackage; };
utils = callPackage ./utils.nix { inherit xcodeWrapper; };
gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit xcodeWrapper utils buildGoPackage; };
buildStatusGoDesktopLib = callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
buildStatusGoMobileLib = callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile xcodeWrapper utils; };
srcData =
@ -18,12 +16,11 @@ let
if (attrByPath ["status_go" "src_override"] "" config) != "" then rec {
owner = "status-im";
repo = "status-go";
version = "develop";
goPackagePath = "github.com/${owner}/${repo}";
rev = "unknown";
shortRev = "unknown";
sanitizedVersion = version;
versionName = "develop";
rawVersion = "develop";
cleanVersion = rawVersion;
goPackagePath = "github.com/${owner}/${repo}";
src =
let path = traceValFn (path: "Using local ${repo} sources from ${path}\n") config.status_go.src_override;
in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control
@ -42,20 +39,14 @@ let
# Otherwise grab it from the location defined by status-go-version.json
let
versionJSON = importJSON ../../status-go-version.json; # TODO: Simplify this path search with lib.locateDominatingFile
versionRegex = "^v?[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-[[:alnum:].]+)$";
sha256 = versionJSON.src-sha256;
sanitizeVersion = builtins.replaceStrings
[ "/" ]
[ "_" ];
in rec {
inherit (versionJSON) owner repo version;
sanitizedVersion = sanitizeVersion versionJSON.version;
goPackagePath = "github.com/${owner}/${repo}";
rev = versionJSON.commit-sha1;
shortRev = strings.substring 0 7 rev;
versionName = if (builtins.match versionRegex sanitizedVersion) != null
then removePrefix "v" sanitizedVersion # Geth forces a 'v' prefix
else "develop"; # to reduce metrics cardinality in Prometheus
rawVersion = versionJSON.version;
cleanVersion = utils.sanitizeVersion versionJSON.version;
goPackagePath = "github.com/${owner}/${repo}";
src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-${srcData.shortRev}-source"; };
};
@ -93,7 +84,7 @@ let
# status-go params to be set at build time, important for About section and metrics
goBuildParams = {
GitCommit = srcData.rev;
Version = srcData.versionName;
Version = srcData.cleanVersion;
};
# These are necessary for status-go to show correct version
paramsLdFlags = attrValues (mapAttrs (name: value:
@ -105,7 +96,7 @@ let
"-w" # -w disables DWARF debugging information
];
statusGoArgs = { inherit (srcData) src owner repo rev version sanitizedVersion goPackagePath; inherit goBuildFlags goBuildLdFlags; };
statusGoArgs = { inherit (srcData) src owner repo rev cleanVersion goPackagePath; inherit goBuildFlags goBuildLdFlags; };
status-go-packages = {
desktop = buildStatusGoDesktopLib (statusGoArgs // {
outputFileName = "libstatus.a";
@ -124,46 +115,41 @@ let
});
};
buildInputs = if target-os == "android" then
android.buildInputs
else if target-os == "ios" then
ios.buildInputs
else if target-os == "all" then
currentHostConfig.allTargets
else if platform.targetDesktop then
desktop.buildInputs
else
throw "Unexpected target platform ${target-os}";
android = {
buildInputs = optional platform.targetAndroid [ status-go-packages.android ];
shellHook =
optionalString platform.targetAndroid ''
android = rec {
buildInputs = [ status-go-packages.android ];
shell = mkShell {
inherit buildInputs;
shellHook = ''
# These variables are used by the Status Android Gradle build script in android/build.gradle
export STATUS_GO_ANDROID_LIBDIR=${status-go-packages.android}/lib
'';
};
};
ios = {
buildInputs = optional platform.targetIOS [ status-go-packages.ios ];
shellHook =
optionalString platform.targetIOS ''
ios = rec {
buildInputs = [ status-go-packages.ios ];
shell = mkShell {
inherit buildInputs;
shellHook = ''
# These variables are used by the iOS build preparation section in nix/mobile/ios/default.nix
export RCTSTATUS_FILEPATH=${status-go-packages.ios}/lib/Statusgo.framework
'';
};
};
desktop = {
buildInputs = optional platform.targetDesktop [ status-go-packages.desktop ];
shellHook =
optionalString platform.targetDesktop ''
desktop = rec {
buildInputs = [ status-go-packages.desktop ];
shell = mkShell {
inherit buildInputs;
shellHook = ''
# These variables are used by the Status Desktop CMake build script in modules/react-native-status/desktop/CMakeLists.txt
export STATUS_GO_DESKTOP_INCLUDEDIR=${status-go-packages.desktop}/include
export STATUS_GO_DESKTOP_LIBDIR=${status-go-packages.desktop}/lib
'';
};
};
platforms = [ android ios desktop ];
in {
inherit buildInputs;
shellHook = concatStrings (catAttrs "shellHook" platforms);
shell = mergeSh mkShell {} (catAttrs "shell" platforms);
# CHILD DERIVATIONS
inherit android ios desktop;

View File

@ -1,4 +1,4 @@
{ stdenv, target-os, callPackage, utils, fetchgit,
{ stdenv, callPackage, utils, fetchgit,
buildGoPackage, glibc, ncurses5, zlib, makeWrapper, patchelf,
platform-tools, xcodeWrapper
}:
@ -6,9 +6,6 @@
let
inherit (stdenv) isDarwin;
inherit (stdenv.lib) optional optionalString strings;
platform = callPackage ../../platform.nix { inherit target-os; };
in buildGoPackage rec {
pname = "gomobile";
version = "20190719-${strings.substring 0 7 rev}";
@ -27,7 +24,7 @@ in buildGoPackage rec {
patches = [ ./resolve-nix-android-sdk.patch ];
postPatch = ''
${optionalString platform.targetAndroid ''substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`"''}
substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`"
# Prevent a non-deterministic temporary directory from polluting the resulting object files
substituteInPlace cmd/gomobile/env.go \

View File

@ -1,4 +1,4 @@
{ xcodeWrapper }:
{ xcodeWrapper, lib }:
let
RED = "\\033[0;31m";
@ -39,7 +39,19 @@ let
fi
'';
# paths don't like slashes in them
dropSlashes = builtins.replaceStrings [ "/" ] [ "_" ];
# if version doesn't match this it's probably a commit
versionRegex = "^v?[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-[[:alnum:].]+)?$";
sanitizeVersion = version:
if (builtins.match versionRegex version) != null
# Geth forces a 'v' prefix for all versions
then lib.removePrefix "v" (dropSlashes version)
# reduce metrics cardinality in Prometheus
else "develop";
in {
inherit enforceXCodeAvailable
inherit sanitizeVersion
enforceXCodeAvailable
enforceiPhoneSDKAvailable;
}

28
nix/targets.nix Normal file
View File

@ -0,0 +1,28 @@
{
config ? {},
pkgs ? import ./pkgs.nix { inherit config; }
}:
with pkgs;
let
localMavenRepoBuilder = callPackage ./tools/maven/maven-repo-builder.nix {
inherit stdenv;
};
status-go = callPackage ./status-go {
inherit (mobile) xcodeWrapper;
androidPkgs = mobile.android.androidComposition;
};
desktop = callPackage ./desktop {
inherit darwin;
status-go = status-go.desktop;
};
mobile = callPackage ./mobile {
inherit status-go localMavenRepoBuilder;
inherit (xcodeenv) composeXcodeWrapper;
};
in {
inherit mobile desktop status-go;
}

9
nix/tools/mergeSh.nix Normal file
View File

@ -0,0 +1,9 @@
# this is an utility for mergeing shells created with mkShell
# TODO: make this an attribute of mkShell result set.
{ lib }:
super: shells: super.overrideAttrs(super: with lib; {
inputsFrom = (super.inputsFrom or []) ++ unique (catAttrs "inputsFrom" shells);
buildInputs = (super.buildInputs or []) ++ unique (catAttrs "buildInputs" shells);
shellHook = (super.shellHook or "") + concatStrings (catAttrs "shellHook" shells);
})

40
nix/tools/mkShell.nix Normal file
View File

@ -0,0 +1,40 @@
# This Nix expression appends/modifies an existing attribute set
# in order to define STATUS_REACT_HOME for use multiple derivations and scripts
{ pkgs, stdenv ? pkgs.stdenv }:
# Declare a specialized mkShell function which adds some bootstrapping
# so that e.g. STATUS_REACT_HOME is automatically available in the shell
attrs:
(pkgs.mkShell.override({ inherit stdenv; }) attrs)
.overrideAttrs(super: rec {
nativeBuildInputs = (super.nativeBuildInputs or [ ]) ++ [ pkgs.git ];
# avoid terinal issues
TERM="xterm";
# default locale
LANG="en_US.UTF-8";
LANGUAGE="en_US.UTF-8";
shellSetup = ''
set -e
if [ -z "$STATUS_REACT_HOME" ]; then
export STATUS_REACT_HOME=$(git rev-parse --show-toplevel)
fi
export SHELL_SETUP=done
set +e
'';
shellHook = ''
if [ -z "$SHELL_SETUP" ]; then
${shellSetup}
fi
${super.shellHook or ""}
'';
}
)

View File

@ -12,6 +12,6 @@ GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
rm -rf .nix-gcroots
mkdir .nix-gcroots
drv=$(nix-instantiate --argstr target-os all --add-root ${GIT_ROOT}/shell.nix)
drv=$(nix-instantiate --argstr target all --add-root ${GIT_ROOT}/shell.nix)
refs=$(nix-store --query --references $drv)
nix-store -r $refs --indirect --add-root $GIT_ROOT/.nix-gcroots/shell.dep

View File

@ -10,8 +10,8 @@ YELLOW='\033[1;33m'
NC='\033[0m'
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
OS=$(uname -s)
if [ -z "$TARGET_OS" ]; then
TARGET_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ -z "$TARGET" ]; then
TARGET=$(uname -s | tr '[:upper:]' '[:lower:]')
fi
WINDOWS_CROSSTOOLCHAIN_PKG_NAME='mxetoolchain-x86_64-w64-mingw32'
@ -21,7 +21,7 @@ source_lib "packages.sh"
source_lib "platform.sh"
function is_windows_target() {
[[ "$TARGET_OS" =~ windows ]]
[[ "$TARGET" =~ windows ]]
}
function joinPath() {

23
scripts/inotify_fix.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# If this is not run on some machines react-native builds fail.
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
source "$GIT_ROOT/scripts/lib/setup/path-support.sh"
source_lib "output.sh"
source_lib "platform.sh"
if ! is_linux; then
echo "inotify fix not applicable on non-linux OS"
return
fi
watches=$(cat /proc/sys/fs/inotify/max_user_watches)
required_watches=524288
if [ $watches -lt $required_watches ]; then
cecho "@b@cyan[[fs.inotify.max_user_watches limit is too low ($watches), increasing it]]"
echo fs.inotify.max_user_watches=$required_watches | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
fi

View File

@ -17,7 +17,7 @@ nixOpts=(
if is_macos; then
# Start a watchman instance if not started already and store its socket path.
# In order to get access to the right versions of watchman and jq, we start an ad-hoc nix-shell that imports the packages from nix/nixpkgs-bootstrap.
WATCHMAN_SOCKFILE=$(watchman get-sockname --no-pretty | jq -r .sockname)
WATCHMAN_SOCKFILE = $(watchman get-sockname --no-pretty | jq -r .sockname)
nixOpts+=(
"--argstr watchmanSockPath ${WATCHMAN_SOCKFILE}"
"--option extra-sandbox-paths ${STORE_FILE};${WATCHMAN_SOCKFILE}"
@ -28,4 +28,4 @@ else
)
fi
${GIT_ROOT}/nix/build.sh targets.mobile.${TARGET_OS}.release "${nixOpts[@]}"
${GIT_ROOT}/nix/scripts/build.sh targets.mobile.android.release "${nixOpts[@]}"

View File

@ -8,8 +8,8 @@
# Usage: scripts/setup
########################################################################
_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
source "$_current_dir/lib/setup/path-support.sh"
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
source "$GIT_ROOT/scripts/lib/setup/path-support.sh"
source_lib "output.sh"
source_lib "packages.sh"
@ -28,30 +28,15 @@ if [ $_need_curl -eq 1 ] && ! program_exists "curl"; then
exit 1
fi
if is_linux && [ -z "$IN_CI_ENVIRONMENT" ]; then
watches=$(cat /proc/sys/fs/inotify/max_user_watches)
required_watches=524288
if [ $watches -lt $required_watches ]; then
cecho "@b@cyan[[fs.inotify.max_user_watches limit is too low ($watches), increasing it]]"
echo fs.inotify.max_user_watches=$required_watches | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
fi
if [ -f "/etc/arch-release" ]; then
# Arch Linux
userns=$(sysctl -n kernel.unprivileged_userns_clone)
if [ "$userns" != '1' ]; then
sudo sysctl kernel.unprivileged_userns_clone=1
fi
fi
fi
# bump max watches limit to avoid issues with RN builds
$GIT_ROOT/scripts/inotify_fix.sh
####
setup_header "Installing requirements..."
if [ "$IN_NIX_SHELL" != 'pure' ] && ! is_nixos && ! program_exists nix; then
required_version="2.3.1"
NIX_INSTALLER_NO_MODIFY_PROFILE=1 bash <(curl https://nixos.org/releases/nix/nix-${required_version}/install) --no-daemon
NIX_INSTALLER_NO_MODIFY_PROFILE=1 NIX_IGNORE_SYMLINK_STORE=1 bash <(curl https://nixos.org/releases/nix/nix-${required_version}/install) --no-daemon
if [ $? -eq 0 ]; then
echo -e "${YELLOW}**********************************************************************************************************"
echo "The Nix package manager was successfully installed."

View File

@ -1,39 +1,11 @@
{ config ? { },
nixpkgs-bootstrap ? import ./nix/nixpkgs-bootstrap.nix { inherit config; },
pkgs ? nixpkgs-bootstrap.pkgs,
target-os ? "none" }:
{
config ? { }, # for passing status_go.src_override
target ? "default" # see nix/shells.nix for all valid values
}:
let
project = import ./default.nix {
inherit target-os pkgs nixpkgs-bootstrap;
inherit (nixpkgs-bootstrap) config;
};
mkShell = pkgs.callPackage ./nix/bootstrapped-shell.nix {
inherit stdenv target-os;
inherit (pkgs) mkShell;
};
platform = pkgs.callPackage ./nix/platform.nix { inherit target-os; };
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
stdenv = pkgs.stdenvNoCC;
# those should always be present in a shell
coreInputs = with pkgs; [
bash curl file flock git gnumake jq wget
];
in mkShell {
name = "status-react-shell";
# none means we shouldn't include project specific deps
buildInputs =
coreInputs ++
stdenv.lib.optionals (target-os != "none") (with pkgs; [
unzip
ncurses
lsof # used in scripts/start-react-native.sh
ps # used in scripts/start-react-native.sh
clojure
leiningen
maven
watchman
]);
inputsFrom = stdenv.lib.optional (target-os != "none") project.shell;
}
project = import ./default.nix { inherit config; };
in
# this is where the $TARGET env variable affects things
project.pkgs.mergeSh project.shells.default [ project.shells.${target} ]
# combining with default shell to include all the standard utilities