Skip to content

Commit 659cf99

Browse files
authored
Drop explicit pgrx outputs/packages (#2475)
pgrx is a build dep for rust extensions but not really necessary as an output in this repo. These attributes aren't even used anyway since we use mkPgrxExtension to build rust extensions and that uses pgrxs defined in nix/ext/versions.json which builds pgrx using hashes from nix/cargo-pgrx/versions.json. These were only used for devshells for the extensions but those are better off in their own repos.
1 parent 9d7f4ea commit 659cf99

5 files changed

Lines changed: 28 additions & 146 deletions

File tree

‎nix/cargo-pgrx/default.nix‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ let
1515
cargo = rust-bin.stable.${rustVersion}.default;
1616
rustc = rust-bin.stable.${rustVersion}.default;
1717
});
18+
in
19+
{
1820
mkCargoPgrx =
1921
{
2022
version,
@@ -65,37 +67,4 @@ let
6567
mainProgram = "cargo-pgrx";
6668
};
6769
};
68-
in
69-
{
70-
cargo-pgrx_0_10_2 = mkCargoPgrx {
71-
version = "0.10.2";
72-
hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls=";
73-
cargoHash = "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI=";
74-
};
75-
cargo-pgrx_0_11_3 = mkCargoPgrx {
76-
version = "0.11.3";
77-
hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";
78-
cargoHash = "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw=";
79-
};
80-
cargo-pgrx_0_12_6 = mkCargoPgrx {
81-
version = "0.12.6";
82-
hash = "sha256-7aQkrApALZe6EoQGVShGBj0UIATnfOy2DytFj9IWdEA=";
83-
cargoHash = "sha256-pnMxWWfvr1/AEp8DvG4awig8zjdHizJHoZ5RJA8CL08=";
84-
};
85-
cargo-pgrx_0_12_9 = mkCargoPgrx {
86-
version = "0.12.9";
87-
hash = "sha256-aR3DZAjeEEAjLQfZ0ZxkjLqTVMIEbU0UiZ62T4BkQq8=";
88-
cargoHash = "sha256-yZpD3FriL9UbzRtdFkfIfFfYIrRPYxr/lZ5rb0YBTPc=";
89-
};
90-
cargo-pgrx_0_14_3 = mkCargoPgrx {
91-
version = "0.14.3";
92-
hash = "sha256-3TsNpEqNm3Uol5XPW1i0XEbP2fF2+RKB2d7lO6BDnvQ=";
93-
cargoHash = "sha256-LZUXhjMxkBs3O5feH4X5NQC7Qk4Ja6M5+sAYaSCikrY=";
94-
};
95-
cargo-pgrx_0_19_2 = mkCargoPgrx {
96-
version = "0.19.2";
97-
hash = "sha256-PANc819AhIE9yJ6NFHGJxHJHWZyR2Srmj2cEz3vQmJk=";
98-
cargoHash = "sha256-cTD7x36FvFUIwVLuAqrOJ75vLDppITiDrY8Fs3RjPqU=";
99-
};
100-
inherit mkCargoPgrx;
10170
}

‎nix/devShells.nix‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@
2121
paramiko
2222
]
2323
);
24-
mkCargoPgrxDevShell =
25-
{ pgrxVersion, rustVersion }:
26-
pkgs.mkShell {
27-
packages = with pkgs; [
28-
self'.packages."cargo-pgrx_${pgrxVersion}"
29-
(rust-bin.stable.${rustVersion}.default.override { extensions = [ "rust-src" ]; })
30-
];
31-
shellHook = ''
32-
export HISTFILE=.history
33-
'';
34-
};
3524
docvenv = pkgs.python3.buildEnv.override {
3625
extraLibs = self'.packages.docs.nativeBuildInputs;
3726
};
@@ -147,14 +136,6 @@
147136
}
148137
];
149138
};
150-
cargo-pgrx_0_11_3 = mkCargoPgrxDevShell {
151-
pgrxVersion = "0_11_3";
152-
rustVersion = "1.80.0";
153-
};
154-
cargo-pgrx_0_12_6 = mkCargoPgrxDevShell {
155-
pgrxVersion = "0_12_6";
156-
rustVersion = "1.80.0";
157-
};
158139
};
159140
};
160141
}

