From 6a3697e85fbd4787bd025b7fbb14356a505576ba Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Tue, 6 Dec 2022 05:41:57 -0500
Subject: [PATCH] update notes

---
 Notes.rst          | 36 ++++++++++++++++++++++++++++++++++++
 crossenv/flake.nix | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 crossenv/flake.nix

diff --git a/Notes.rst b/Notes.rst
index 0a315c2..7d27d8b 100644
--- a/Notes.rst
+++ b/Notes.rst
@@ -4,6 +4,29 @@
 
     * Build an app that can read magic-folders and download linked files
 
+      * Build libchallenge_bypass_ristretto for armv7a and aarch64 Android
+
+	* nixpkgs *used to* use "crates-io.nix" which was quite friendly to cross-compilation!
+
+	  But it got thrown in the trash and now you are directed to naersk or crate2nix.
+
+	* cross-compilation with crate2nix expressions is not straightforward
+
+	  Does it work at all, for anything?
+	  Who knows.
+	  There's a ticket open.
+	  I haven't yet figured out how to make it go.
+
+	* naersk looks super easy to use!
+
+	  But does it support cross-compilation?
+	  It is not clear.
+	  (Naive?) Attempts to do so on nixpkgs master@HEAD fail with infinite recursion errors.
+	  On nixos-22.05 with some patches applied ... maybe it will work?
+	  (As of 2022-12-05 16:04, build is still running)
+
+	* Either way we need to preserve our postInstall step to get the .h and .pc files
+
       * Build an app that runs a Haskell Tahoe-LAFS implementation on Android
 
 	* Reflex-FRP / Obsidian Systems Obelisk?
@@ -180,8 +203,21 @@
                         (by inspection with builtins.trace)
 
               * python-cryptography
+
+		* cffi-based projects seem to be tricky!
+
               * python-challenge-bypass-ristretto
 
+	    * crossenv can do it!
+	      See crossenv subdirectory.
+
+	      * However, crossenv can't do python-challenge-bypass-ristretto
+                or python-cryptography.
+
+		These seem to have cffi as a build-time dependency.
+		Cross-env gives the build pip env the host cffi .so so it fails.
+
+
           * Integrate a Python Tahoe-LAFS runtime with a GUI
 
             * Build a GUI
diff --git a/crossenv/flake.nix b/crossenv/flake.nix
new file mode 100644
index 0000000..7179373
--- /dev/null
+++ b/crossenv/flake.nix
@@ -0,0 +1,33 @@
+{
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=3d58e3a31ee55554fe26650bb59db7d6d0e97625";
+  outputs = { self, nixpkgs }:
+    let
+      native-pkgs = import nixpkgs {
+        system = "x86_64-linux";
+        allowUnfree = true;
+        android_sdk.accept_license = true;
+      };
+      cross-pkgs = native-pkgs.pkgsCross.aarch64-android;
+
+      platformVersion = "31";
+      cmakeVersion = "3.10.2";
+      buildToolsVersion = "31.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;
+      };
+
+    in {
+      devShells.x86_64-linux.default = native-pkgs.mkShell rec {
+        BUILD_PYTHON = "${native-pkgs.python3Minimal}/bin/python";
+        HOST_PYTHON = "${cross-pkgs.python3Minimal}/bin/python";
+        ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk";
+        ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle";
+        shellHook = ''
+          export PATH="$(echo "$ANDROIDSDK/cmake/${cmakeVersion}".*/bin):$PATH"
+        '';
+      };
+    };
+}
-- 
GitLab