2019-06-04 16:50:29 +00:00
{ 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
2019-07-19 18:40:03 +00:00
mkShell = ( import ./bootstrapped-shell.nix { inherit stdenv target-os ; inherit ( pkgs ) mkShell git ; } ) ;
2019-06-04 16:50:29 +00:00
# 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_11 ;
go = pkgs . callPackage ./patched-go { inherit baseGo ; } ;
buildGoPackage = pkgs . buildGoPackage . override { inherit go ; } ;
desktop = pkgs . callPackage ./desktop { inherit target-os stdenv status-go pkgs nodejs ; inherit ( pkgs ) darwin ; go = baseGo ; } ;
mobile = pkgs . callPackage ./mobile { inherit target-os config stdenv pkgs mkShell nodejs yarn status-go maven localMavenRepoBuilder mkFilter prod-build-fn ; inherit ( pkgs . xcodeenv ) composeXcodeWrapper ; } ;
status-go = pkgs . callPackage ./status-go { inherit target-os go buildGoPackage ; 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 ; } ;
# Import a function that can build a prod-build target with specified node dependencies Nix expression
prod-build-fn = pkgs . callPackage ./targets/prod-build.nix { inherit stdenv pkgs target-os nodejs localMavenRepoBuilder mkFilter ; } ;
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 maven nodejs ] ;
shellHook =
if target-os == " a n d r o i d " then mobile . android . shellHook else
if target-os == " i o s " then mobile . ios . shellHook else " " ;
} ;
watchman-shell = mkShell {
buildInputs = with pkgs ; [ watchman ] ;
} ;
in {
# CHILD DERIVATIONS
inherit mobile ;
# TARGETS
leiningen = {
shell = leiningen-shell ;
} ;
watchman = {
shell = watchman-shell ;
} ;
shell = {
buildInputs = unique ( [
nodejs
pkgs . python27 # for e.g. gyp
yarn
]
++ optional isDarwin pkgs . cocoapods
++ optional ( isDarwin && ! platform . targetIOS ) pkgs . clang
++ optional ( ! isDarwin ) pkgs . gcc8
++ catAttrs " b u i l d I n p u t s " selectedSources ) ;
shellHook = ''
export PATH = " $ S T A T U S _ R E A C T _ H O M E / n o d e _ m o d u l e s / . b i n : $ P A T H "
$ { concatStrings ( catAttrs " s h e l l H o o k " selectedSources ) }
'' ;
} ;
}