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 30 { 31 lib, 32 - cargo-pgrx, 33 pkg-config, 34 rustPlatform, 35 stdenv, ··· 64 buildFeatures ? [ ], 65 cargoBuildFlags ? [ ], 66 cargoPgrxFlags ? [ ], 67 postgresql, 68 # cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the 69 # dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
··· 29 30 { 31 lib, 32 pkg-config, 33 rustPlatform, 34 stdenv, ··· 63 buildFeatures ? [ ], 64 cargoBuildFlags ? [ ], 65 cargoPgrxFlags ? [ ], 66 + # pinned dependencies 67 + cargo-pgrx, 68 postgresql, 69 # cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the 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 }; 24 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 30 cargo-pgrx = cargo-pgrx_0_12_0_alpha_1; 31 - rustPlatform = rustPlatform'; 32 - }) 33 - (finalAttrs: { 34 - inherit postgresql; 35 36 - pname = "pgvecto-rs"; 37 - version = "0.3.0"; 38 39 - buildInputs = [ openssl ]; 40 - nativeBuildInputs = [ pkg-config ]; 41 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 - }; 55 56 - useFetchCargoVendor = true; 57 - cargoHash = "sha256-8otJ1uqGrCmlxAqvfAL3OjhBI4I6dAu6EoajstO46Sw="; 58 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 - ''; 63 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 - ''; 69 70 - env = { 71 - # Needed to get openssl-sys to use pkg-config. 72 - OPENSSL_NO_VENDOR = 1; 73 74 - # Bypass rust nightly features not being available on rust stable 75 - RUSTC_BOOTSTRAP = 1; 76 - }; 77 78 - # This crate does not have the "pg_test" feature 79 - usePgTestCheckFeature = false; 80 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; 90 91 - CREATE TABLE items ( 92 - id bigserial PRIMARY KEY, 93 - content text NOT NULL, 94 - embedding vectors.vector(3) NOT NULL -- 3 dimensions 95 - ); 96 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 - }; 117 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 132 ]; 133 }; 134 - })
··· 23 }; 24 25 in 26 + (buildPgrxExtension.override { rustPlatform = rustPlatform'; }) (finalAttrs: { 27 + inherit postgresql; 28 cargo-pgrx = cargo-pgrx_0_12_0_alpha_1; 29 30 + pname = "pgvecto-rs"; 31 + version = "0.3.0"; 32 33 + buildInputs = [ openssl ]; 34 + nativeBuildInputs = [ pkg-config ]; 35 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 + ]; 42 43 + src = fetchFromGitHub { 44 + owner = "tensorchord"; 45 + repo = "pgvecto.rs"; 46 + tag = "v${finalAttrs.version}"; 47 + hash = "sha256-X7BY2Exv0xQNhsS/GA7GNvj9OeVDqVCd/k3lUkXtfgE="; 48 + }; 49 50 + useFetchCargoVendor = true; 51 + cargoHash = "sha256-8otJ1uqGrCmlxAqvfAL3OjhBI4I6dAu6EoajstO46Sw="; 52 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 + ''; 57 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 + ''; 63 64 + env = { 65 + # Needed to get openssl-sys to use pkg-config. 66 + OPENSSL_NO_VENDOR = 1; 67 68 + # Bypass rust nightly features not being available on rust stable 69 + RUSTC_BOOTSTRAP = 1; 70 + }; 71 72 + # This crate does not have the "pg_test" feature 73 + usePgTestCheckFeature = false; 74 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; 84 85 + CREATE TABLE items ( 86 + id bigserial PRIMARY KEY, 87 + content text NOT NULL, 88 + embedding vectors.vector(3) NOT NULL -- 3 dimensions 89 + ); 90 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 + } 108 ]; 109 }; 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 postgresqlTestExtension, 8 }: 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: { 17 pname = "pgvectorscale"; 18 version = "0.7.0"; 19 ··· 38 ]; 39 40 inherit postgresql; 41 42 passthru.tests.extension = postgresqlTestExtension { 43 inherit (finalAttrs) finalPackage;
··· 7 postgresqlTestExtension, 8 }: 9 10 + buildPgrxExtension (finalAttrs: { 11 pname = "pgvectorscale"; 12 version = "0.7.0"; 13 ··· 32 ]; 33 34 inherit postgresql; 35 + cargo-pgrx = cargo-pgrx_0_12_6; 36 37 passthru.tests.extension = postgresqlTestExtension { 38 inherit (finalAttrs) finalPackage;
+2 -7
pkgs/servers/sql/postgresql/ext/pgx_ulid.nix
··· 7 postgresql, 8 util-linux, 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: { 17 inherit postgresql; 18 19 pname = "pgx_ulid"; 20 version = "0.2.0";
··· 7 postgresql, 8 util-linux, 9 }: 10 + buildPgrxExtension (finalAttrs: { 11 inherit postgresql; 12 + cargo-pgrx = cargo-pgrx_0_12_6; 13 14 pname = "pgx_ulid"; 15 version = "0.2.0";
+2 -1
pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix
··· 7 postgresql, 8 }: 9 10 - (buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_12_6; }) (finalAttrs: { 11 inherit postgresql; 12 13 pname = "timescaledb_toolkit"; 14 version = "1.21.0";
··· 7 postgresql, 8 }: 9 10 + buildPgrxExtension (finalAttrs: { 11 inherit postgresql; 12 + cargo-pgrx = cargo-pgrx_0_12_6; 13 14 pname = "timescaledb_toolkit"; 15 version = "1.21.0";
+2 -7
pkgs/servers/sql/postgresql/ext/vectorchord/package.nix
··· 12 stdenv, 13 }: 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 # Follow upstream and use rust-jemalloc-sys on linux aarch64 and x86_64 22 # Additionally, disable init exec TLS, since it causes issues with postgres. 23 # https://github.com/tensorchord/VectorChord/blob/0.4.2/Cargo.toml#L43-L44 ··· 29 }) 30 ); 31 in 32 - buildPgrxExtension' (finalAttrs: { 33 inherit postgresql; 34 35 pname = "vectorchord"; 36 version = "0.4.2";
··· 12 stdenv, 13 }: 14 let 15 # Follow upstream and use rust-jemalloc-sys on linux aarch64 and x86_64 16 # Additionally, disable init exec TLS, since it causes issues with postgres. 17 # https://github.com/tensorchord/VectorChord/blob/0.4.2/Cargo.toml#L43-L44 ··· 23 }) 24 ); 25 in 26 + buildPgrxExtension (finalAttrs: { 27 inherit postgresql; 28 + cargo-pgrx = cargo-pgrx_0_14_1; 29 30 pname = "vectorchord"; 31 version = "0.4.2";