buildPgrxExtension: require pinning cargo-pgrx

Each extension always depends on a specific cargo-pgrx version, so make
pinning a requirement.

+97 -116
+2 -1
pkgs/development/tools/rust/cargo-pgrx/buildPgrxExtension.nix
··· 29 29 30 30 { 31 31 lib, 32 - cargo-pgrx, 33 32 pkg-config, 34 33 rustPlatform, 35 34 stdenv, ··· 64 63 buildFeatures ? [ ], 65 64 cargoBuildFlags ? [ ], 66 65 cargoPgrxFlags ? [ ], 66 + # pinned dependencies 67 + cargo-pgrx, 67 68 postgresql, 68 69 # cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the 69 70 # dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
+87 -93
pkgs/servers/sql/postgresql/ext/pgvecto-rs/package.nix
··· 23 23 }; 24 24 25 25 in 26 - (buildPgrxExtension.override { 27 - # Upstream only works with a fixed version of cargo-pgrx for each release, 28 - # so we're pinning it here to avoid future incompatibility. 29 - # See https://docs.vectorchord.ai/developers/development.html#set-up-development-environment, step 5 26 + (buildPgrxExtension.override { rustPlatform = rustPlatform'; }) (finalAttrs: { 27 + inherit postgresql; 30 28 cargo-pgrx = cargo-pgrx_0_12_0_alpha_1; 31 - rustPlatform = rustPlatform'; 32 - }) 33 - (finalAttrs: { 34 - inherit postgresql; 35 29 36 - pname = "pgvecto-rs"; 37 - version = "0.3.0"; 30 + pname = "pgvecto-rs"; 31 + version = "0.3.0"; 38 32 39 - buildInputs = [ openssl ]; 40 - nativeBuildInputs = [ pkg-config ]; 33 + buildInputs = [ openssl ]; 34 + nativeBuildInputs = [ pkg-config ]; 41 35 42 - patches = [ 43 - # Tell the `c` crate to use the flags from the rust bindgen hook 44 - (replaceVars ./0001-read-clang-flags-from-environment.diff { 45 - clang = lib.getExe clang; 46 - }) 47 - ]; 48 - 49 - src = fetchFromGitHub { 50 - owner = "tensorchord"; 51 - repo = "pgvecto.rs"; 52 - tag = "v${finalAttrs.version}"; 53 - hash = "sha256-X7BY2Exv0xQNhsS/GA7GNvj9OeVDqVCd/k3lUkXtfgE="; 54 - }; 36 + patches = [ 37 + # Tell the `c` crate to use the flags from the rust bindgen hook 38 + (replaceVars ./0001-read-clang-flags-from-environment.diff { 39 + clang = lib.getExe clang; 40 + }) 41 + ]; 55 42 56 - useFetchCargoVendor = true; 57 - cargoHash = "sha256-8otJ1uqGrCmlxAqvfAL3OjhBI4I6dAu6EoajstO46Sw="; 43 + src = fetchFromGitHub { 44 + owner = "tensorchord"; 45 + repo = "pgvecto.rs"; 46 + tag = "v${finalAttrs.version}"; 47 + hash = "sha256-X7BY2Exv0xQNhsS/GA7GNvj9OeVDqVCd/k3lUkXtfgE="; 48 + }; 58 49 59 - # Set appropriate version on vectors.control, otherwise it won't show up on PostgreSQL 60 - postPatch = '' 61 - substituteInPlace ./vectors.control --subst-var-by CARGO_VERSION ${finalAttrs.version} 62 - ''; 50 + useFetchCargoVendor = true; 51 + cargoHash = "sha256-8otJ1uqGrCmlxAqvfAL3OjhBI4I6dAu6EoajstO46Sw="; 63 52 64 - # Include upgrade scripts in the final package 65 - # https://github.com/tensorchord/pgvecto.rs/blob/v0.2.0/scripts/ci_package.sh#L6-L8 66 - postInstall = '' 67 - cp sql/upgrade/* $out/share/postgresql/extension/ 68 - ''; 53 + # Set appropriate version on vectors.control, otherwise it won't show up on PostgreSQL 54 + postPatch = '' 55 + substituteInPlace ./vectors.control --subst-var-by CARGO_VERSION ${finalAttrs.version} 56 + ''; 69 57 70 - env = { 71 - # Needed to get openssl-sys to use pkg-config. 72 - OPENSSL_NO_VENDOR = 1; 58 + # Include upgrade scripts in the final package 59 + # https://github.com/tensorchord/pgvecto.rs/blob/v0.2.0/scripts/ci_package.sh#L6-L8 60 + postInstall = '' 61 + cp sql/upgrade/* $out/share/postgresql/extension/ 62 + ''; 73 63 74 - # Bypass rust nightly features not being available on rust stable 75 - RUSTC_BOOTSTRAP = 1; 76 - }; 64 + env = { 65 + # Needed to get openssl-sys to use pkg-config. 66 + OPENSSL_NO_VENDOR = 1; 77 67 78 - # This crate does not have the "pg_test" feature 79 - usePgTestCheckFeature = false; 68 + # Bypass rust nightly features not being available on rust stable 69 + RUSTC_BOOTSTRAP = 1; 70 + }; 80 71 81 - passthru = { 82 - updateScript = nix-update-script { }; 83 - tests.extension = postgresqlTestExtension { 84 - inherit (finalAttrs) finalPackage; 85 - postgresqlExtraSettings = '' 86 - shared_preload_libraries='vectors' 87 - ''; 88 - sql = '' 89 - CREATE EXTENSION vectors; 72 + # This crate does not have the "pg_test" feature 73 + usePgTestCheckFeature = false; 90 74 91 - CREATE TABLE items ( 92 - id bigserial PRIMARY KEY, 93 - content text NOT NULL, 94 - embedding vectors.vector(3) NOT NULL -- 3 dimensions 95 - ); 75 + passthru = { 76 + updateScript = nix-update-script { }; 77 + tests.extension = postgresqlTestExtension { 78 + inherit (finalAttrs) finalPackage; 79 + postgresqlExtraSettings = '' 80 + shared_preload_libraries='vectors' 81 + ''; 82 + sql = '' 83 + CREATE EXTENSION vectors; 96 84 97 - INSERT INTO items (content, embedding) VALUES 98 - ('a fat cat sat on a mat and ate a fat rat', '[1, 2, 3]'), 99 - ('a fat dog sat on a mat and ate a fat rat', '[4, 5, 6]'), 100 - ('a thin cat sat on a mat and ate a thin rat', '[7, 8, 9]'), 101 - ('a thin dog sat on a mat and ate a thin rat', '[10, 11, 12]'); 102 - ''; 103 - asserts = [ 104 - { 105 - query = "SELECT default_version FROM pg_available_extensions WHERE name = 'vectors'"; 106 - expected = "'${finalAttrs.version}'"; 107 - description = "Extension vectors has correct version."; 108 - } 109 - { 110 - query = "SELECT COUNT(embedding) FROM items WHERE to_tsvector('english', content) @@ 'cat & rat'::tsquery"; 111 - expected = "2"; 112 - description = "Stores and returns vectors."; 113 - } 114 - ]; 115 - }; 116 - }; 85 + CREATE TABLE items ( 86 + id bigserial PRIMARY KEY, 87 + content text NOT NULL, 88 + embedding vectors.vector(3) NOT NULL -- 3 dimensions 89 + ); 117 90 118 - meta = { 119 - # Upstream removed support for PostgreSQL 13 on 0.3.0: https://github.com/tensorchord/pgvecto.rs/issues/343 120 - broken = 121 - (lib.versionOlder postgresql.version "14") 122 - || 123 - # PostgreSQL 17 support issue upstream: https://github.com/tensorchord/pgvecto.rs/issues/607 124 - # Check after next package update. 125 - lib.versionAtLeast postgresql.version "17" && finalAttrs.version == "0.3.0"; 126 - description = "Scalable, Low-latency and Hybrid-enabled Vector Search in Postgres"; 127 - homepage = "https://github.com/tensorchord/pgvecto.rs"; 128 - license = lib.licenses.asl20; 129 - maintainers = with lib.maintainers; [ 130 - diogotcorreia 131 - esclear 91 + INSERT INTO items (content, embedding) VALUES 92 + ('a fat cat sat on a mat and ate a fat rat', '[1, 2, 3]'), 93 + ('a fat dog sat on a mat and ate a fat rat', '[4, 5, 6]'), 94 + ('a thin cat sat on a mat and ate a thin rat', '[7, 8, 9]'), 95 + ('a thin dog sat on a mat and ate a thin rat', '[10, 11, 12]'); 96 + ''; 97 + asserts = [ 98 + { 99 + query = "SELECT default_version FROM pg_available_extensions WHERE name = 'vectors'"; 100 + expected = "'${finalAttrs.version}'"; 101 + description = "Extension vectors has correct version."; 102 + } 103 + { 104 + query = "SELECT COUNT(embedding) FROM items WHERE to_tsvector('english', content) @@ 'cat & rat'::tsquery"; 105 + expected = "2"; 106 + description = "Stores and returns vectors."; 107 + } 132 108 ]; 133 109 }; 134 - }) 110 + }; 111 + 112 + meta = { 113 + # Upstream removed support for PostgreSQL 13 on 0.3.0: https://github.com/tensorchord/pgvecto.rs/issues/343 114 + broken = 115 + (lib.versionOlder postgresql.version "14") 116 + || 117 + # PostgreSQL 17 support issue upstream: https://github.com/tensorchord/pgvecto.rs/issues/607 118 + # Check after next package update. 119 + lib.versionAtLeast postgresql.version "17" && finalAttrs.version == "0.3.0"; 120 + description = "Scalable, Low-latency and Hybrid-enabled Vector Search in Postgres"; 121 + homepage = "https://github.com/tensorchord/pgvecto.rs"; 122 + license = lib.licenses.asl20; 123 + maintainers = with lib.maintainers; [ 124 + diogotcorreia 125 + esclear 126 + ]; 127 + }; 128 + })
+2 -7
pkgs/servers/sql/postgresql/ext/pgvectorscale/package.nix
··· 7 7 postgresqlTestExtension, 8 8 }: 9 9 10 - let 11 - buildPgrxExtension' = buildPgrxExtension.override { 12 - # Upstream only works with a fixed minor version of cargo-pgrx for each release. 13 - cargo-pgrx = cargo-pgrx_0_12_6; 14 - }; 15 - in 16 - buildPgrxExtension' (finalAttrs: { 10 + buildPgrxExtension (finalAttrs: { 17 11 pname = "pgvectorscale"; 18 12 version = "0.7.0"; 19 13 ··· 38 32 ]; 39 33 40 34 inherit postgresql; 35 + cargo-pgrx = cargo-pgrx_0_12_6; 41 36 42 37 passthru.tests.extension = postgresqlTestExtension { 43 38 inherit (finalAttrs) finalPackage;
+2 -7
pkgs/servers/sql/postgresql/ext/pgx_ulid.nix
··· 7 7 postgresql, 8 8 util-linux, 9 9 }: 10 - let 11 - buildPgrxExtension' = buildPgrxExtension.override { 12 - # Upstream only works with a fixed minor version of cargo-pgrx for each release. 13 - cargo-pgrx = cargo-pgrx_0_12_6; 14 - }; 15 - in 16 - buildPgrxExtension' (finalAttrs: { 10 + buildPgrxExtension (finalAttrs: { 17 11 inherit postgresql; 12 + cargo-pgrx = cargo-pgrx_0_12_6; 18 13 19 14 pname = "pgx_ulid"; 20 15 version = "0.2.0";
+2 -1
pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix
··· 7 7 postgresql, 8 8 }: 9 9 10 - (buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_12_6; }) (finalAttrs: { 10 + buildPgrxExtension (finalAttrs: { 11 11 inherit postgresql; 12 + cargo-pgrx = cargo-pgrx_0_12_6; 12 13 13 14 pname = "timescaledb_toolkit"; 14 15 version = "1.21.0";
+2 -7
pkgs/servers/sql/postgresql/ext/vectorchord/package.nix
··· 12 12 stdenv, 13 13 }: 14 14 let 15 - buildPgrxExtension' = buildPgrxExtension.override { 16 - # Upstream only works with a fixed version of cargo-pgrx for each release, 17 - # so we're pinning it here to avoid future incompatibility. 18 - cargo-pgrx = cargo-pgrx_0_14_1; 19 - }; 20 - 21 15 # Follow upstream and use rust-jemalloc-sys on linux aarch64 and x86_64 22 16 # Additionally, disable init exec TLS, since it causes issues with postgres. 23 17 # https://github.com/tensorchord/VectorChord/blob/0.4.2/Cargo.toml#L43-L44 ··· 29 23 }) 30 24 ); 31 25 in 32 - buildPgrxExtension' (finalAttrs: { 26 + buildPgrxExtension (finalAttrs: { 33 27 inherit postgresql; 28 + cargo-pgrx = cargo-pgrx_0_14_1; 34 29 35 30 pname = "vectorchord"; 36 31 version = "0.4.2";