Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 fetchFromGitHub,
3 lib,
4 postgresql,
5 postgresqlBuildExtension,
6}:
7
8let
9 sources = {
10 # For v18, see https://github.com/ossc-db/pg_hint_plan/issues/224
11 "17" = {
12 version = "1.7.0";
13 hash = "sha256-MNQMePDmGxC8OFIJuVJrhfgU566vkng00+tjeGpGKvs=";
14 };
15 "16" = {
16 version = "1.6.0";
17 hash = "sha256-lg7N0QblluTgtNo1tGZjirNJSyQXtcAEs9Jqd3zx0Sg=";
18 };
19 "15" = {
20 version = "1.5.1";
21 hash = "sha256-o8Hepf/Mc1ClRTLZ6PBdqU4jSdlz+ijVgl2vJKmIc6M=";
22 };
23 "14" = {
24 version = "1.4.2";
25 hash = "sha256-nGyKcNY57RdQdZKSaBPk2/YbT0Annz1ZevH0lKswdhA=";
26 };
27 "13" = {
28 version = "1.3.9";
29 hash = "sha256-KGcHDwk8CgNHPZARfLBfS8r7TRCP9LPjT+m4fNSnnW0=";
30 };
31 };
32
33 source =
34 sources.${lib.versions.major postgresql.version} or {
35 version = "";
36 hash = throw "Source for pg_hint_plan is not available for ${postgresql.version}";
37 };
38in
39postgresqlBuildExtension {
40 pname = "pg_hint_plan";
41 inherit (source) version;
42
43 src = fetchFromGitHub {
44 owner = "ossc-db";
45 repo = "pg_hint_plan";
46 tag = "REL${lib.versions.major postgresql.version}_${
47 builtins.replaceStrings [ "." ] [ "_" ] source.version
48 }";
49 inherit (source) hash;
50 };
51
52 postPatch = lib.optionalString (lib.versionOlder postgresql.version "14") ''
53 # https://github.com/ossc-db/pg_hint_plan/commit/e9e564ad59b8bd4a03e0f13b95b5122712e573e6
54 substituteInPlace Makefile --replace "LDFLAGS+=-Wl,--build-id" ""
55 '';
56
57 enableUpdateScript = false;
58
59 meta = {
60 broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames sources);
61 description = "Extension to tweak PostgreSQL execution plans using so-called 'hints' in SQL comments";
62 homepage = "https://github.com/ossc-db/pg_hint_plan";
63 maintainers = with lib.maintainers; [ _1000101 ];
64 platforms = postgresql.meta.platforms;
65 license = lib.licenses.bsd3;
66 };
67}