build: reproducible Nix environment for Android and Wear OS #1
No files matched your search
@@ -0,0 +1,3 @@
|
||||
watch_file devenv.nix devenv.yaml devenv.lock
|
||||
eval "$(devenv direnvrc)"
|
||||
use devenv
|
||||
@@ -49,6 +49,11 @@ faceclaw_settings.xml
|
||||
faceclaw_settings*.json
|
||||
|
||||
# Developer configs
|
||||
.devenv*
|
||||
.direnv/
|
||||
.android/
|
||||
devenv.local.nix
|
||||
local.properties
|
||||
build_paths.sh
|
||||
**/xcuserdata/
|
||||
|
||||
|
||||
@@ -162,6 +162,14 @@ tasks.register("prepareFaceclawNativeLibs") {
|
||||
def faceclawLlamaCppTag = "b10333"
|
||||
|
||||
def faceclawFindSdkCmakeDir = {
|
||||
// NixOS and other managed environments can provide patched host tools.
|
||||
def explicitCmake = System.getenv("ANDROID_CMAKE_HOME")
|
||||
if (explicitCmake != null) {
|
||||
def explicitDir = file(explicitCmake)
|
||||
if (faceclawHostExecutable(file("$explicitDir/bin"), "cmake").exists()
|
||||
&& faceclawHostExecutable(file("$explicitDir/bin"), "ninja").exists()) return explicitDir
|
||||
throw new GradleException("ANDROID_CMAKE_HOME must contain bin/cmake and bin/ninja: $explicitDir")
|
||||
}
|
||||
def sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
|
||||
if (sdkRoot == null) return null
|
||||
def cmakeRoot = file("$sdkRoot/cmake")
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"nodes": {
|
||||
"devenv": {
|
||||
"locked": {
|
||||
"dir": "src/modules",
|
||||
"lastModified": 1793731702,
|
||||
"narHash": "sha256-WlVNaWXVTYaGBNey2Z+20sY1lT7BvzJEECb+VlDDdk0=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "9655d320b8f9df74dbecf681f52a7334574606c3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "src/modules",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"inputs": {
|
||||
"nixpkgs-src": "nixpkgs-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793043970,
|
||||
"narHash": "sha256-m14odYTdkBUEkJOiEYs2zjGjn8fcjvdCJsm45+k084U=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"rev": "d97234e58d4e90e3bf77c082fc3b546e51200938",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"ref": "rolling",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1792812153,
|
||||
"narHash": "sha256-T2+XBfNbf9pecLUWS4+RtuVNZ3W8K5taG5QdV71mWlk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "674a2028661e550a97400c1cc992b9cca9a668a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devenv": "devenv",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
{
|
||||
languages.javascript = {
|
||||
enable = true;
|
||||
package = pkgs.nodejs_22;
|
||||
};
|
||||
languages.java = {
|
||||
enable = true;
|
||||
jdk.package = pkgs.jdk21;
|
||||
lsp.enable = false;
|
||||
};
|
||||
android = {
|
||||
enable = true;
|
||||
platforms.version = [ "35" ];
|
||||
buildTools.version = [ "34.0.0" "35.0.0" "35.0.1" ];
|
||||
ndk.enable = true;
|
||||
ndk.version = [ "27.2.12479018" ];
|
||||
cmake.version = [ ];
|
||||
emulator.enable = false;
|
||||
systemImages.enable = false;
|
||||
sources.enable = false;
|
||||
};
|
||||
packages = with pkgs; [ git gh curl jq ripgrep python3 pkg-config gnumake gcc unzip zip ];
|
||||
# Gradle's downloaded aapt2 cannot run directly on NixOS.
|
||||
# Keep API 35 aapt2 for phone builds even with Wear's older tools installed.
|
||||
env.GRADLE_OPTS = lib.mkForce "-Dorg.gradle.project.android.aapt2FromMavenOverride=${config.env.ANDROID_HOME}/build-tools/35.0.0/aapt2";
|
||||
# NativeScript's doctor rejects a valid build-only SDK without an emulator.
|
||||
# enterTest below checks the actual tools used by our local builds.
|
||||
env.NS_SKIP_ENV_CHECK = "1";
|
||||
env.ANDROID_CMAKE_HOME = "${pkgs.symlinkJoin {
|
||||
name = "faceclaw-cmake";
|
||||
paths = [ pkgs.cmake pkgs.ninja ];
|
||||
}}";
|
||||
scripts.faceclaw-setup.exec = "npm ci";
|
||||
scripts.faceclaw-test.exec = "npm test";
|
||||
enterShell = ''
|
||||
export PATH="$DEVENV_ROOT/node_modules/.bin:$PATH"
|
||||
'';
|
||||
enterTest = ''
|
||||
bash "$DEVENV_ROOT/scripts/check-devenv.sh"
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
inputs:
|
||||
nixpkgs:
|
||||
url: github:cachix/devenv-nixpkgs/rolling
|
||||
nixpkgs:
|
||||
allow_unfree: true
|
||||
android_sdk:
|
||||
accept_license: true
|
||||
@@ -0,0 +1,29 @@
|
||||
# Nix development environment
|
||||
|
||||
Install Nix with flakes and devenv, then run `devenv shell` in this directory
|
||||
(or `nix run nixpkgs#devenv -- shell`). With direnv, `direnv allow` loads `.envrc`.
|
||||
The committed `devenv.lock` pins the environment inputs.
|
||||
|
||||
The environment provides Node 22/npm, Java 21, Android SDK/platform 35,
|
||||
build-tools 34.0.0 (Wear OS) and 35.0.0/35.0.1 (phone and NativeScript plugins), NDK 27, CMake,
|
||||
Git/GitHub CLI, Python and build utilities. `ANDROID_CMAKE_HOME` selects the
|
||||
Nix-patched CMake/Ninja pair for the native Android libraries (the SDK's bundled
|
||||
Ninja can crash on NixOS). Other environments keep using the SDK's CMake.
|
||||
Android SDK licenses are accepted through `devenv.yaml`. Gradle uses the
|
||||
Nix-patched SDK aapt2. Gradle itself comes from the repository's wrapper.
|
||||
The emulator and system images are omitted. `NS_SKIP_ENV_CHECK=1` bypasses
|
||||
NativeScript doctor's mandatory emulator check; `devenv test` checks the actual
|
||||
SDK/JDK build prerequisites instead.
|
||||
|
||||
Run `faceclaw-setup` (`npm ci`) once, then `faceclaw-test` (`npm test`),
|
||||
`npm run lint` and `npm run test:kotlin`. `devenv test` checks the environment.
|
||||
`bash build.sh` builds the Android app; it does not install it. On NixOS, any
|
||||
additional downloaded native executables may require the host's nix-ld support.
|
||||
iOS builds still require macOS/Xcode and are outside this Linux environment.
|
||||
|
||||
Keep machine-specific signing/device settings in the ignored `build_paths.sh`.
|
||||
Use `gh auth login` separately if GitHub CLI is not already authenticated.
|
||||
|
||||
Software tests do not validate Bluetooth behavior on physical glasses. Record
|
||||
device/firmware versions and manual results separately for hardware checks.
|
||||
Do not flash firmware during development without explicit permission.
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
node --version
|
||||
java -version
|
||||
test -f "$ANDROID_HOME/platforms/android-35/android.jar"
|
||||
for version in 34.0.0 35.0.0 35.0.1; do
|
||||
"$ANDROID_HOME/build-tools/$version/aapt2" version
|
||||
done
|
||||
"$ANDROID_HOME/platform-tools/adb" version
|
||||
"$ANDROID_CMAKE_HOME/bin/cmake" --version
|
||||
"$ANDROID_CMAKE_HOME/bin/ninja" --version
|
||||
case "$(uname -s)" in
|
||||
Darwin) ndk_host=darwin-x86_64 ;;
|
||||
*) ndk_host=linux-x86_64 ;;
|
||||
esac
|
||||
test -x "$ANDROID_HOME/ndk/27.2.12479018/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
|
||||
echo "Faceclaw development tools verified."
|
||||
Reference in new issue
Block a user