Skip to content

Add flake.nix for development environment#159

Merged
446564 merged 5 commits into
zjs81:mainfrom
ChaoticLeah:add-flake-nix
Feb 11, 2026
Merged

Add flake.nix for development environment#159
446564 merged 5 commits into
zjs81:mainfrom
ChaoticLeah:add-flake-nix

Conversation

@ChaoticLeah

@ChaoticLeah ChaoticLeah commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI review requested due to automatic review settings February 11, 2026 16:17
@446564

446564 commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

I'll wait to see what the robot say's then merge

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.nix defining a devShell with Flutter/Dart, Android tooling, and common build dependencies.
  • Adds a shellHook to 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.

Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix
Comment thread flake.nix Outdated
Copilot AI review requested due to automatic review settings February 11, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flake.nix
Comment on lines +54 to +64
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

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this is needed?

Comment thread flake.nix
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Copilot AI review requested due to automatic review settings February 11, 2026 16:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flake.nix
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 && \

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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 && \

Copilot uses AI. Check for mistakes.
Comment thread flake.nix
Comment on lines +15 to +20
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Flutter and Dart
flutter
dart

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; [ ... ];.

Copilot uses AI. Check for mistakes.
Comment thread flake.nix
Comment on lines +16 to +46
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"

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 ''
'')
+ ''

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if this is an issue. wont fix. If a nix-darwin user says its an issue we can look into it

@446564 446564 merged commit 4995f5f into zjs81:main Feb 11, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nix dev enviorment

3 participants