nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 115 lines 3.6 kB view raw
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-09-26"; 25 26 src = fetchFromGitHub { 27 owner = "omnigres"; 28 repo = "omnigres"; 29 rev = "247383198a95d045df0d97ece5a81adffb5c08e8"; 30 hash = "sha256-RrdtUtrs0Mh1VyMbF89qJhr2fnCVcQy2l1/85/mJ/4Y="; 31 }; 32 33 postPatch = '' 34 substituteInPlace deps/libfyaml/CMakeLists.txt \ 35 --replace-fail "cmake_minimum_required(VERSION 3.0)" "cmake_minimum_required(VERSION 3.10)" 36 substituteInPlace deps/STC/CMakeLists.txt \ 37 --replace-fail "cmake_minimum_required(VERSION 3.1)" "cmake_minimum_required(VERSION 3.10)" 38 substituteInPlace deps/wslay/{,lib/}CMakeLists.txt \ 39 --replace-fail "cmake_minimum_required(VERSION 2.8)" "cmake_minimum_required(VERSION 3.10)" 40 substituteInPlace deps/h2o/CMakeLists.txt \ 41 --replace-fail "CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)" "cmake_minimum_required(VERSION 3.10)" 42 substituteInPlace deps/uriparser/CMakeLists.txt \ 43 --replace-fail "cmake_minimum_required(VERSION 3.3)" "cmake_minimum_required(VERSION 3.10)" 44 substituteInPlace deps/metalang99/CMakeLists.txt \ 45 --replace-fail "cmake_minimum_required(VERSION 3.0.2)" "cmake_minimum_required(VERSION 3.10)" 46 '' 47 + 48 # This matches postInstall of PostgreSQL's generic.nix, which does this for the PGXS Makefile. 49 # Since omnigres uses a CMake file, which tries to replicate the things that PGXS does, we need 50 # to apply the same fix for darwin. 51 # The reason we need to do this is, because PG_BINARY will point at the postgres wrapper of 52 # postgresql.withPackages, which does not contain the same symbols as the original file, ofc. 53 lib.optionalString stdenv.hostPlatform.isDarwin '' 54 substituteInPlace "cmake/PostgreSQLExtension.cmake" \ 55 --replace-fail '-bundle_loader ''${PG_BINARY}' "-bundle_loader ${postgresql}/bin/postgres" 56 ''; 57 58 strictDeps = true; 59 60 nativeBuildInputs = [ 61 clang_18 62 cmake 63 flex 64 netcat 65 pkg-config 66 perl 67 python3 68 ]; 69 70 buildInputs = postgresql.buildInputs ++ [ 71 brotli 72 ]; 73 74 cmakeFlags = [ 75 "-DOPENSSL_CONFIGURED=1" 76 "-DPG_CONFIG=${pgWithExtensions.pg_config}/bin/pg_config" 77 "-DPostgreSQL_TARGET_EXTENSION_DIR=${placeholder "out"}/share/postgresql/extension/" 78 "-DPostgreSQL_TARGET_PACKAGE_LIBRARY_DIR=${placeholder "out"}/lib/" 79 ]; 80 81 enableParallelBuilding = true; 82 doCheck = false; 83 84 preInstall = '' 85 patchShebangs script_omni* 86 mkdir -p $out/lib/ 87 mkdir -p $out/share/postgresql/extension/ 88 ''; 89 90 # https://github.com/omnigres/omnigres?tab=readme-ov-file#building--using-extensions 91 installTargets = [ "install_extensions" ]; 92 93 passthru.tests.extension = postgresqlTestExtension { 94 inherit (finalAttrs) finalPackage; 95 sql = '' 96 -- https://docs.omnigres.org/omni_id/identity_type/#usage 97 CREATE EXTENSION omni_id; 98 99 SELECT identity_type('user_id'); 100 ''; 101 }; 102 103 passthru.updateScript = unstableGitUpdater { 104 hardcodeZeroVersion = true; 105 }; 106 107 meta = { 108 description = "Postgres as a Business Operating System"; 109 homepage = "https://docs.omnigres.org"; 110 maintainers = with lib.maintainers; [ mtrsk ]; 111 platforms = postgresql.meta.platforms; 112 license = lib.licenses.asl20; 113 broken = lib.versionOlder postgresql.version "14"; 114 }; 115})