1{
2 fetchCrate,
3 lib,
4 openssl,
5 pkg-config,
6 rustPlatform,
7}:
8
9let
10 generic =
11 {
12 version,
13 hash,
14 cargoHash,
15 }:
16 rustPlatform.buildRustPackage {
17 pname = "cargo-pgrx";
18
19 inherit version;
20
21 src = fetchCrate {
22 inherit version hash;
23 pname = "cargo-pgrx";
24 };
25
26 inherit cargoHash;
27
28 nativeBuildInputs = [
29 pkg-config
30 ];
31
32 buildInputs = [
33 openssl
34 ];
35
36 preCheck = ''
37 export PGRX_HOME=$(mktemp -d)
38 '';
39
40 checkFlags = [
41 # requires pgrx to be properly initialized with cargo pgrx init
42 "--skip=command::schema::tests::test_parse_managed_postmasters"
43 ];
44
45 meta = {
46 description = "Build Postgres Extensions with Rust";
47 homepage = "https://github.com/pgcentralfoundation/pgrx";
48 changelog = "https://github.com/pgcentralfoundation/pgrx/releases/tag/v${version}";
49 license = lib.licenses.mit;
50 maintainers = with lib.maintainers; [
51 happysalada
52 matthiasbeyer
53 ];
54 mainProgram = "cargo-pgrx";
55 };
56 };
57in
58{
59 # Default version for direct usage.
60 # Not to be used with buildPgrxExtension, where it should be pinned.
61 # When you make an extension use the latest version, *copy* this to a separate pinned attribute.
62 cargo-pgrx = generic {
63 version = "0.16.1";
64 hash = "sha256-AjoBr+/sEPdzbD0wLUNVm2syCySkGaFOFQ70TST1U9w=";
65 cargoHash = "sha256-95DHq5GLnAqb3bbKwwaeBeKEmkfRh81ZTRaJ7L59DAg=";
66 };
67}
68// lib.mapAttrs (_: generic) (import ./pinned.nix)