Add Nix development environment

This commit is contained in:
link2xt 2023-02-28 20:23:38 +00:00
parent 84a767dc17
commit dc94b8614d
3 changed files with 240 additions and 4 deletions

View file

@ -22,12 +22,34 @@ subproject _deltachat-core-rust_:
or later by `git submodule update --init --recursive`. If you do this in your or later by `git submodule update --init --recursive`. If you do this in your
home directory, this results in the folder `~/deltachat-android` which is just fine. home directory, this results in the folder `~/deltachat-android` which is just fine.
# Build Using Nix
The repository contains [Nix](https://nixos.org/) development environment
described in `flake.nix` file.
If you don't have Nix installed,
the easiest way is to use [The Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer)
which installs Nix with [Flakes](https://nixos.wiki/wiki/Flakes) feature enabled out of the box
and can be cleanly uninstalled with `/nix/nix-installer uninstall` once you don't need it anymore.
Once you have Nix with Flakes feature set up,
run `nix develop` to start development environment shell.
Nix development environment contains Rust with cross-compilation toolchains and Android SDK.
To [build an APK](https://developer.android.com/studio/build/building-cmdline), run:
```
$ scripts/ndk-make.sh
$ ./gradlew assembleDebug
```
Resulting APK files can be found in
`build/outputs/apk/gplay/debug/` and
`build/outputs/apk/fat/debug/.
# Build Using Dockerfile # Build Using Dockerfile
If you only want to build an APK, the easiest way is to use Another way to build APK is to use provided `Dockerfile`
provided `Dockerfile` with [Docker](https://www.docker.com/) or with [Docker](https://www.docker.com/) or [Podman](https://podman.io/).
[Podman](https://podman.io/). Podman is a drop-in replacement for Docker Podman is a drop-in replacement for Docker that does not require root privileges.
that does not require root privileges.
If you don't have Docker or Podman setup yet, read [how to setup Podman](#setup-podman) If you don't have Docker or Podman setup yet, read [how to setup Podman](#setup-podman)
below. If you don't want to use Docker or Podman, read [how to manually install the below. If you don't want to use Docker or Podman, read [how to manually install the

171
flake.lock generated Normal file
View file

@ -0,0 +1,171 @@
{
"nodes": {
"android": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1677615701,
"narHash": "sha256-htNurglzagPhlXTynUKXolUi8+G2gigZibaH7rdNIw4=",
"owner": "tadfisher",
"repo": "android-nixpkgs",
"rev": "3e68832f40fc9879daa764ba26772231594abafe",
"type": "github"
},
"original": {
"owner": "tadfisher",
"repo": "android-nixpkgs",
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": [
"android",
"nixpkgs"
],
"nixpkgs": [
"android",
"nixpkgs"
]
},
"locked": {
"lastModified": 1677576895,
"narHash": "sha256-EtV2sOcIxqZUVijAb5HyCIq7Oft72bgQ3Me8YlKd5jE=",
"owner": "numtide",
"repo": "devshell",
"rev": "05a1e4a4b02cb7bfc8d031064f9d5a2cc27c8847",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1677407201,
"narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1677560409,
"narHash": "sha256-PIvUIsVNozPXe1FmNe9c6B8Febl3t9+51uBKMJ1Q8o0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9e56d6ec92c8fb4192f1392aa5c4101ad77f2070",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"android": "android",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1677551437,
"narHash": "sha256-KidNaM3fTvixGQwJPrbR4hon6FjT2Doil1Fq1GaeLpA=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "c1df023b1aaded1b65a1f4ad604a98a58ab4db97",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

43
flake.nix Normal file
View file

@ -0,0 +1,43 @@
{
description = "Delta Chat for Android";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
android.url = "github:tadfisher/android-nixpkgs";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, android }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
android-sdk = android.sdk.${system} (sdkPkgs:
with sdkPkgs; [
build-tools-30-0-3
cmdline-tools-latest
ndk-bundle
platform-tools
platforms-android-32
ndk-23-2-8568313
]);
in {
devShells.default = pkgs.mkShell {
ANDROID_SDK_ROOT = "${android-sdk}/share/android-sdk";
ANDROID_NDK_ROOT =
"${android-sdk}/share/android-sdk/ndk/23.2.8568313/";
buildInputs = [
android-sdk
(pkgs.buildPackages.rust-bin.stable."1.64.0".minimal.override {
targets = [
"armv7-linux-androideabi"
"aarch64-linux-android"
"i686-linux-android"
"x86_64-linux-android"
];
})
];
};
});
}