Unverified Commit 86de7cd8 authored by Yt's avatar Yt Committed by GitHub
Browse files

Merge pull request #296336 from marsam/refactor-cargo-pgrx

cargo-pgrx: refactor
parents 560a2137 72d1bae4
Loading
Loading
Loading
Loading
+63 −28
Original line number Diff line number Diff line
{ 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
  generic =
    { version
    , hash
    , cargoHash
    }:
    rustPlatform.buildRustPackage rec {
  inherit version pname;
      pname = "cargo-pgrx";

      inherit version;

      src = fetchCrate {
    inherit version pname;
    hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM=";
        inherit version pname hash;
      };

  cargoHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI=";
      inherit cargoHash;

  nativeBuildInputs = [ pkg-config ];
      nativeBuildInputs = lib.optionals stdenv.isLinux [
        pkg-config
      ];

  buildInputs = [ openssl ]
    ++ lib.optionals stdenv.isDarwin [ Security ];
      buildInputs = lib.optionals stdenv.isLinux [
        openssl
      ] ++ lib.optionals stdenv.isDarwin [
        darwin.apple_sdk.frameworks.Security
      ];

      preCheck = ''
        export PGRX_HOME=$(mktemp -d)
@@ -29,11 +44,31 @@ rustPlatform.buildRustPackage rec {
      ];

      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}";
        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=";
  };

  cargo-pgrx_0_11_3 = generic {
    version = "0.11.3";
    hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";
    cargoHash = "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw=";
  };
}
+3 −19
Original line number Diff line number Diff line
{ 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 {
+1 −20
Original line number Diff line number Diff line
@@ -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;

+7 −3
Original line number Diff line number Diff line
@@ -16829,9 +16829,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;
  };