{ # inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=3d58e3a31ee55554fe26650bb59db7d6d0e97625"; # inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=fd83da2b640e05c6dd14fad4b741714b069ae0d7"; inputs.nixpkgs.url = "github:NixOS/nixpkgs"; # inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-22.05"; # inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-22.11"; # inputs.mach-nix.url = "github:DavHau/mach-nix"; outputs = { self , nixpkgs # , mach-nix }: let native-pkgs = import nixpkgs { system = "x86_64-linux"; config = { allowUnfree = true; android_sdk.accept_license = true; }; }; cross-pkgs = native-pkgs.pkgsCross.aarch64-android; platformVersion = "31"; cmakeVersion = "3.10.2"; buildToolsVersion = "30.0.0"; # Check out pkgs/development/mobile/androidenv/repo.json for # nixpkgs-supported versions. ndkVersion = "23.0.7123448-rc1"; androidComposition = native-pkgs.callPackage ../android.nix { inherit cmakeVersion buildToolsVersion platformVersion ndkVersion; }; # mach-nix' = native-pkgs.callPackage mach-nix { # python = "python3Minimal"; # }; in { devShells.x86_64-linux.default = native-pkgs.mkShell rec { BUILD_PYTHON = "${native-pkgs.python3}/bin/python"; HOST_PYTHON = "${cross-pkgs.python3Minimal}/bin/python"; ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk"; ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle"; CROSSENV_WHEEL = native-pkgs.fetchurl { url = "https://files.pythonhosted.org/packages/46/11/8bdda7df08c5d7566a518bb422e305f11980d2be1d1ca9b3fb6806097762/crossenv-1.3.0-py3-none-any.whl"; sha256 = "sha256-bdkjYJChMU+810cd8MN5/b82KCsMzQJ7WPoayKTwRyE="; }; nativeBuildInputs = [ # expose ffi header and library so we can build cffi, itself used by # various other Python packages cross-pkgs.libffi ]; setupCrossEnv = '' # Create a virtualenv with software we can run on the build system. $BUILD_PYTHON -m venv build-env # Put crossenv into that build environment so we can use it to # manage the cross build. ./build-env/bin/pip install crossenv # Create a cross build environment with crossenv. It doesn't find # CC on its own, so help it out. Also tell it where a Python # configured for the host system can be found, so it can extra more # details from it. ./build-env/bin/python -m crossenv --cc $CC $HOST_PYTHON ./cross-env # Activate the cross build environment for interactive use. . ./cross-env/bin/activate ''; shellHook = '' # Point at the compiler that can build for the host platform. This # seems like a plausible choice but it doesn't actually match the # compiler used to build the host Python so maybe it is wrong. export CC="${ANDROIDNDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android${platformVersion}-clang" # Let cffi build find ffi.h export CFLAGS=$NIX_CFLAGS_COMPILE # Let cffi build find libffi.so export LDFLAGS=$NIX_LDFLAGS ''; }; }; }