1{ lib, stdenv, fetchFromGitHub, libkrb5, openssl, postgresql }:
2
3let
4 source = {
5 "16" = {
6 version = "16.0";
7 hash = "sha256-8+tGOl1U5y9Zgu+9O5UDDE4bec4B0JC/BQ6GLhHzQzc=";
8 };
9 "15" = {
10 version = "1.7.0";
11 hash = "sha256-8pShPr4HJaJQPjW1iPJIpj3CutTx8Tgr+rOqoXtgCcw=";
12 };
13 "14" = {
14 version = "1.6.2";
15 hash = "sha256-Bl7Jk2B0deZUDiI391vk4nilwuVGHd1wuaQRSCoA3Mk=";
16 };
17 "13" = {
18 version = "1.5.2";
19 hash = "sha256-fyf2Ym0fAAXjc28iFCGDEftPAyDLXmEgi/0DaTJJiIg=";
20 };
21 "12" = {
22 version = "1.4.3";
23 hash = "sha256-c8/xUFIHalu2bMCs57DeylK0oW0VnQwmUCpdp+tYqk4=";
24 };
25 }.${lib.versions.major postgresql.version} or (throw "Source for pgaudit is not available for ${postgresql.version}");
26in
27stdenv.mkDerivation {
28 pname = "pgaudit";
29 inherit (source) version;
30
31 src = fetchFromGitHub {
32 owner = "pgaudit";
33 repo = "pgaudit";
34 rev = source.version;
35 hash = source.hash;
36 };
37
38 buildInputs = [ libkrb5 openssl postgresql ];
39
40 makeFlags = [ "USE_PGXS=1" ];
41
42 installPhase = ''
43 install -D -t $out/lib pgaudit${postgresql.dlSuffix}
44 install -D -t $out/share/postgresql/extension *.sql
45 install -D -t $out/share/postgresql/extension *.control
46 '';
47
48 meta = with lib; {
49 description = "Open Source PostgreSQL Audit Logging";
50 homepage = "https://github.com/pgaudit/pgaudit";
51 changelog = "https://github.com/pgaudit/pgaudit/releases/tag/${source.version}";
52 maintainers = with maintainers; [ idontgetoutmuch ];
53 platforms = postgresql.meta.platforms;
54 license = licenses.postgresql;
55 };
56}