1{
2 fetchFromGitHub,
3 lib,
4 libkrb5,
5 openssl,
6 postgresql,
7 postgresqlBuildExtension,
8}:
9
10let
11 sources = {
12 # v18: No upstream ticket, yet (2025-07-07)
13 "17" = {
14 version = "17.1";
15 hash = "sha256-9St/ESPiFq2NiPKqbwHLwkIyATKUkOGxFcUrWgT+Iqo=";
16 };
17 "16" = {
18 version = "16.1";
19 hash = "sha256-fzoAcXEKmA+xD4HtcHZgcduh1XmSgL8ZS4R72og7RGQ=";
20 };
21 "15" = {
22 version = "1.7.1";
23 hash = "sha256-emwoTowT7WKFX0RQDqJXjIblrzqaUIUkzqSqBCHVKQ8=";
24 };
25 "14" = {
26 version = "1.6.3";
27 hash = "sha256-KgLidJHjUK9BTp6ffmGUj1chcwIe6IzlcadRpGCfNdM=";
28 };
29 "13" = {
30 version = "1.5.3";
31 hash = "sha256-IU4Clec3DkKWT7+kw0VtQNybt94i7M2rSSgJG/XdcRs=";
32 };
33 };
34
35 source =
36 sources.${lib.versions.major postgresql.version} or {
37 version = "";
38 hash = throw "Source for pgaudit is not available for ${postgresql.version}";
39 };
40in
41postgresqlBuildExtension {
42 pname = "pgaudit";
43 inherit (source) version;
44
45 src = fetchFromGitHub {
46 owner = "pgaudit";
47 repo = "pgaudit";
48 tag = source.version;
49 inherit (source) hash;
50 };
51
52 buildInputs = [
53 libkrb5
54 openssl
55 ];
56
57 makeFlags = [ "USE_PGXS=1" ];
58
59 enableUpdateScript = false;
60
61 meta = {
62 broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames sources);
63 description = "Open Source PostgreSQL Audit Logging";
64 homepage = "https://github.com/pgaudit/pgaudit";
65 changelog = "https://github.com/pgaudit/pgaudit/releases/tag/${source.version}";
66 maintainers = with lib.maintainers; [ idontgetoutmuch ];
67 platforms = postgresql.meta.platforms;
68 license = lib.licenses.postgresql;
69 };
70}