1+ {
2+ description = "PostgreSQL Language Server Development Environment" ;
3+
4+ inputs = {
5+ nixpkgs . url = "github:NixOS/nixpkgs/nixos-unstable" ;
6+ flake-utils . url = "github:numtide/flake-utils" ;
7+ rust-overlay = {
8+ url = "github:oxalica/rust-overlay" ;
9+ inputs . nixpkgs . follows = "nixpkgs" ;
10+ } ;
11+ } ;
12+
13+ outputs = { self , nixpkgs , flake-utils , rust-overlay } :
14+ flake-utils . lib . eachDefaultSystem ( system :
15+ let
16+ overlays = [ ( import rust-overlay ) ] ;
17+ pkgs = import nixpkgs {
18+ inherit system overlays ;
19+ } ;
20+
21+ # Read rust-toolchain.toml to get the exact Rust version
22+ rustToolchain = pkgs . rust-bin . fromRustupToolchainFile ./rust-toolchain.toml ;
23+
24+ # Development dependencies
25+ buildInputs = with pkgs ; [
26+ # Rust toolchain
27+ rustToolchain
28+
29+ # Node.js ecosystem
30+ bun
31+ nodejs_20
32+
33+ # Python for additional tooling
34+ python3
35+ python3Packages . pip
36+
37+ # System dependencies
38+ pkg-config
39+ openssl
40+
41+ # Build tools
42+ just
43+ git
44+
45+ # LSP and development tools
46+ rust-analyzer
47+
48+ # Additional tools that might be needed
49+ cmake
50+ gcc
51+ libiconv
52+ ] ;
53+
54+ # Environment variables
55+ env = {
56+ RUST_SRC_PATH = "${ rustToolchain } /lib/rustlib/src/rust/library" ;
57+ PKG_CONFIG_PATH = "${ pkgs . openssl . dev } /lib/pkgconfig" ;
58+ } ;
59+
60+ in
61+ {
62+ devShells . default = pkgs . mkShell {
63+ inherit buildInputs ;
64+
65+ shellHook = ''
66+ echo "PostgreSQL Language Server Development Environment"
67+ echo "Available tools:"
68+ echo " • Rust $(rustc --version)"
69+ echo " • Node.js $(node --version)"
70+ echo " • Bun $(bun --version)"
71+ echo " • Just $(just --version)"
72+ echo ""
73+ echo "Development Commands:"
74+ echo " • just --list # Show tasks"
75+ echo " • cargo check # Check Rust"
76+ echo " • bun install # Install deps"
77+ echo ""
78+ echo "Use Docker for database:"
79+ echo " • docker-compose up -d"
80+ echo ""
81+
82+ # Set environment variables
83+ ${ pkgs . lib . concatStringsSep "\n "
84+ ( pkgs . lib . mapAttrsToList ( name : value : "export ${ name } =\" ${ value } \" " ) env ) }
85+ '' ;
86+ } ;
87+
88+ # Formatter for nix files
89+ formatter = pkgs . nixfmt-rfc-style ;
90+ }
91+ ) ;
92+ }
0 commit comments