‎nix/docs/creating-pgrx-extension.md‎

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Creating a New pgrx Extension
1+
# Creating a new pgrx extension
22

33
This guide covers how to set up a new cargo pgrx PostgreSQL extension in this project.
44

5-
## Template: New pgrx Extension
5+
## Template: New pgrx extension
66

77
### 1. Directory Structure
88

@@ -122,19 +122,21 @@ Edit `nix/ext/versions.json` and add your extension:
122122
"my_extension": {
123123
"0.1.0": {
124124
"postgresql": ["15", "17"],
125-
"hash": "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
125+
"hash": "",
126126
"pgrx": "0.12.6",
127127
"rust": "1.80.0"
128128
}
129129
}
130130
}
131131
```
132132

133-
**To calculate the hash:** Use a dummy hash first, then run:
133+
Run the following to calculate content hash:
134+
134135
```bash
135136
nix build .#psql_15.exts.my_extension -L
136137
```
137-
The error message will show the correct hash.
138+
139+
The error message will show the correct hash, update the `hash` attribute in versions.json.
138140

139141
### 4. Register in postgres.nix
140142

@@ -149,59 +151,14 @@ ourExtensions = [
149151

150152
## Files to Modify (Summary)
151153

152-
| File | Change |
153-
|------|--------|
154-
| `nix/ext/my_extension/default.nix` | Create new file |
155-
| `nix/ext/versions.json` | Add version entry |
156-
| `nix/packages/postgres.nix` | Add to `ourExtensions` list |
157-
| `nix/tests/sql/my_extension.sql` | (optional) Add test SQL |
154+
| File | Change |
155+
| ------------------------------------- | ------------------------------- |
156+
| `nix/ext/my_extension/default.nix` | Create new file |
157+
| `nix/ext/versions.json` | Add version entry |
158+
| `nix/packages/postgres.nix` | Add to `ourExtensions` list |
159+
| `nix/tests/sql/my_extension.sql` | (optional) Add test SQL |
158160
| `nix/tests/expected/my_extension.out` | (optional) Expected test output |
159161

160-
## Using nix develop for Extension Development
161-
162-
### Available Dev Shells
163-
164-
```bash
165-
# List all available dev shells
166-
nix flake show | grep devShells
167-
168-
# Enter pgrx 0.12.6 development environment (Rust 1.80.0)
169-
nix develop .#cargo-pgrx_0_12_6
170-
171-
# Enter pgrx 0.14.3 development environment (Rust 1.87.0)
172-
nix develop .#cargo-pgrx_0_14_3
173-
174-
# Default shell (general tooling, not pgrx-specific)
175-
nix develop
176-
```
177-
178-
### Inside the Dev Shell
179-
180-
Once inside `nix develop .#cargo-pgrx_0_12_6`:
181-
182-
```bash
183-
# Initialize pgrx (first time only)
184-
cargo pgrx init --pg15 $(which pg_config)
185-
186-
# Create a new extension from scratch
187-
cargo pgrx new my_extension
188-
cd my_extension
189-
190-
# Build and test your extension
191-
cargo pgrx run pg15
192-
193-
# Package for release
194-
cargo pgrx package
195-
```
196-
197-
### Dev Shell Contents
198-
199-
The pgrx dev shells provide:
200-
- Correct Rust toolchain version
201-
- `cargo-pgrx` CLI matching the pgrx version
202-
- PostgreSQL headers and pg_config
203-
- Required build tools (pkg-config, openssl, etc.)
204-
205162
## Build Commands
206163

