Skip to content

Commit 57502a8

Browse files
jfrochesamrose
authored andcommitted
feat(cargo-pgrx): build extensions with specified Rust version
This change allows developers to target specific Rust versions for building extensions. It implements support for building cargo extensions and `cargo-pgrx` using the specified Rust version.
1 parent 710a35c commit 57502a8

File tree

5 files changed

+20
-29
lines changed

5 files changed

+20
-29
lines changed

nix/cargo-pgrx/default.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ let
6363
};
6464
in
6565
{
66-
cargo-pgrx_0_11_2 = mkCargoPgrx {
67-
version = "0.11.2";
68-
hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM=";
69-
cargoHash = "sha256-CbU5B0pvB9ApTZOdYP/ZwuIG8bqGzk/ING2PCM0q2bQ=";
70-
};
7166
cargo-pgrx_0_11_3 = mkCargoPgrx {
7267
version = "0.11.3";
7368
hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";

nix/cargo-pgrx/mkPgrxExtension.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
rust-bin,
77
}:
88
let
9-
inherit ((callPackage ./default.nix { inherit rustVersion; })) mkCargoPgrx;
9+
inherit
10+
(
11+
(callPackage ./default.nix {
12+
inherit rustVersion;
13+
})
14+
)
15+
mkCargoPgrx
16+
;
1017

1118
rustPlatform = makeRustPlatform {
1219
cargo = rust-bin.stable.${rustVersion}.default;
@@ -19,12 +26,12 @@ let
1926
let
2027
pgrx =
2128
versions.${pgrxVersion}
22-
or (throw "Unsupported pgrx version ${pgrxVersion}. Available versions: ${builtins.toString (builtins.attrNames versions)}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
29+
or (throw "Unsupported pgrx version ${pgrxVersion}. Available versions: ${builtins.attrNames versions}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
2330
mapping = {
2431
inherit (pgrx) hash;
2532
cargoHash =
2633
pgrx.rust."${rustVersion}".cargoHash
27-
or (throw "Unsupported rust version ${rustVersion} for pgrx version ${pgrxVersion}. Available Rust versions: ${builtins.toString (builtins.attrNames pgrx.rust)}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
34+
or (throw "Unsupported rust version ${rustVersion} for pgrx version ${pgrxVersion}. Available Rust versions: ${builtins.attrNames pgrx.rust}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
2835
};
2936
in
3037
mkCargoPgrx {

nix/cargo-pgrx/versions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@
5757
}
5858
}
5959
}
60-
6160
}

nix/ext/pg_graphql.nix

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
2+
callPackages,
23
lib,
34
stdenv,
45
buildEnv,
56
fetchFromGitHub,
67
postgresql,
7-
buildPgrxExtension_0_11_2,
8-
buildPgrxExtension_0_11_3,
9-
buildPgrxExtension_0_12_6,
10-
buildPgrxExtension_0_12_9,
118
rust-bin,
129
rsync,
1310
}:
1411

1512
let
1613
pname = "pg_graphql";
1714
build =
18-
version: hash: rustVersion: buildPgrxExtension:
15+
version: hash: rustVersion: pgrxVersion:
1916
let
2017
cargo = rust-bin.stable.${rustVersion}.default;
21-
previousVersions = lib.filter (v: v != version) versions;
18+
previousVersions = lib.filter (v: v != version) versions; # FIXME
19+
mkPgrxExtension = callPackages ../cargo-pgrx/mkPgrxExtension.nix {
20+
inherit rustVersion pgrxVersion;
21+
};
22+
2223
in
23-
buildPgrxExtension rec {
24+
mkPgrxExtension rec {
2425
inherit pname version postgresql;
2526

2627
src = fetchFromGitHub {
@@ -125,19 +126,8 @@ let
125126
versions = lib.naturalSort (lib.attrNames supportedVersions);
126127
latestVersion = lib.last versions;
127128
numberOfVersions = builtins.length versions;
128-
mapPgrxExtension =
129-
version:
130-
{
131-
"0.11.2" = buildPgrxExtension_0_11_2;
132-
"0.11.3" = buildPgrxExtension_0_11_3;
133-
"0.12.6" = buildPgrxExtension_0_12_6;
134-
"0.12.9" = buildPgrxExtension_0_12_9;
135-
}
136-
."${version}";
137129
packages = builtins.attrValues (
138-
lib.mapAttrs (
139-
name: value: build name value.hash value.rust (mapPgrxExtension value.pgrx)
140-
) supportedVersions
130+
lib.mapAttrs (name: value: build name value.hash value.rust value.pgrx) supportedVersions
141131
);
142132
in
143133
buildEnv {

nix/ext/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
],
8282
"hash": "sha256-Kxo4o8+hfSTOjvhYyGF2BpksWfW/AMCCH4qom4AGw18=",
8383
"pgrx": "0.11.2",
84-
"rust": "1.85.1"
84+
"rust": "1.70.0"
8585
},
8686
"1.5.0": {
8787
"postgresql": [

0 commit comments

Comments
 (0)