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 {
BUILD_PLATFORM = 'android'
TARGET_PLATFORM = 'android'
LANG = 'en_US.UTF-8'
LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -1,16 +1,28 @@
let
pkgs = import ((import <nixpkgs> { }).fetchFromGitHub {
# target-os = [ 'windows' 'linux' 'macos' 'android' 'ios' ]
{ pkgs ? import ((import <nixpkgs> { }).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
'';
}

View File

@ -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

View File

@ -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
'');
}

View File

@ -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"