nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchgit,
5 rust-jemalloc-sys,
6 tree-sitter,
7 nodejs,
8}:
9rustPlatform.buildRustPackage (finalAttrs: {
10 pname = "postgres-language-server";
11 version = "0.19.0";
12
13 src = fetchgit {
14 url = "https://github.com/supabase-community/postgres-language-server";
15 tag = finalAttrs.version;
16 hash = "sha256-0zmH9hYwmKYTRR1MxaHZcm7B2SzgCxYjLM4GCK61c7s=";
17 fetchSubmodules = true;
18 };
19
20 cargoHash = "sha256-2PEyKjHWEkGEgRy0l6nIhARN0qoR4CIv/Qo+xHucgEc=";
21
22 nativeBuildInputs = [
23 rustPlatform.bindgenHook
24
25 # Required to build the custom tree-sitter grammar
26 # https://github.com/supabase-community/postgres-language-server/blob/main/crates/pgls_treesitter_grammar/grammar.js
27 tree-sitter
28 nodejs
29 ];
30
31 buildInputs = [
32 rust-jemalloc-sys
33 ];
34
35 env = {
36 SQLX_OFFLINE = 1;
37
38 # As specified in the upstream: https://github.com/supabase-community/postgres-language-server/blob/main/.github/workflows/release.yml
39 RUSTFLAGS = "-C strip=symbols -C codegen-units=1";
40 PGLS_VERSION = finalAttrs.version;
41 };
42
43 cargoBuildFlags = [ "-p=pgls_cli" ];
44 cargoTestFlags = finalAttrs.cargoBuildFlags;
45 checkFlags = [
46 # Tries to write to the file system relatively to the current path
47 "--skip=syntax_error"
48 # Requires a database connection
49 "--skip=test_cli_check_command"
50 "--skip=dblint_detects_issues_snapshot"
51 "--skip=dblint_empty_database_snapshot"
52 ];
53
54 meta = {
55 description = "Tools and language server for Postgres";
56 homepage = "https://pg-language-server.com";
57 license = lib.licenses.mit;
58 maintainers = with lib.maintainers; [
59 myypo
60 ];
61 mainProgram = "postgres-language-server";
62 };
63})