Add flake.nix for development environment#159
Conversation
2ea1646 to
a4d3d24
Compare
|
I'll wait to see what the robot say's then merge |
There was a problem hiding this comment.
Pull request overview
Adds a Nix flake-based development shell to make it easier to set up a consistent Flutter/Android (and partial macOS) development environment for the MeshCore Flutter app.
Changes:
- Introduces
flake.nixdefining adevShellwith Flutter/Dart, Android tooling, and common build dependencies. - Adds a
shellHookto configure environment variables for Linux desktop builds and Android SDK/Gradle defaults.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cat << 'EOF' | ||
| mkdir -p ~/Android/Sdk && cd ~/Android/Sdk && \ | ||
| curl -o cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip && \ | ||
| unzip -q cmdline-tools.zip && \ | ||
| mkdir -p cmdline-tools/latest && \ | ||
| mv cmdline-tools/* cmdline-tools/latest/ 2>/dev/null || true && \ | ||
| rm cmdline-tools.zip && \ | ||
| cd cmdline-tools/latest/bin && \ | ||
| yes | ./sdkmanager --sdk_root=~/Android/Sdk 'platform-tools' 'platforms;android-34' 'build-tools;34.0.0' && \ | ||
| echo "Android SDK setup complete!" | ||
| EOF |
There was a problem hiding this comment.
The Android SDK download instructions use curl without HTTPS certificate verification and pipe directly to unzip. While the URL is from Google's official domain, consider adding a note about verifying the integrity of downloaded files. Additionally, the hardcoded URL version (10406996_latest.zip) may become outdated. Consider documenting that users should verify this is the current version from https://developer.android.com/studio#command-tools
There was a problem hiding this comment.
Unsure if this is needed?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| curl -o cmdline-tools.zip ${if pkgs.stdenv.isDarwin then "https://dl.google.com/android/repository/commandlinetools-mac-10406996_latest.zip" else "https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip"} && \ | ||
| unzip -q cmdline-tools.zip && \ | ||
| mkdir -p cmdline-tools/latest && \ | ||
| mv cmdline-tools/* cmdline-tools/latest/ 2>/dev/null || echo "Warning: failed to move Android cmdline-tools into 'latest' directory; please check your SDK layout." >&2 && \ |
There was a problem hiding this comment.
In the printed Android SDK setup command, mkdir -p cmdline-tools/latest is followed by mv cmdline-tools/* cmdline-tools/latest/. Because the latest directory exists, the glob will include it, which can cause mv to error and leave the cmdline-tools layout incorrect (and cd cmdline-tools/latest/bin may fail). Adjust the move step to avoid moving latest into itself (e.g., move the unzipped directory into latest, or move only specific entries / exclude latest).
| mv cmdline-tools/* cmdline-tools/latest/ 2>/dev/null || echo "Warning: failed to move Android cmdline-tools into 'latest' directory; please check your SDK layout." >&2 && \ | |
| for entry in cmdline-tools/*; do \ | |
| [ "$(basename "$entry")" = "latest" ] && continue; \ | |
| mv "$entry" cmdline-tools/latest/; \ | |
| done || echo "Warning: failed to move Android cmdline-tools into 'latest' directory; please check your SDK layout." >&2 && \ |
| devShells.default = pkgs.mkShell { | ||
| buildInputs = with pkgs; [ | ||
| # Flutter and Dart | ||
| flutter | ||
| dart | ||
|
|
There was a problem hiding this comment.
For mkShell, buildInputs works but is primarily intended for derivation builds; for dev shells packages (and nativeBuildInputs when needed) is the current recommended attribute and avoids some surprising propagation behaviors. Consider switching to packages = with pkgs; [ ... ];.
| buildInputs = with pkgs; [ | ||
| # Flutter and Dart | ||
| flutter | ||
| dart | ||
|
|
||
| # Java (required for Android development) | ||
| jdk17 | ||
|
|
||
| # Android development tools | ||
| android-tools | ||
| gradle | ||
|
|
||
| # For the shell hook to set up the environment for Flutter development | ||
| gtk3 | ||
| glib | ||
| sysprof | ||
| libclang | ||
| cmake | ||
| ninja | ||
| pkg-config | ||
| libdatrie | ||
|
|
||
| # Additional tools for installing Android SDK if not present | ||
| curl | ||
| unzip | ||
| ]; | ||
|
|
||
| shellHook = '' | ||
| echo "MeshCore Flutter Development Environment" | ||
| export PKG_CONFIG_PATH="${pkgs.gtk3}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:${pkgs.sysprof}/lib/pkgconfig:$PKG_CONFIG_PATH" | ||
| export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [pkgs.gtk3 pkgs.glib pkgs.sysprof pkgs.libdatrie]}:$LD_LIBRARY_PATH" |
There was a problem hiding this comment.
flake-utils.lib.eachDefaultSystem will evaluate this devShell on Darwin as well, but the buildInputs list includes Linux/GTK-specific packages (e.g., gtk3, sysprof, libdatrie) unconditionally. This is likely to fail evaluation/build on macOS; consider either restricting supported systems to Linux for now or conditionally including these deps only when pkgs.stdenv.isLinux.
| buildInputs = with pkgs; [ | |
| # Flutter and Dart | |
| flutter | |
| dart | |
| # Java (required for Android development) | |
| jdk17 | |
| # Android development tools | |
| android-tools | |
| gradle | |
| # For the shell hook to set up the environment for Flutter development | |
| gtk3 | |
| glib | |
| sysprof | |
| libclang | |
| cmake | |
| ninja | |
| pkg-config | |
| libdatrie | |
| # Additional tools for installing Android SDK if not present | |
| curl | |
| unzip | |
| ]; | |
| shellHook = '' | |
| echo "MeshCore Flutter Development Environment" | |
| export PKG_CONFIG_PATH="${pkgs.gtk3}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:${pkgs.sysprof}/lib/pkgconfig:$PKG_CONFIG_PATH" | |
| export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [pkgs.gtk3 pkgs.glib pkgs.sysprof pkgs.libdatrie]}:$LD_LIBRARY_PATH" | |
| buildInputs = with pkgs; | |
| [ | |
| # Flutter and Dart | |
| flutter | |
| dart | |
| # Java (required for Android development) | |
| jdk17 | |
| # Android development tools | |
| android-tools | |
| gradle | |
| # Tools required for building native components | |
| libclang | |
| cmake | |
| ninja | |
| pkg-config | |
| # Additional tools for installing Android SDK if not present | |
| curl | |
| unzip | |
| ] | |
| ++ (if pkgs.stdenv.isLinux then [ | |
| # Linux/GTK-specific libraries | |
| gtk3 | |
| glib | |
| sysprof | |
| libdatrie | |
| ] else []); | |
| shellHook = | |
| '' | |
| echo "MeshCore Flutter Development Environment" | |
| '' | |
| + (if pkgs.stdenv.isLinux then '' | |
| export PKG_CONFIG_PATH="${pkgs.gtk3}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:${pkgs.sysprof}/lib/pkgconfig:$PKG_CONFIG_PATH" | |
| export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [pkgs.gtk3 pkgs.glib pkgs.sysprof pkgs.libdatrie]}:$LD_LIBRARY_PATH" | |
| '' else '' | |
| '') | |
| + '' |
There was a problem hiding this comment.
unsure if this is an issue. wont fix. If a nix-darwin user says its an issue we can look into it
This is a very rough thrown together nix flake. I have not tested this for IOS/Mac development.
Its probably not perfect but it seems good enough for now and can be updated later if there are problems
closes #155