chore: add nix flake dev shell - #1238
Conversation
The PR appears safe to merge, with a non-blocking concern that the shell hook can persistently overwrite a developer’s custom Nix-store aapt2 configuration. Findings
|
| if grep -qs '^android.aapt2FromMavenOverride=' "$gradle_props"; then | ||
| # Refresh overrides previously written by this hook (stale store | ||
| # paths break after a flake update + gc); leave custom ones alone. | ||
| sed -i "s|^android.aapt2FromMavenOverride=/nix/store/.*|android.aapt2FromMavenOverride=$aapt2|" "$gradle_props" |
There was a problem hiding this comment.
Custom override is overwritten
If a developer has intentionally configured an aapt2 override under /nix/store/, entering this shell replaces it because the pattern treats every Nix-store value as hook-owned. The hook edits the persistent user-level Gradle properties file, so this non-blocking issue can also change aapt2 behavior in unrelated Gradle projects. Track which value the hook generated instead of using the /nix/store/ prefix as ownership.
|
@icota Awesome idea! |
|
This could potentially fix #953 |
To fully address that, we may need this for the rust repos too, or some Still, might need again to add the same change to all repos which build rust deps consumed by bitkit. |
jvsena42
left a comment
There was a problem hiding this comment.
Checked the things that actually go wrong with a flake — clean, no findings.
- Pinning is correct. One input (
github:NixOS/nixpkgs/nixos-unstable), pinned inflake.lockto revd6524aaca2ff…with a matchingnarHash, and the lock'soriginalblock matches the flake exactly. The floatingnixos-unstableref is only the update target —nix developresolves through the lock.cmdLineToolsVersion/platformToolsVersion = "latest"resolve against the locked nixpkgs, so they're deterministic too. Nothing is fetched from an unpinned or non-content-addressed source at eval time. - Toolchain matches CI exactly, so no "works on my machine" divergence: JDK 17 against
java-version: '17'in all seven workflows; NDK28.1.13356709againstJustfile:6ndk_verandNDK_VERSIONin both release workflows;platformVersions = ["36"]againstcompileSdk/targetSdk = 36(app/build.gradle.kts:183,:188). Gradle 9.5.0 via the checked-in wrapper, AGP 9.3.0 — JDK 17 satisfies both, and the repo pins no JVM elsewhere (nojvmToolchain, noorg.gradle.java.home). - Nothing breaks non-nix contributors. The repo root had no
flake.nix/shell.nix/.envrc/.tool-versions/mise.tomlbefore this, so there's no competing toolchain spec, and.gitignorehas no pattern that would leaveflake.lockuntracked and let it drift. Nothing Gradle, detekt orjustreads picks up either file.
The ~/.gradle/gradle.properties aapt2FromMavenOverride write is the one rough edge and greptile already has it inline at flake.nix:93, including the effect on unrelated Gradle projects — not repeating it.
Description
This PR adds a Nix flake dev shell that provides the full toolchain needed to build the app without Android Studio:
ndk_verinJustfile), composed via nixpkgsandroidenvwithflake.lockpinning the nixpkgs revisionANDROID_HOME,ANDROID_SDK_ROOT,ANDROID_NDK_ROOT, andJAVA_HOMEsojust compile/build/test/lintwork as-is insidenix developandroid.aapt2FromMavenOverridein~/.gradle/gradle.propertiesat the SDK's patched aapt2 (idempotent, refreshes stale store paths, leaves custom overrides alone)Emulator and system images are excluded to keep the closure small (~2 GB with the NDK); the flags to enable them are documented in the flake. A sandboxed
nix buildof the APK is not provided since Gradle needs network access for Maven dependencies, which would require vendoring the whole dependency graph.Note: building still requires
GITHUB_ACTOR/GITHUB_TOKENin.envfor thecom.synonym:*GitHub Packages repositories, same as any other environment.Preview
N/A — no user-visible changes.
QA Notes
Manual Tests
nix develop→just build: devDebug APKs are produced inapp/build/outputs/bitkit/devDebug.Automated Checks
nix developon NixOS:just compileandjust buildsucceed, producing all four devDebug APKs.