|
1 | 1 | { |
2 | 2 | lib, |
| 3 | + cargo-pgrx, |
3 | 4 | fetchCrate, |
4 | | - openssl, |
5 | | - pkg-config, |
6 | 5 | makeRustPlatform, |
7 | | - stdenv, |
8 | 6 | rust-bin, |
9 | 7 | rustVersion ? "1.85.1", |
10 | 8 | }: |
|
14 | 12 | rustc = rust-bin.stable.${rustVersion}.default; |
15 | 13 | }; |
16 | 14 | mkCargoPgrx = |
17 | | - { |
18 | | - version, |
19 | | - hash, |
20 | | - cargoHash, |
21 | | - }: |
22 | | - let |
23 | | - pname = if builtins.compareVersions "0.7.4" version >= 0 then "cargo-pgx" else "cargo-pgrx"; |
24 | | - in |
25 | | - rustPlatform.buildRustPackage rec { |
26 | | - # rust-overlay uses 'cargo-auditable' wrapper for 'cargo' command, but it |
27 | | - # is using older version 0.18.1 of 'cargo_metadata' which doesn't support |
28 | | - # rust edition 2024, so we disable the 'cargo-auditable' just for now. |
29 | | - # ref: https://github.com/oxalica/rust-overlay/issues/153 |
30 | | - auditable = false; |
31 | | - inherit pname; |
32 | | - inherit version; |
33 | | - src = fetchCrate { inherit version pname hash; }; |
34 | | - inherit cargoHash; |
35 | | - nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ pkg-config ]; |
36 | | - buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ openssl ]; |
| 15 | + args: |
| 16 | + (cargo-pgrx.override { inherit rustPlatform; }).overrideAttrs rec { |
| 17 | + pname = if lib.versionOlder version "0.7.4" then "cargo-pgx" else "cargo-pgrx"; |
| 18 | + inherit (args) version; |
37 | 19 |
|
38 | | - OPENSSL_DIR = "${openssl.dev}"; |
39 | | - OPENSSL_INCLUDE_DIR = "${openssl.dev}/include"; |
40 | | - OPENSSL_LIB_DIR = "${openssl.out}/lib"; |
41 | | - PKG_CONFIG_PATH = "${openssl.dev}/lib/pkgconfig"; |
42 | | - preCheck = '' |
43 | | - export PGRX_HOME=$(mktemp -d) |
44 | | - ''; |
45 | | - checkFlags = [ |
46 | | - # requires pgrx to be properly initialized with cargo pgrx init |
47 | | - "--skip=command::schema::tests::test_parse_managed_postmasters" |
48 | | - ]; |
49 | | - meta = with lib; { |
50 | | - description = "Build Postgres Extensions with Rust"; |
51 | | - homepage = "https://github.com/pgcentralfoundation/pgrx"; |
52 | | - changelog = "https://github.com/pgcentralfoundation/pgrx/releases/tag/v${version}"; |
53 | | - license = licenses.mit; |
54 | | - maintainers = with maintainers; [ happysalada ]; |
55 | | - mainProgram = "cargo-pgrx"; |
| 20 | + src = fetchCrate { |
| 21 | + inherit pname; |
| 22 | + inherit (args) |
| 23 | + version |
| 24 | + hash |
| 25 | + ; |
| 26 | + }; |
| 27 | + |
| 28 | + cargoDeps = rustPlatform.fetchCargoVendor { |
| 29 | + inherit |
| 30 | + pname |
| 31 | + src |
| 32 | + ; |
| 33 | + inherit (args) version; |
| 34 | + hash = args.cargoHash; |
56 | 35 | }; |
57 | 36 | }; |
58 | 37 | in |
59 | | -{ |
60 | | - cargo-pgrx_0_10_2 = mkCargoPgrx { |
| 38 | +lib.mapAttrs (_: mkCargoPgrx) { |
| 39 | + cargo-pgrx_0_10_2 = { |
61 | 40 | version = "0.10.2"; |
62 | 41 | hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls="; |
63 | 42 | cargoHash = "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="; |
64 | 43 | }; |
65 | | - cargo-pgrx_0_11_3 = mkCargoPgrx { |
| 44 | + cargo-pgrx_0_11_3 = { |
66 | 45 | version = "0.11.3"; |
67 | 46 | hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU="; |
68 | 47 | cargoHash = "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw="; |
69 | 48 | }; |
70 | | - cargo-pgrx_0_12_6 = mkCargoPgrx { |
| 49 | + cargo-pgrx_0_12_6 = { |
71 | 50 | version = "0.12.6"; |
72 | 51 | hash = "sha256-7aQkrApALZe6EoQGVShGBj0UIATnfOy2DytFj9IWdEA="; |
73 | 52 | cargoHash = "sha256-pnMxWWfvr1/AEp8DvG4awig8zjdHizJHoZ5RJA8CL08="; |
74 | 53 | }; |
75 | | - cargo-pgrx_0_12_9 = mkCargoPgrx { |
| 54 | + cargo-pgrx_0_12_9 = { |
76 | 55 | version = "0.12.9"; |
77 | 56 | hash = "sha256-aR3DZAjeEEAjLQfZ0ZxkjLqTVMIEbU0UiZ62T4BkQq8="; |
78 | 57 | cargoHash = "sha256-yZpD3FriL9UbzRtdFkfIfFfYIrRPYxr/lZ5rb0YBTPc="; |
79 | 58 | }; |
80 | | - cargo-pgrx_0_14_3 = mkCargoPgrx { |
| 59 | + cargo-pgrx_0_14_3 = { |
81 | 60 | version = "0.14.3"; |
82 | 61 | hash = "sha256-3TsNpEqNm3Uol5XPW1i0XEbP2fF2+RKB2d7lO6BDnvQ="; |
83 | 62 | cargoHash = "sha256-LZUXhjMxkBs3O5feH4X5NQC7Qk4Ja6M5+sAYaSCikrY="; |
84 | 63 | }; |
| 64 | +} |
| 65 | +// { |
85 | 66 | inherit mkCargoPgrx; |
86 | 67 | } |
0 commit comments