diff --git a/android.nix b/android.nix
new file mode 100644
index 0000000000000000000000000000000000000000..30309a0e642a6983d924ef5320a1e4a3809af076
--- /dev/null
+++ b/android.nix
@@ -0,0 +1,25 @@
+{ androidenv, cmakeVersion }:
+let
+  androidComposition = androidenv.composeAndroidPackages {
+    toolsVersion = "26.1.1";
+    # platformToolsVersion = "30.0.5";
+    buildToolsVersions = [ "30.0.3" ];
+    includeEmulator = false;
+    emulatorVersion = "30.3.4";
+    platformVersions = [ "27" "28" "29" "30" ];
+    includeSources = false;
+    includeSystemImages = false;
+    systemImageTypes = [ "google_apis_playstore" ];
+    abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
+    cmakeVersions = [ cmakeVersion ];
+    includeNDK = true;
+    # Check out pkgs/development/mobile/androidenv/repo.json
+    ndkVersions = [ "23.0.7123448-rc1" "22.0.7026061" ];
+    useGoogleAPIs = false;
+    useGoogleTVAddOns = false;
+    includeExtras = [
+      "extras;google;gcm"
+    ];
+  };
+in
+androidComposition
diff --git a/flake.lock b/flake.lock
index 439020b2d77bcd3c25ee35b984e207a824939198..0a5cd5b9c0f4688c34af7569c0fb77d5936e74d6 100644
--- a/flake.lock
+++ b/flake.lock
@@ -43,15 +43,16 @@
     },
     "nixpkgs": {
       "locked": {
-        "lastModified": 1667933212,
-        "narHash": "sha256-Iu5yhT4nr+IsGPnk61eTKLmffPRL0dwJpWBlIFnAXvY=",
+        "lastModified": 1667821506,
+        "narHash": "sha256-u4HKBBfTOPpFsGnM7sjS0+F67Hmf2or3uHKNVxXZtiM=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "0ab419f97ad748a3150183d3e0706e949924de7a",
+        "rev": "ebf65554b18ee053311f43e5faa5a3f36626c52e",
         "type": "github"
       },
       "original": {
         "owner": "NixOS",
+        "ref": "nixos-22.05",
         "repo": "nixpkgs",
         "type": "github"
       }
diff --git a/flake.nix b/flake.nix
index 2bdd07122fb6f5d1345eb1809f3e603d1905664f..229981c6e16c3aee754517342d9a4af2012edc87 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,23 +1,23 @@
 {
   description = "The PrivateStorage Mobile application";
   inputs = {
+    nixpkgs = {
+      url = "github:NixOS/nixpkgs?ref=nixos-22.05";
+    };
+    flake-utils.url = "github:numtide/flake-utils";
+    pypi-deps-db = {
+      flake = false;
+      url = "github:DavHau/pypi-deps-db";
+    };
     mach-nix-flake = {
       flake = true;
       url = "github:DavHau/mach-nix";
       inputs = {
-        pypi-deps-db.follows = "pypi-deps-db";
         nixpkgs.follows = "nixpkgs";
         flake-utils.follows = "flake-utils";
+        pypi-deps-db.follows = "pypi-deps-db";
       };
     };
-    nixpkgs = {
-      url = "github:NixOS/nixpkgs";
-    };
-    flake-utils.url = "github:numtide/flake-utils";
-    pypi-deps-db = {
-      flake = false;
-      url = "github:DavHau/pypi-deps-db";
-    };
   };
   outputs = { self, nixpkgs, flake-utils, mach-nix-flake, ... }:
     flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let
@@ -25,7 +25,10 @@
       mach-nix = mach-nix-flake.lib.${system};
       pkgs = import nixpkgs {
         inherit system;
-        config = { allowUnfree = true; };
+        config = {
+          allowUnfree = true;
+          android_sdk.accept_license = true;
+        };
       };
       lib = pkgs.lib;
 
@@ -40,18 +43,32 @@
         '';
       };
 
+      cmakeVersion = "3.10.2";
+
+      # Also includes ndk
+      androidComposition = pkgs.callPackage ./android.nix { inherit cmakeVersion; };
+
     in {
-      devShells.default = pkgs.mkShell {
+      # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md
+      # is a good reference for this stuff.
+      devShells.default = pkgs.mkShell rec {
         name = "ps-mobile";
         version = "2022.10.21";
 
+        # The docs talk about ANDROID_SDK_ROOT but apparently it has been
+        # renamed yet again.
+        ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk";
+        ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle";
+
+        shellHook = ''
+        export PATH="$(echo "$ANDROIDSDK/cmake/${cmakeVersion}".*/bin):$PATH"
+        '';
+
+
         buildInputs = with pkgs; [
           android-studio
-          android-tools
-          androidndkPkgs_23b.binaries
-          androidndkPkgs_23b.binutils
-          androidndkPkgs_23b.libraries
           kivy-env
+          openjdk8
         ];
       };
     });