diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index 7421bed8d9..235d524614 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -31,7 +31,7 @@ pipeline { } environment { - BUILD_PLATFORM = 'android' + TARGET_PLATFORM = 'android' LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index 5911cd9346..25a013a7ac 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -22,7 +22,7 @@ pipeline { } environment { - BUILD_PLATFORM = 'ios' + TARGET_PLATFORM = 'ios' LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 64ce66d7ce..98d81f2265 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -37,7 +37,7 @@ pipeline { * https://issues.jenkins-ci.org/browse/JENKINS-49076 **/ environment { - BUILD_PLATFORM = 'linux' + TARGET_PLATFORM = 'linux' LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index 11216a03a4..e13fa079a2 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -22,7 +22,7 @@ pipeline { } environment { - BUILD_PLATFORM = 'macos' + TARGET_PLATFORM = 'macos' LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' diff --git a/ci/Jenkinsfile.windows b/ci/Jenkinsfile.windows index 2fd1c29c8a..b475e28a82 100644 --- a/ci/Jenkinsfile.windows +++ b/ci/Jenkinsfile.windows @@ -35,7 +35,7 @@ pipeline { * https://issues.jenkins-ci.org/browse/JENKINS-49076 **/ environment { - BUILD_PLATFORM = 'windows' + TARGET_PLATFORM = 'windows' LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' diff --git a/default.nix b/default.nix index 007ae14f5e..73c4fca763 100644 --- a/default.nix +++ b/default.nix @@ -1,16 +1,28 @@ -let - pkgs = import ((import { }).fetchFromGitHub { +# target-os = [ 'windows' 'linux' 'macos' 'android' 'ios' ] +{ pkgs ? import ((import { }).fetchFromGitHub { owner = "status-im"; repo = "nixpkgs"; rev = "15623aac6e8cbfa24d4268195bc8eda7303ea2ff"; sha256 = "0crjmspk65rbpkl3kqcj7433355i9fy530lhc48g2cz75xjk4sxh"; - }) { config = { }; }; + }) { config = { }; }, + target-os ? "" }: -in with pkgs; +with pkgs; let + targetDesktop = { + "linux" = true; + "windows" = true; + "macos" = true; + "" = true; + }.${target-os} or false; + targetMobile = { + "android" = true; + "ios" = true; + "" = true; + }.${target-os} or false; _stdenv = stdenvNoCC; # TODO: Try to use stdenv for Darwin - statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { stdenv = _stdenv; }; - statusMobile = callPackage ./scripts/lib/setup/nix/mobile { stdenv = _stdenv; }; + statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { inherit target-os; stdenv = _stdenv; }; + statusMobile = callPackage ./scripts/lib/setup/nix/mobile { inherit target-os; stdenv = _stdenv; }; nodeInputs = import ./scripts/lib/setup/nix/global-node-packages/output { # The remaining dependencies come from Nixpkgs inherit pkgs; @@ -36,18 +48,20 @@ in with pkgs; maven ncurses ps # used in scripts/start-react-native.sh - statusDesktop.buildInputs - statusMobile.buildInputs watchman unzip wget ] ++ nodePkgs ++ lib.optional isDarwin cocoapods - ++ lib.optional isLinux gcc7; - shellHook = '' - ${statusDesktop.shellHook} - ${statusMobile.shellHook} - - [ -d "$ANDROID_SDK_ROOT" ] || ./scripts/setup # we assume that if the Android SDK dir does not exist, make setup needs to be run - ''; + ++ lib.optional isLinux gcc7 + ++ lib.optional targetDesktop statusDesktop.buildInputs + ++ lib.optional targetMobile statusMobile.buildInputs; + shellHook = + lib.optionalString targetDesktop statusDesktop.shellHook + + lib.optionalString targetMobile statusMobile.shellHook + + '' + if [ -n "$ANDROID_SDK_ROOT" ] && [ ! -d "$ANDROID_SDK_ROOT" ]; then + ./scripts/setup # we assume that if the Android SDK dir does not exist, make setup needs to be run + fi + ''; } diff --git a/scripts/lib/setup/installers.sh b/scripts/lib/setup/installers.sh index a61f978650..d6a36f48fe 100755 --- a/scripts/lib/setup/installers.sh +++ b/scripts/lib/setup/installers.sh @@ -39,6 +39,10 @@ function install_nix() { } function install_android_sdk() { + if [ -z "$ANDROID_SDK_ROOT" ]; then + return 0 + fi + if [ -d "$ANDROID_SDK_ROOT" ]; then cecho "@green[[Android SDK already installed.]]" else diff --git a/scripts/lib/setup/nix/desktop/default.nix b/scripts/lib/setup/nix/desktop/default.nix index 7d344f5ae2..01e7075ebe 100644 --- a/scripts/lib/setup/nix/desktop/default.nix +++ b/scripts/lib/setup/nix/desktop/default.nix @@ -1,9 +1,17 @@ -{ stdenv, pkgs }: +{ stdenv, pkgs, target-os }: with pkgs; with stdenv; let + targetLinux = { + "linux" = true; + "" = true; + }.${target-os} or false; + targetWindows = { + "windows" = true; + "" = true; + }.${target-os} or false; windowsPlatform = callPackage ./windows { }; appimagekit = callPackage ./appimagekit { }; linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; }; @@ -16,11 +24,13 @@ in file gnupg # Used by appimagetool go - qt5.full - ] ++ lib.optional isLinux [ appimagekit linuxdeployqt patchelf ] - ++ lib.optional isLinux windowsPlatform.buildInputs; - shellHook = '' + ] ++ lib.optional targetLinux [ appimagekit linuxdeployqt patchelf ] + ++ lib.optional (! targetWindows) qt5.full + ++ lib.optional targetWindows windowsPlatform.buildInputs; + shellHook = (if target-os == "windows" then "unset QT_PATH" else '' export QT_PATH="${qt5.full}" export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH" - ''; + '') + (lib.optionalString isDarwin '' + export MACOSX_DEPLOYMENT_TARGET=10.9 + ''); } diff --git a/scripts/lib/setup/nix/mobile/default.nix b/scripts/lib/setup/nix/mobile/default.nix index 82e0569ee9..17754d0591 100644 --- a/scripts/lib/setup/nix/mobile/default.nix +++ b/scripts/lib/setup/nix/mobile/default.nix @@ -1,18 +1,22 @@ -{ stdenv, pkgs }: +{ stdenv, pkgs, target-os ? "" }: with pkgs; with stdenv; let android-ndk = callPackage ./android-ndk { }; + targetAndroid = { + "android" = true; + "" = true; + }.${target-os} or false; in { - buildInputs = [ + buildInputs = lib.optional targetAndroid [ android-ndk openjdk ]; - shellHook = '' + shellHook = lib.optionalString targetAndroid '' export JAVA_HOME="${openjdk}" export ANDROID_HOME=~/.status/Android/Sdk export ANDROID_SDK_ROOT="$ANDROID_HOME"