mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-04 07:03:09 +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
|
let
|
||||||
inherit (pkgs) stdenv lib writeScriptBin callPackage;
|
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");
|
version = substring 0 8 (src.sourceInfo.rev or "dirty");
|
||||||
|
|
||||||
@ -34,18 +38,18 @@ in stdenv.mkDerivation rec {
|
|||||||
nativeBuildInputs = let
|
nativeBuildInputs = let
|
||||||
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
|
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
|
||||||
fakeGit = writeScriptBin "git" "echo ${version}";
|
fakeGit = writeScriptBin "git" "echo ${version}";
|
||||||
in
|
in with pkgs; [
|
||||||
with pkgs; [
|
|
||||||
cmake
|
cmake
|
||||||
which
|
which
|
||||||
lsb-release
|
|
||||||
nim-unwrapped-2_2
|
nim-unwrapped-2_2
|
||||||
fakeGit
|
fakeGit
|
||||||
|
] ++ optionals stdenv.isLinux [
|
||||||
|
pkgs.lsb-release
|
||||||
];
|
];
|
||||||
|
|
||||||
# Environment variables required for Android builds
|
ANDROID_SDK_ROOT = optionalString isAndroidBuild pkgs.androidPkgs.sdk;
|
||||||
ANDROID_SDK_ROOT = "${pkgs.androidPkgs.sdk}";
|
ANDROID_NDK_HOME = optionalString isAndroidBuild pkgs.androidPkgs.ndk;
|
||||||
ANDROID_NDK_HOME = "${pkgs.androidPkgs.ndk}";
|
|
||||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${version}";
|
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${version}";
|
||||||
XDG_CACHE_HOME = "/tmp";
|
XDG_CACHE_HOME = "/tmp";
|
||||||
|
|
||||||
@ -68,8 +72,7 @@ in stdenv.mkDerivation rec {
|
|||||||
androidManifest = ''
|
androidManifest = ''
|
||||||
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"org.waku.${pname}\" />
|
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"org.waku.${pname}\" />
|
||||||
'';
|
'';
|
||||||
containsAndroid = s: (match ".*android.*" s) != null;
|
in if isAndroidBuild then ''
|
||||||
in if (any containsAndroid targets) then ''
|
|
||||||
mkdir -p $out/jni
|
mkdir -p $out/jni
|
||||||
cp -r build/* $out/jni/
|
cp -r build/* $out/jni/
|
||||||
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
|
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
|
||||||
|
|||||||
@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
{ androidenv, lib, stdenv }:
|
{ 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
|
# The "android-sdk-license" license is accepted
|
||||||
# by setting android_sdk.accept_license = true.
|
# by setting android_sdk.accept_license = true.
|
||||||
androidenv.composeAndroidPackages {
|
androidenv.composeAndroidPackages {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user