Newer
Older
{
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 = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
pypi-deps-db.follows = "pypi-deps-db";
};
};
buildozerSrc = {
flake = false;
url = "github:PrivateStorageio/buildozer?ref=build-without-installing";
};
pythonForAndroidSrc = {
flake = false;
url = "github:PrivateStorageio/python-for-android?ref=work-on-nixos";
};
};
outputs = { self, nixpkgs, flake-utils, mach-nix-flake, buildozerSrc, pythonForAndroidSrc, ... }:
flake-utils.lib.eachSystem [
"x86_64-linux"
] (system: let
mach-nix = mach-nix-flake.lib.${system};
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
lib = pkgs.lib;
python-for-android = mach-nix.buildPythonPackage {
src = pythonForAndroidSrc;
requirementsExtra = ''
sh>=1.10
'';
};
buildozer = mach-nix.buildPythonPackage {
src = buildozerSrc;
packagesExtra = [ ];
};
kivy-env = mach-nix.mkPython {
python = "python39";
requirements = ''
kivy
Pillow
cython
'';
packagesExtra = [ python-for-android buildozer ];
};
cmakeVersion = "3.10.2";
# Also includes ndk
androidComposition = pkgs.callPackage ./android.nix { inherit cmakeVersion; };
getBuildInputs = getInputs: xs: builtins.foldl' (accum: drv: (getInputs drv) ++ accum) [] xs;
chaquopy-env = mach-nix.mkPython {
python = "python39";
requirements = ''
chaquopy
'';
};
in {
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
packages.default = pkgs.androidenv.buildApp {
name = "PrivateStorage Mobile";
src = ./app;
release = false;
platformVersions = [ "27" ];
includeNDK = false;
};
apps.emulator = {
type = "app";
program = let
emulator = pkgs.androidenv.emulateApp {
name = "PrivateStorage Mobile";
platformVersion = "27";
abiVersion = "x86_64";
systemImageType = "default";
app = ./app/app/build/outputs/apk/debug/app-debug.apk;
package = "MyApp";
activity = "MainActivity";
};
in
"${emulator}/bin/emulate-it???";
};
devShells.gradle = pkgs.mkShell rec {
name = "nix-native";
version = "2022.11.09";
ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle";
buildInputs = with pkgs; [
# XXXX
# gradle finds an aapk2 from some random tgz it downloads from internet instead of from our ANDROIDSDK! GREAT!!!!!!!!!!11111
#
# Fix the one it downloads, if it didn't already root you, with:
#
# patchelf --set-interpreter <correct ld.so> ~/.gradle/<...path to aapt2>
gradle
ant
# openjdk8
android-studio
android-tools
python39
];
};
devShells.default = self.devShells.${system}.gradle;
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md
# is a good reference for this stuff.
devShells.kivy = 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
kivy-env
# https://github.com/kivy/python-for-android/blob/v2020.04.29/doc/source/troubleshooting.rst#errors-related-to-java-version
openjdk8
Jean-Paul Calderone
committed
# python-for-android recipes all want to download and unpack their
# own sources! aaaaaa
unzip
] ++
# Also we need build dependencies for all of the things it is going to
# build!
(getBuildInputs (drv: drv.buildInputs) [ openssl libffi python39 ]);
nativeBuildInputs =
with pkgs; getBuildInputs (drv: drv.nativeBuildInputs) [ openssl libffi python39 ];