From 22ba1a22d71df37e9cbb34c1a8180133aeabb2b5 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Fri, 15 Mar 2024 04:20:00 +0000 Subject: cargo-pgrx: expose more versions --- pkgs/development/tools/rust/cargo-pgrx/default.nix | 91 +++++++++++++++------- pkgs/top-level/all-packages.nix | 10 ++- 2 files changed, 70 insertions(+), 31 deletions(-) diff --git a/pkgs/development/tools/rust/cargo-pgrx/default.nix b/pkgs/development/tools/rust/cargo-pgrx/default.nix index 85fc916104ad..3aa7003b7567 100644 --- a/pkgs/development/tools/rust/cargo-pgrx/default.nix +++ b/pkgs/development/tools/rust/cargo-pgrx/default.nix @@ -1,39 +1,74 @@ -{ lib, stdenv, fetchCrate, rustPlatform, pkg-config, openssl, Security }: +{ lib +, darwin +, fetchCrate +, openssl +, pkg-config +, rustPlatform +, stdenv +}: let - pname = "cargo-pgrx"; - version = "0.11.2"; -in -rustPlatform.buildRustPackage rec { - inherit version pname; + generic = + { version + , hash + , cargoHash + }: + rustPlatform.buildRustPackage rec { + pname = "cargo-pgrx"; - src = fetchCrate { - inherit version pname; - hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM="; - }; + inherit version; + + src = fetchCrate { + inherit version pname hash; + }; + + inherit cargoHash; - cargoHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="; + nativeBuildInputs = lib.optionals stdenv.isLinux [ + pkg-config + ]; - nativeBuildInputs = [ pkg-config ]; + buildInputs = lib.optionals stdenv.isLinux [ + openssl + ] ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; - buildInputs = [ openssl ] - ++ lib.optionals stdenv.isDarwin [ Security ]; + preCheck = '' + export PGRX_HOME=$(mktemp -d) + ''; - preCheck = '' - export PGRX_HOME=$(mktemp -d) - ''; + checkFlags = [ + # requires pgrx to be properly initialized with cargo pgrx init + "--skip=command::schema::tests::test_parse_managed_postmasters" + ]; - checkFlags = [ - # requires pgrx to be properly initialized with cargo pgrx init - "--skip=command::schema::tests::test_parse_managed_postmasters" - ]; + meta = with lib; { + description = "Build Postgres Extensions with Rust"; + homepage = "https://github.com/pgcentralfoundation/pgrx"; + changelog = "https://github.com/pgcentralfoundation/pgrx/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ happysalada ]; + mainProgram = "cargo-pgrx"; + }; + }; +in +{ + cargo-pgrx_0_10_2 = generic { + version = "0.10.2"; + hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls="; + cargoHash = "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="; + }; + + cargo-pgrx_0_11_2 = generic { + version = "0.11.2"; + hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM="; + cargoHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="; + }; - meta = with lib; { - description = "Build Postgres Extensions with Rust!"; - mainProgram = "cargo-pgrx"; - homepage = "https://github.com/tcdi/pgrx"; - changelog = "https://github.com/tcdi/pgrx/releases/tag/v${version}"; - license = licenses.mit; - maintainers = with maintainers; [ happysalada ]; + cargo-pgrx_0_11_3 = generic { + version = "0.11.3"; + hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU="; + cargoHash = "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw="; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3c7aa60a14d9..40aa1599fad3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16830,9 +16830,13 @@ with pkgs; buildPgxExtension = callPackage ../development/tools/rust/cargo-pgx/buildPgxExtension.nix { inherit (darwin.apple_sdk.frameworks) Security; }; - cargo-pgrx = callPackage ../development/tools/rust/cargo-pgrx/default.nix { - inherit (darwin.apple_sdk.frameworks) Security; - }; + inherit (callPackages ../development/tools/rust/cargo-pgrx { }) + cargo-pgrx_0_10_2 + cargo-pgrx_0_11_2 + cargo-pgrx_0_11_3 + ; + cargo-pgrx = cargo-pgrx_0_11_2; + buildPgrxExtension = callPackage ../development/tools/rust/cargo-pgrx/buildPgrxExtension.nix { inherit (darwin.apple_sdk.frameworks) Security; }; -- cgit 1.4.1 From 6025943fa21173b424ec569dc946163e48cb3670 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Fri, 15 Mar 2024 04:20:00 +0000 Subject: postgresqlPackages.timescaledb_toolkit: use cargo-pgrx_0_10_2 from top-level --- .../sql/postgresql/ext/timescaledb_toolkit.nix | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix b/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix index 77dd41db7f6d..96bff3fe20b3 100644 --- a/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix +++ b/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix @@ -3,31 +3,12 @@ , buildPgrxExtension , postgresql , nixosTests -, cargo-pgrx +, cargo-pgrx_0_10_2 , fetchCrate , nix-update-script , stdenv }: -let - cargo-pgrx_0_10_2 = cargo-pgrx.overrideAttrs (old: rec { - name = "cargo-pgrx-${version}"; - version = "0.10.2"; - - src = fetchCrate { - pname = "cargo-pgrx"; - inherit version; - hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls="; - }; - - cargoDeps = old.cargoDeps.overrideAttrs (_: { - inherit src; - outputHash = "sha256-XyI3RaPI3Edm/tCP2xoZemib2d2n2cAhobgk9Oafg6s="; - }); - }); - -in - (buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_10_2; }) rec { inherit postgresql; -- cgit 1.4.1 From 72d1bae4063ef7f34658d645af65d764c8bc6fc0 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Fri, 15 Mar 2024 04:20:00 +0000 Subject: postgresqlPackages.pgvecto-rs: use cargo-pgrx_0_11_2 from top-level --- .../sql/postgresql/ext/pgvecto-rs/default.nix | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix index 23d4499029ea..d6a4f24bf5e6 100644 --- a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix +++ b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix @@ -1,6 +1,6 @@ { lib , buildPgrxExtension -, cargo-pgrx +, cargo-pgrx_0_11_2 , clang_16 , fetchCrate , fetchFromGitHub @@ -23,27 +23,11 @@ let bindgenHook = rustPlatform.bindgenHook.override { inherit clang; }; }; +in +(buildPgrxExtension.override { # Upstream only works with a fixed version of cargo-pgrx for each release, # so we're pinning it here to avoid future incompatibility. # See https://docs.pgvecto.rs/developers/development.html#environment, step 6 - cargo-pgrx_0_11_2 = cargo-pgrx.overrideAttrs (old: rec { - pname = "cargo-pgrx"; - version = "0.11.2"; - - src = fetchCrate { - pname = "cargo-pgrx"; - inherit version; - hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM="; - }; - - cargoDeps = old.cargoDeps.overrideAttrs (_: { - inherit src; - outputHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="; - }); - }); - -in -(buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_11_2; rustPlatform = rustPlatform'; }) rec { -- cgit 1.4.1