mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-02 14:13:07 +00:00
nix: fix Android builds on Darwin platforms
The assert for Android NDK is obsolete. But we also can avoid fetching the Android dependencies when not building for Android. Also, lsb-release is a linux-only tool. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
a8060c5600
commit
cb472bc829
@ -16,7 +16,11 @@ assert pkgs.lib.assertMsg ((src.submodules or true) == true)
|
||||
|
||||
let
|
||||
inherit (pkgs) stdenv lib writeScriptBin callPackage;
|
||||
inherit (lib) any match substring;
|
||||
inherit (lib) any match substring optionals optionalString;
|
||||
|
||||
# Check if build is for android platform.
|
||||
containsAndroid = s: (match ".*android.*" s) != null;
|
||||
isAndroidBuild = any containsAndroid targets;
|
||||
|
||||
version = substring 0 8 (src.sourceInfo.rev or "dirty");
|
||||
|
||||
@ -34,18 +38,18 @@ in stdenv.mkDerivation rec {
|
||||
nativeBuildInputs = let
|
||||
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
|
||||
fakeGit = writeScriptBin "git" "echo ${version}";
|
||||
in
|
||||
with pkgs; [
|
||||
in with pkgs; [
|
||||
cmake
|
||||
which
|
||||
lsb-release
|
||||
nim-unwrapped-2_2
|
||||
fakeGit
|
||||
] ++ optionals stdenv.isLinux [
|
||||
pkgs.lsb-release
|
||||
];
|
||||
|
||||
# Environment variables required for Android builds
|
||||
ANDROID_SDK_ROOT = "${pkgs.androidPkgs.sdk}";
|
||||
ANDROID_NDK_HOME = "${pkgs.androidPkgs.ndk}";
|
||||
ANDROID_SDK_ROOT = optionalString isAndroidBuild pkgs.androidPkgs.sdk;
|
||||
ANDROID_NDK_HOME = optionalString isAndroidBuild pkgs.androidPkgs.ndk;
|
||||
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${version}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
|
||||
@ -68,8 +72,7 @@ in stdenv.mkDerivation rec {
|
||||
androidManifest = ''
|
||||
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"org.waku.${pname}\" />
|
||||
'';
|
||||
containsAndroid = s: (match ".*android.*" s) != null;
|
||||
in if (any containsAndroid targets) then ''
|
||||
in if isAndroidBuild then ''
|
||||
mkdir -p $out/jni
|
||||
cp -r build/* $out/jni/
|
||||
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
|
||||
{ androidenv, lib, stdenv }:
|
||||
|
||||
assert lib.assertMsg (stdenv.system != "aarch64-darwin")
|
||||
"aarch64-darwin not supported for Android SDK. Use: NIXPKGS_SYSTEM_OVERRIDE=x86_64-darwin";
|
||||
|
||||
# The "android-sdk-license" license is accepted
|
||||
# by setting android_sdk.accept_license = true.
|
||||
androidenv.composeAndroidPackages {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user