diff --git a/README.md b/README.md index 162bb9c0..fa18d0fe 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,21 @@ Our current focus is on refining and enhancing these core features while buildin - [psteinroe](https://github.com/psteinroe) - [juleswritescode](https://github.com/juleswritescode) +## Development + +### Using Nix + +```bash +nix develop +docker-compose up -d +``` + +### Using Docker + +```bash +docker-compose up -d +``` + ## Acknowledgements A big thanks to the following projects, without which this project wouldn't have been possible: diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..e8bb4576 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751271578, + "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751510438, + "narHash": "sha256-m8PjOoyyCR4nhqtHEBP1tB/jF+gJYYguSZmUmVTEAQE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7f415261f298656f8164bd636c0dc05af4e95b6b", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..0dac4b19 --- /dev/null +++ b/flake.nix @@ -0,0 +1,92 @@ +{ + description = "PostgreSQL Language Server Development Environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + # Read rust-toolchain.toml to get the exact Rust version + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + + # Development dependencies + buildInputs = with pkgs; [ + # Rust toolchain + rustToolchain + + # Node.js ecosystem + bun + nodejs_20 + + # Python for additional tooling + python3 + python3Packages.pip + + # System dependencies + pkg-config + openssl + + # Build tools + just + git + + # LSP and development tools + rust-analyzer + + # Additional tools that might be needed + cmake + gcc + libiconv + ]; + + # Environment variables + env = { + RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library"; + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; + }; + + in + { + devShells.default = pkgs.mkShell { + inherit buildInputs; + + shellHook = '' + echo "PostgreSQL Language Server Development Environment" + echo "Available tools:" + echo " • Rust $(rustc --version)" + echo " • Node.js $(node --version)" + echo " • Bun $(bun --version)" + echo " • Just $(just --version)" + echo "" + echo "Development Commands:" + echo " • just --list # Show tasks" + echo " • cargo check # Check Rust" + echo " • bun install # Install deps" + echo "" + echo "Use Docker for database:" + echo " • docker-compose up -d" + echo "" + + # Set environment variables + ${pkgs.lib.concatStringsSep "\n" + (pkgs.lib.mapAttrsToList (name: value: "export ${name}=\"${value}\"") env)} + ''; + }; + + # Formatter for nix files + formatter = pkgs.nixfmt-rfc-style; + } + ); +} \ No newline at end of file