mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-18 04:43:28 +00:00
fix: make Android SDK env vars conditional on abidir
ANDROID_SDK_ROOT, ANDROID_NDK_HOME, and androidManifest are only needed for Android builds (when abidir is set). Making them unconditional causes evaluation failures on aarch64-darwin since the Android SDK overlay doesn't support that platform. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
af08e3eac6
commit
161bc02ad4
@ -21,7 +21,9 @@ let
|
||||
|
||||
revision = lib.substring 0 8 (src.rev or "dirty");
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
|
||||
|
||||
in stdenv.mkDerivation (rec {
|
||||
|
||||
pname = "logos-messaging-nim";
|
||||
|
||||
@ -49,7 +51,12 @@ in stdenv.mkDerivation rec {
|
||||
with pkgs; [
|
||||
cmake
|
||||
which
|
||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
lsb-release
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
# libtool is needed by libnatpmp to create static archives on macOS
|
||||
pkgs.darwin.cctools
|
||||
] ++ [
|
||||
zerokitRln
|
||||
nim-unwrapped-2_0
|
||||
fakeGit
|
||||
@ -58,12 +65,8 @@ in stdenv.mkDerivation rec {
|
||||
fakeCross
|
||||
];
|
||||
|
||||
# Environment variables required for Android builds
|
||||
ANDROID_SDK_ROOT="${pkgs.androidPkgs.sdk}";
|
||||
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
|
||||
|
||||
makeFlags = targets ++ [
|
||||
"V=${toString verbosity}"
|
||||
@ -71,10 +74,22 @@ in stdenv.mkDerivation rec {
|
||||
"QUICK_AND_DIRTY_NIMBLE=${if quickAndDirty then "1" else "0"}"
|
||||
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
|
||||
"LIBRLN_FILE=${zerokitRln}/target/release/librln.a"
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
# nim-libbacktrace's Makefile hardcodes --host=arm which breaks on aarch64-darwin
|
||||
"USE_LIBBACKTRACE=0"
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
patchShebangs . vendor/nimbus-build-system > /dev/null
|
||||
|
||||
# build_nim.sh guards "rm -rf dist/checksums" with NIX_BUILD_TOP != "/build",
|
||||
# but on macOS the nix sandbox uses /private/tmp/... so the check fails and
|
||||
# dist/checksums (provided via preBuild) gets deleted. Fix the check to skip
|
||||
# the removal whenever NIX_BUILD_TOP is set (i.e. any nix build).
|
||||
substituteInPlace vendor/nimbus-build-system/scripts/build_nim.sh \
|
||||
--replace 'if [[ "''${NIX_BUILD_TOP}" != "/build" ]]; then' \
|
||||
'if [[ -z "''${NIX_BUILD_TOP}" ]]; then'
|
||||
|
||||
make nimbus-build-system-paths
|
||||
make nimbus-build-system-nimble-dir
|
||||
'';
|
||||
@ -82,7 +97,7 @@ in stdenv.mkDerivation rec {
|
||||
# For the Nim v2.2.4 built with NBS we added sat and zippy
|
||||
preBuild = ''
|
||||
ln -s waku.nimble waku.nims
|
||||
|
||||
|
||||
${lib.optionalString (!useSystemNim) ''
|
||||
pushd vendor/nimbus-build-system/vendor/Nim
|
||||
|
||||
@ -97,7 +112,7 @@ in stdenv.mkDerivation rec {
|
||||
cp -r ${callPackage ./sat.nix {}}/. dist/nimble/vendor/sat
|
||||
cp -r ${callPackage ./checksums.nix {}}/. dist/nimble/vendor/checksums
|
||||
cp -r ${callPackage ./zippy.nix {}}/. dist/nimble/vendor/zippy
|
||||
chmod 777 -R dist/nimble csources_v2
|
||||
chmod -R u+w dist/ csources_v2
|
||||
|
||||
popd
|
||||
''}
|
||||
@ -110,10 +125,10 @@ in stdenv.mkDerivation rec {
|
||||
cd $out && zip -r libwaku.aar *
|
||||
'' else ''
|
||||
mkdir -p $out/bin $out/include
|
||||
|
||||
|
||||
# Copy library files
|
||||
cp build/* $out/bin/ 2>/dev/null || true
|
||||
|
||||
|
||||
# Copy the header file
|
||||
cp library/libwaku.h $out/include/
|
||||
'';
|
||||
@ -124,4 +139,7 @@ in stdenv.mkDerivation rec {
|
||||
license = licenses.mit;
|
||||
platforms = stableSystems;
|
||||
};
|
||||
}
|
||||
} // lib.optionalAttrs (abidir != null) {
|
||||
ANDROID_SDK_ROOT = "${pkgs.androidPkgs.sdk}";
|
||||
ANDROID_NDK_HOME = "${pkgs.androidPkgs.ndk}";
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user