{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  name = "cloud-dev";

  buildInputs = with pkgs; [
    # Rust toolchain
    rustup
    cargo
    rustc

    # Protocol Buffers
    protobuf

    # LLVM/Clang (for bindgen/clang-sys)
    llvmPackages.libclang
    llvmPackages.clang

    # Build essentials
    pkg-config
    openssl

    # Development tools
    git

    # For RocksDB (chainfire dependency)
    rocksdb
  ];

  # Environment variables for clang-sys
  LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";

  # Ensure protoc is found
  PROTOC = "${pkgs.protobuf}/bin/protoc";

  shellHook = ''
    echo "Cloud Platform Development Environment"
    echo "======================================="
    if ! rustup default >/dev/null 2>&1; then
      rustup default stable
    fi
    echo "Rust: $(rustc --version 2>/dev/null || echo 'run: rustup default stable')"
    echo "Protoc: $(protoc --version)"
    echo "Clang: $(clang --version | head -1)"
    echo ""
    echo "Environment variables set:"
    echo "  LIBCLANG_PATH=$LIBCLANG_PATH"
    echo "  PROTOC=$PROTOC"
  '';
}
