Implement target-dependent installing of Nix dependencies

This commit is contained in:
Pedro Pombeiro 2019-03-05 18:36:40 +01:00
parent 9f601e851d
commit 015f02ae84
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
9 changed files with 61 additions and 29 deletions

View File

@ -31,7 +31,7 @@ pipeline {
} }
environment { environment {
BUILD_PLATFORM = 'android' TARGET_PLATFORM = 'android'
LANG = 'en_US.UTF-8' LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8'

View File

@ -22,7 +22,7 @@ pipeline {
} }
environment { environment {
BUILD_PLATFORM = 'ios' TARGET_PLATFORM = 'ios'
LANG = 'en_US.UTF-8' LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8'

View File

@ -37,7 +37,7 @@ pipeline {
* https://issues.jenkins-ci.org/browse/JENKINS-49076 * https://issues.jenkins-ci.org/browse/JENKINS-49076
**/ **/
environment { environment {
BUILD_PLATFORM = 'linux' TARGET_PLATFORM = 'linux'
LANG = 'en_US.UTF-8' LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8'

View File

@ -22,7 +22,7 @@ pipeline {
} }
environment { environment {
BUILD_PLATFORM = 'macos' TARGET_PLATFORM = 'macos'
LANG = 'en_US.UTF-8' LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8'

View File

@ -35,7 +35,7 @@ pipeline {
* https://issues.jenkins-ci.org/browse/JENKINS-49076 * https://issues.jenkins-ci.org/browse/JENKINS-49076
**/ **/
environment { environment {
BUILD_PLATFORM = 'windows' TARGET_PLATFORM = 'windows'
LANG = 'en_US.UTF-8' LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8'

View File

@ -1,16 +1,28 @@
let # target-os = [ 'windows' 'linux' 'macos' 'android' 'ios' ]
pkgs = import ((import <nixpkgs> { }).fetchFromGitHub { { pkgs ? import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "status-im"; owner = "status-im";
repo = "nixpkgs"; repo = "nixpkgs";
rev = "15623aac6e8cbfa24d4268195bc8eda7303ea2ff"; rev = "15623aac6e8cbfa24d4268195bc8eda7303ea2ff";
sha256 = "0crjmspk65rbpkl3kqcj7433355i9fy530lhc48g2cz75xjk4sxh"; sha256 = "0crjmspk65rbpkl3kqcj7433355i9fy530lhc48g2cz75xjk4sxh";
}) { config = { }; }; }) { config = { }; },
target-os ? "" }:
in with pkgs; with pkgs;
let 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 _stdenv = stdenvNoCC; # TODO: Try to use stdenv for Darwin
statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { stdenv = _stdenv; }; statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { inherit target-os; stdenv = _stdenv; };
statusMobile = callPackage ./scripts/lib/setup/nix/mobile { stdenv = _stdenv; }; statusMobile = callPackage ./scripts/lib/setup/nix/mobile { inherit target-os; stdenv = _stdenv; };
nodeInputs = import ./scripts/lib/setup/nix/global-node-packages/output { nodeInputs = import ./scripts/lib/setup/nix/global-node-packages/output {
# The remaining dependencies come from Nixpkgs # The remaining dependencies come from Nixpkgs
inherit pkgs; inherit pkgs;
@ -36,18 +48,20 @@ in with pkgs;
maven maven
ncurses ncurses
ps # used in scripts/start-react-native.sh ps # used in scripts/start-react-native.sh
statusDesktop.buildInputs
statusMobile.buildInputs
watchman watchman
unzip unzip
wget wget
] ++ nodePkgs ] ++ nodePkgs
++ lib.optional isDarwin cocoapods ++ lib.optional isDarwin cocoapods
++ lib.optional isLinux gcc7; ++ lib.optional isLinux gcc7
shellHook = '' ++ lib.optional targetDesktop statusDesktop.buildInputs
${statusDesktop.shellHook} ++ lib.optional targetMobile statusMobile.buildInputs;
${statusMobile.shellHook} shellHook =
lib.optionalString targetDesktop statusDesktop.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.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
''; '';
} }

View File

@ -39,6 +39,10 @@ function install_nix() {
} }
function install_android_sdk() { function install_android_sdk() {
if [ -z "$ANDROID_SDK_ROOT" ]; then
return 0
fi
if [ -d "$ANDROID_SDK_ROOT" ]; then if [ -d "$ANDROID_SDK_ROOT" ]; then
cecho "@green[[Android SDK already installed.]]" cecho "@green[[Android SDK already installed.]]"
else else

View File

@ -1,9 +1,17 @@
{ stdenv, pkgs }: { stdenv, pkgs, target-os }:
with pkgs; with pkgs;
with stdenv; with stdenv;
let let
targetLinux = {
"linux" = true;
"" = true;
}.${target-os} or false;
targetWindows = {
"windows" = true;
"" = true;
}.${target-os} or false;
windowsPlatform = callPackage ./windows { }; windowsPlatform = callPackage ./windows { };
appimagekit = callPackage ./appimagekit { }; appimagekit = callPackage ./appimagekit { };
linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; }; linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; };
@ -16,11 +24,13 @@ in
file file
gnupg # Used by appimagetool gnupg # Used by appimagetool
go go
qt5.full ] ++ lib.optional targetLinux [ appimagekit linuxdeployqt patchelf ]
] ++ lib.optional isLinux [ appimagekit linuxdeployqt patchelf ] ++ lib.optional (! targetWindows) qt5.full
++ lib.optional isLinux windowsPlatform.buildInputs; ++ lib.optional targetWindows windowsPlatform.buildInputs;
shellHook = '' shellHook = (if target-os == "windows" then "unset QT_PATH" else ''
export QT_PATH="${qt5.full}" export QT_PATH="${qt5.full}"
export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH" export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH"
''; '') + (lib.optionalString isDarwin ''
export MACOSX_DEPLOYMENT_TARGET=10.9
'');
} }

View File

@ -1,18 +1,22 @@
{ stdenv, pkgs }: { stdenv, pkgs, target-os ? "" }:
with pkgs; with pkgs;
with stdenv; with stdenv;
let let
android-ndk = callPackage ./android-ndk { }; android-ndk = callPackage ./android-ndk { };
targetAndroid = {
"android" = true;
"" = true;
}.${target-os} or false;
in in
{ {
buildInputs = [ buildInputs = lib.optional targetAndroid [
android-ndk android-ndk
openjdk openjdk
]; ];
shellHook = '' shellHook = lib.optionalString targetAndroid ''
export JAVA_HOME="${openjdk}" export JAVA_HOME="${openjdk}"
export ANDROID_HOME=~/.status/Android/Sdk export ANDROID_HOME=~/.status/Android/Sdk
export ANDROID_SDK_ROOT="$ANDROID_HOME" export ANDROID_SDK_ROOT="$ANDROID_HOME"