1{ lib, stdenv, fetchFromGitHub, which }:
2
3stdenv.mkDerivation rec {
4 pname = "libpg_query";
5 version = "15-4.2.1";
6
7 src = fetchFromGitHub {
8 owner = "pganalyze";
9 repo = "libpg_query";
10 rev = version;
11 hash = "sha256-wbWW2r8Ai4Y+JBI5DbMuVx326bAxmEgQlTd6nnzqDXw=";
12 };
13
14 nativeBuildInputs = [ which ];
15
16 makeFlags = [ "build" "build_shared" ];
17
18 installPhase = ''
19 install -Dm644 -t $out/lib libpg_query.a
20 install -Dm644 -t $out/include pg_query.h
21 install -Dm644 -t $out/lib libpg_query${stdenv.hostPlatform.extensions.sharedLibrary}
22 '';
23
24 doCheck = true;
25 checkTarget = "test";
26
27 meta = with lib; {
28 homepage = "https://github.com/pganalyze/libpg_query";
29 description = "C library for accessing the PostgreSQL parser outside of the server environment";
30 changelog = "https://github.com/pganalyze/libpg_query/raw/${version}/CHANGELOG.md";
31 license = licenses.bsd3;
32 platforms = platforms.unix;
33 maintainers = [ maintainers.marsam ];
34 };
35}