1{ lib, stdenv, fetchFromGitHub, which, squawk }:
2
3stdenv.mkDerivation rec {
4 pname = "libpg_query";
5 version = "15-4.2.3";
6
7 src = fetchFromGitHub {
8 owner = "pganalyze";
9 repo = "libpg_query";
10 rev = version;
11 hash = "sha256-/HUg6x0il5WxENmgR3slu7nmXTKv6YscjpX569Dztko=";
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 passthru.tests = {
28 inherit squawk;
29 };
30
31 meta = with lib; {
32 homepage = "https://github.com/pganalyze/libpg_query";
33 description = "C library for accessing the PostgreSQL parser outside of the server environment";
34 changelog = "https://github.com/pganalyze/libpg_query/blob/${version}/CHANGELOG.md";
35 license = licenses.bsd3;
36 platforms = platforms.unix;
37 maintainers = [ maintainers.marsam ];
38 };
39}