{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    openjdk17
    gradle
    git
    mesa
    libglvnd
  ];

  shellHook = ''
    echo "Java development environment loaded!"
    echo "- OpenJDK 17: $(java -version 2>&1 | head -n1)"
    echo "- Gradle: $(gradle --version | grep 'Gradle' | head -n1 2>/dev/null || echo 'Gradle available')"
    echo "- OpenGL libraries available"

    export LD_LIBRARY_PATH=${pkgs.mesa.out}/lib:${pkgs.libglvnd.out}/lib:$LD_LIBRARY_PATH
    export JAVA_HOME=${pkgs.openjdk17}

    echo ""
    echo "Environment variables set:"
    echo "- JAVA_HOME: $JAVA_HOME"
    echo "- LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
    echo ""
    echo "Ready to build! Run: ./gradlew package"
  '';
}
