From 19cf564251507617982cd1ed1da66de317b38ff0 Mon Sep 17 00:00:00 2001 From: Guillaume ETHEVE Date: Thu, 5 Nov 2026 23:52:02 +0100 Subject: [PATCH] chore: add pinned Nix development environment --- .envrc | 3 ++ .gitignore | 3 ++ devenv.lock | 65 +++++++++++++++++++++++++++++++++++++++++ devenv.nix | 36 +++++++++++++++++++++++ devenv.yaml | 7 +++++ docs/development-nix.md | 23 +++++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 .envrc create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml create mode 100644 docs/development-nix.md diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..7b430716 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +watch_file devenv.nix devenv.yaml devenv.lock +eval "$(devenv direnvrc)" +use devenv diff --git a/.gitignore b/.gitignore index 6659b26a..eb9e8427 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ faceclaw_settings.xml faceclaw_settings*.json # Developer configs +.devenv* +.direnv/ +devenv.local.nix build_paths.sh **/xcuserdata/ diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 00000000..76a4dbe1 --- /dev/null +++ b/devenv.lock @@ -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 +} \ No newline at end of file diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 00000000..2dbd18c0 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,36 @@ +{ pkgs, config, ... }: +{ + languages.javascript = { + enable = true; + package = pkgs.nodejs_22; + }; + languages.java = { + enable = true; + jdk.package = pkgs.jdk17; + }; + android = { + enable = true; + platforms.version = [ "35" ]; + buildTools.version = [ "35.0.0" ]; + ndk.enable = true; + ndk.version = [ "27.2.12479018" ]; + cmake.version = [ "3.22.1" ]; + 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. + env.GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${config.env.ANDROID_HOME}/build-tools/35.0.0/aapt2"; + scripts.faceclaw-setup.exec = "npm ci"; + scripts.faceclaw-test.exec = "npm test"; + enterShell = '' + export PATH="$DEVENV_ROOT/node_modules/.bin:$PATH" + ''; + enterTest = '' + node --version + java -version + test -f "$ANDROID_HOME/platforms/android-35/android.jar" + test -x "$ANDROID_HOME/build-tools/35.0.0/aapt2" + ''; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 00000000..e950cd74 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,7 @@ +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling +nixpkgs: + allow_unfree: true + android_sdk: + accept_license: true diff --git a/docs/development-nix.md b/docs/development-nix.md new file mode 100644 index 00000000..5c29b52c --- /dev/null +++ b/docs/development-nix.md @@ -0,0 +1,23 @@ +# 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 17, Android SDK/platform 35, +build-tools 35.0.0, NDK 27, CMake, Git/GitHub CLI, Python and build utilities. +Android SDK licenses are accepted through `devenv.yaml`. Gradle uses the +Nix-patched SDK aapt2. Gradle itself comes from the repository's wrapper. + +Run `faceclaw-setup` (`npm ci`) once, then `faceclaw-test` (`npm test`), +`npm run lint` and `npm run test:kotlin`. `devenv test` checks the environment. +`./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.