Siddarth Kumar 1ee16da0c7
nix: point to nixpkgs unstable channel for gradle 8.8 (#21267)
nix: use nixpkgs unstable for gradle 8.8

nix: ldflags are expected to be a list

chore: fix deprecated vendorSha256

nix: bump jdk to 17 & pass java version to gradle

make: set universalApk false in run-android target

nix: fix --replace deprecation warning

  - https://github.com/NixOS/nixpkgs/pull/260776

ios: update pod and gem lockfiles

nix: bump nodejs to 20.12.2

nix: add Xcode 16.0 to allowed versions

chore: upgrade rn-image-crop-picker lib

nix: full path for missing dep in node_modules sh

e2e: removed redundant element

---------

Co-authored-by: Yevheniia Berdnyk <ie.berdnyk@gmail.com>
2024-09-20 15:01:42 +05:30

76 lines
2.4 KiB
Nix

{ callPackage, lib, buildGoPackage
, androidPkgs, openjdk, gomobile, xcodeWrapper, removeReferencesTo
, meta
, source
, platform ? "android"
, platformVersion ? "23"
, targets ? [ "android/arm64" "android/arm" ]
, goBuildFlags ? [ ] # Use -v or -x for debugging.
, goBuildLdFlags ? [ ]
, outputFileName ? "status-go-${source.shortRev}-${platform}.aar" }:
let
inherit (lib) concatStringsSep optionalString optional splitString;
isIOS = platform == "ios";
isAndroid = platform == "android";
enforceXCodeAvailable = callPackage ./enforceXCodeAvailable.nix { };
in buildGoPackage {
pname = source.repo;
version = "${source.cleanVersion}-${source.shortRev}-${platform}";
inherit meta;
inherit (source) src goPackagePath;
# Sandbox causes Xcode issues on MacOS. Requires sandbox=relaxed.
# https://github.com/status-im/status-mobile/pull/13912
__noChroot = isIOS;
extraSrcPaths = [ gomobile ];
nativeBuildInputs = [ gomobile removeReferencesTo ]
++ optional isAndroid openjdk
++ optional isIOS xcodeWrapper;
ldflags = goBuildLdFlags;
ANDROID_HOME = optionalString isAndroid androidPkgs.sdk;
# Ensure XCode is present for iOS, instead of failing at the end of the build.
preConfigure = optionalString isIOS enforceXCodeAvailable;
# https://pkg.go.dev/net#hdr-Name_Resolution
# https://github.com/status-im/status-mobile/issues/19736
# https://github.com/status-im/status-mobile/issues/19581
# TODO: try removing when go is upgraded to 1.22
GODEBUG = "netdns=cgo+2";
buildPhase = ''
runHook preBuild
echo -e "\nBuilding $pname for: ${concatStringsSep "," targets}"
gomobile bind \
${concatStringsSep " " goBuildFlags} \
-ldflags="$ldflags" \
-target=${concatStringsSep "," targets} \
${optionalString isAndroid "-androidapi=${platformVersion}" } \
${optionalString isIOS "-iosversion=${platformVersion}" } \
-tags='${optionalString isIOS "nowatchdog"} gowaku_skip_migrations gowaku_no_rln' \
-o ${outputFileName} \
${source.goPackagePath}/mobile
runHook postBuild
'';
installPhase = ''
mkdir -p $out
cp -r ${outputFileName} $out/
'';
# Drop govers from disallowedReferences.
dontRenameImports = true;
# Replace hardcoded paths to go package in /nix/store.
preFixup = optionalString isIOS ''
find $out -type f -exec \
remove-references-to -t $disallowedReferences '{}' + || true
'';
}