207164
```bash
@@ -222,17 +179,17 @@ nix flake check -L
222179

223180
From `nix/cargo-pgrx/versions.json`:
224181

225-
| pgrx Version | Rust Version |
226-
|--------------|--------------|
227-
| 0.12.6 | 1.80.0, 1.81.0 |
228-
| 0.14.3 | 1.87.0 |
182+
| pgrx Version | Rust Version |
183+
| ------------ | -------------- |
184+
| 0.12.6 | 1.80.0, 1.81.0 |
185+
| 0.14.3 | 1.87.0 |
229186

230187
Match your extension's pgrx dependency to a supported combination.
231188

232189
## Existing Examples to Reference
233190

234-
| Extension | Path | Notes |
235-
|-----------|------|-------|
236-
| pg_graphql | `nix/ext/pg_graphql/default.nix` | Clean pgrx example |
237-
| pg_jsonschema | `nix/ext/pg_jsonschema/default.nix` | Simple single-crate |
238-
| wrappers | `nix/ext/wrappers/default.nix` | Complex with git deps |
191+
| Extension | Path | Notes |
192+
| ------------- | ----------------------------------- | --------------------- |
193+
| pg_graphql | `nix/ext/pg_graphql/default.nix` | Clean pgrx example |
194+
| pg_jsonschema | `nix/ext/pg_jsonschema/default.nix` | Simple single-crate |
195+
| wrappers | `nix/ext/wrappers/default.nix` | Complex with git deps |

‎nix/docs/updating-pgrx-extensions.md‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ Use this when the extension requires a newer pgrx version.
119119
| `nix/ext/versions.json` | Add new version with new pgrx version |
120120
| `nix/ext/<extension>/default.nix` | Add old version to `allPreviouslyPackagedVersions` |
121121
| `nix/cargo-pgrx/versions.json` | Add new pgrx version (if not already present) |
122-
| `nix/cargo-pgrx/default.nix` | Add new `cargo-pgrx_x_y_z` entry (if not already present) |
123-
| `nix/overlays/default.nix` | Add new `buildPgrxExtension_x_y_z` (if not already present) |
124122

125123
### Steps
126124

@@ -143,27 +141,10 @@ Use this when the extension requires a newer pgrx version.
143141
}
144142
```
145143

146-
The `rust` object maps Rust versions to their corresponding `cargoHash`. You'll need to calculate both the `hash` (for the pgrx crate) and `cargoHash` (for cargo dependencies).
144+
The `rust` object maps Rust versions to their corresponding `cargoHash`.
145+
You'll need to calculate both the `hash` (for the pgrx crate) and `cargoHash` (for cargo dependencies).
147146

148-
3. **Add cargo-pgrx entry** in `nix/cargo-pgrx/default.nix`:
149-
150-
```nix
151-
cargo-pgrx_0_16_1 = mkCargoPgrx {
152-
version = "0.16.1";
153-
hash = "";
154-
cargoHash = "";
155-
};
156-
```
157-
158-
4. **Add overlay entry** in `nix/overlays/default.nix`:
159-
160-
```nix
161-
buildPgrxExtension_0_16_1 = prev.buildPgrxExtension.override {
162-
cargo-pgrx = final.cargo-pgrx.cargo-pgrx_0_16_1;
163-
};
164-
```
165-
166-
5. **Update `nix/ext/versions.json`** with the new extension version:
147+
3. **Update `nix/ext/versions.json`** with the new extension version:
167148

168149
```json
169150
"0.5.7": {
@@ -174,7 +155,7 @@ Use this when the extension requires a newer pgrx version.
174155
}
175156
```
176157

177-
6. **Stage and build** to calculate hashes:
158+
4. **Stage and build** to calculate hashes:
178159

179160
```bash
180161
git add .

‎nix/packages/default.nix‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@
123123
inherit (pkgs.callPackage ./wal-g.nix { }) wal-g-2 wal-g-3;
124124
inherit (supascan-pkgs) goss supascan supascan-specs;
125125
inherit (pg-startup-profiler-pkgs) pg-startup-profiler;
126-
inherit (pkgs.cargo-pgrx)
127-
cargo-pgrx_0_11_3
128-
cargo-pgrx_0_12_6
129-
cargo-pgrx_0_12_9
130-
cargo-pgrx_0_14_3
131-
;
132126
}
133127
// lib.optionalAttrs pkgs.stdenv.isDarwin {
134128
setup-darwin-linux-builder = pkgs.callPackage ./setup-darwin-linux-builder.nix {

0 commit comments

Comments
 (0)