|
53 | 53 | buildFeatures ? [ ],
|
54 | 54 | cargoBuildFlags ? [ ],
|
55 | 55 | postgresql,
|
| 56 | + # enable override to generate bindings using bindgenHook. |
| 57 | + # Some older versions of cargo-pgrx use a bindgenHook that is not compatible with the |
| 58 | + # current clang version present in stdenv |
| 59 | + bindgenHook ? rustPlatform.bindgenHook, |
56 | 60 | # cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the
|
57 | 61 | # dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
|
58 | 62 | # if you include the generated code in the output via postInstall.
|
|
87 | 91 | pushd "${buildAndTestSubdir}"
|
88 | 92 | '';
|
89 | 93 | maybeLeaveBuildAndTestSubdir = lib.optionalString (buildAndTestSubdir != null) "popd";
|
| 94 | + pgrxBinaryName = if builtins.compareVersions "0.7.4" cargo-pgrx.version >= 0 then "pgx" else "pgrx"; |
90 | 95 |
|
91 | 96 | pgrxPostgresMajor = lib.versions.major postgresql.version;
|
92 | 97 | preBuildAndTest = ''
|
93 | 98 | export PGRX_HOME=$(mktemp -d)
|
| 99 | + export PGX_HOME=$PGRX_HOME |
94 | 100 | export PGDATA="$PGRX_HOME/data-${pgrxPostgresMajor}/"
|
95 |
| - cargo-pgrx pgrx init "--pg${pgrxPostgresMajor}" ${lib.getDev postgresql}/bin/pg_config |
| 101 | + cargo-${pgrxBinaryName} ${pgrxBinaryName} init "--pg${pgrxPostgresMajor}" ${lib.getDev postgresql}/bin/pg_config |
96 | 102 |
|
97 | 103 | # unix sockets work in sandbox, too.
|
98 | 104 | export PGHOST="$(mktemp -d)"
|
|
127 | 133 | cargo-pgrx
|
128 | 134 | postgresql
|
129 | 135 | pkg-config
|
130 |
| - rustPlatform.bindgenHook |
| 136 | + bindgenHook |
131 | 137 | ]
|
132 | 138 | ++ lib.optionals useFakeRustfmt [ fakeRustfmt ];
|
133 | 139 |
|
|
138 | 144 | ${preBuildAndTest}
|
139 | 145 | ${maybeEnterBuildAndTestSubdir}
|
140 | 146 |
|
141 |
| - PGRX_BUILD_FLAGS="--frozen -j $NIX_BUILD_CORES ${builtins.concatStringsSep " " cargoBuildFlags}" \ |
| 147 | + export PGRX_BUILD_FLAGS="--frozen -j $NIX_BUILD_CORES ${builtins.concatStringsSep " " cargoBuildFlags}" |
| 148 | + export PGX_BUILD_FLAGS="$PGRX_BUILD_FLAGS" |
142 | 149 | ${lib.optionalString stdenv.hostPlatform.isDarwin ''RUSTFLAGS="''${RUSTFLAGS:+''${RUSTFLAGS} }-Clink-args=-Wl,-undefined,dynamic_lookup"''} \
|
143 |
| - cargo pgrx package \ |
| 150 | + cargo ${pgrxBinaryName} package \ |
144 | 151 | --pg-config ${lib.getDev postgresql}/bin/pg_config \
|
145 | 152 | ${maybeDebugFlag} \
|
146 | 153 | --features "${builtins.concatStringsSep " " buildFeatures}" \
|
|
160 | 167 |
|
161 | 168 | ${maybeEnterBuildAndTestSubdir}
|
162 | 169 |
|
163 |
| - cargo-pgrx pgrx stop all |
| 170 | + cargo-${pgrxBinaryName} ${pgrxBinaryName} stop all |
164 | 171 |
|
165 | 172 | mv $out/${postgresql}/* $out
|
166 | 173 | mv $out/${postgresql.lib}/* $out
|
|
0 commit comments