Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 brotli,
3 clang_18,
4 cmake,
5 fetchFromGitHub,
6 flex,
7 lib,
8 netcat,
9 perl,
10 pkg-config,
11 postgresql,
12 postgresqlBuildExtension,
13 postgresqlTestExtension,
14 python3,
15 stdenv,
16 unstableGitUpdater,
17}:
18
19let
20 pgWithExtensions = postgresql.withPackages (ps: [ ps.plpython3 ]);
21in
22postgresqlBuildExtension (finalAttrs: {
23 pname = "omnigres";
24 version = "0-unstable-2025-06-27";
25
26 src = fetchFromGitHub {
27 owner = "omnigres";
28 repo = "omnigres";
29 rev = "f1b35e623b2583d1124c593f0d9c8466d8fa3a56";
30 hash = "sha256-FiZuXvY+1qyLTnxZ9Y5MP9SxM4wncX4L4rDJEa6O7NE=";
31 };
32
33 # This matches postInstall of PostgreSQL's generic.nix, which does this for the PGXS Makefile.
34 # Since omnigres uses a CMake file, which tries to replicate the things that PGXS does, we need
35 # to apply the same fix for darwin.
36 # The reason we need to do this is, because PG_BINARY will point at the postgres wrapper of
37 # postgresql.withPackages, which does not contain the same symbols as the original file, ofc.
38 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
39 substituteInPlace "cmake/PostgreSQLExtension.cmake" \
40 --replace-fail '-bundle_loader ''${PG_BINARY}' "-bundle_loader ${postgresql}/bin/postgres"
41 '';
42
43 strictDeps = true;
44
45 nativeBuildInputs = [
46 clang_18
47 cmake
48 flex
49 netcat
50 pkg-config
51 perl
52 python3
53 ];
54
55 buildInputs = postgresql.buildInputs ++ [
56 brotli
57 ];
58
59 cmakeFlags = [
60 "-DOPENSSL_CONFIGURED=1"
61 "-DPG_CONFIG=${pgWithExtensions.pg_config}/bin/pg_config"
62 "-DPostgreSQL_TARGET_EXTENSION_DIR=${builtins.placeholder "out"}/share/postgresql/extension/"
63 "-DPostgreSQL_TARGET_PACKAGE_LIBRARY_DIR=${builtins.placeholder "out"}/lib/"
64 ];
65
66 enableParallelBuilding = true;
67 doCheck = false;
68
69 preInstall = ''
70 patchShebangs script_omni*
71 mkdir -p $out/lib/
72 mkdir -p $out/share/postgresql/extension/
73 '';
74
75 # https://github.com/omnigres/omnigres?tab=readme-ov-file#building--using-extensions
76 installTargets = [ "install_extensions" ];
77
78 passthru.tests.extension = postgresqlTestExtension {
79 inherit (finalAttrs) finalPackage;
80 sql = ''
81 -- https://docs.omnigres.org/omni_id/identity_type/#usage
82 CREATE EXTENSION omni_id;
83
84 SELECT identity_type('user_id');
85 '';
86 };
87
88 passthru.updateScript = unstableGitUpdater {
89 hardcodeZeroVersion = true;
90 };
91
92 meta = {
93 description = "Postgres as a Business Operating System";
94 homepage = "https://docs.omnigres.org";
95 maintainers = with lib.maintainers; [ mtrsk ];
96 platforms = postgresql.meta.platforms;
97 license = lib.licenses.asl20;
98 broken = lib.versionOlder postgresql.version "14";
99 };
100})