Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
32ad2b5
feat: add an utility script to generate nix/ext/versions.json
yvan-sraka Oct 27, 2025
9c61bb6
feat(wrappers): move patch(s) and lock file of every version into its…
yvan-sraka Oct 27, 2025
82c94fb
feat(wrappers): temporarily remove some versions to please the CI
yvan-sraka Nov 11, 2025
356b6f1
feat(wrappers): add versions 0.5.4 and 0.5.5
yvan-sraka Nov 11, 2025
2ff340a
feat(wrappers): add versions 0.5.2 and 0.5.3
yvan-sraka Nov 11, 2025
41c7ece
feat(wrappers): add versions 0.5.0 and 0.5.1
yvan-sraka Nov 11, 2025
d0b5ddb
feat(wrappers): add versions 0.4.5 and 0.4.6
yvan-sraka Nov 11, 2025
f25675a
feat(wrappers): add versions 0.4.3 and 0.4.4
yvan-sraka Nov 12, 2025
f372b15
feat(wrappers): add versions 0.4.1 and 0.4.2
yvan-sraka Nov 12, 2025
9369fd0
feat(wrappers): add versions 0.2.0 and 0.3.0
yvan-sraka Nov 12, 2025
507a4b8
feat(wrappers): add versions 0.1.18 and 0.1.19
yvan-sraka Nov 12, 2025
566b32d
feat(wrappers): add versions 0.1.16 and 0.1.17
yvan-sraka Nov 12, 2025
3476945
feat(wrappers): add versions 0.1.14 and 0.1.15
yvan-sraka Nov 12, 2025
7c77095
feat(wrappers): add versions 0.1.11 and 0.1.12
yvan-sraka Nov 12, 2025
10ba5a4
feat(wrappers): add versions 0.1.9 and 0.1.10
yvan-sraka Nov 12, 2025
ab7b540
feat(wrappers): add versions 0.1.7 and 0.1.8
yvan-sraka Nov 12, 2025
0950748
Update nix/ext/scripts/update_versions_json.py
yvan-sraka Jan 19, 2026
2b700f9
fix: prefer peeled commit hashes for annotated tags
yvan-sraka Jan 19, 2026
9387f95
fix: remove unused loop variable in tag processing
yvan-sraka Jan 19, 2026
e4fa22c
refactor: consolidate duplicate version conditions as suggested
yvan-sraka Jan 19, 2026
3a2444b
chore: bump version suffix to test
yvan-sraka Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: "17.6.0.038-orioledb"
postgres17: "17.6.1.081"
postgres15: "15.14.1.081"
postgresorioledb-17: "17.6.0.038-orioledb-old-wrapper-ext"
postgres17: "17.6.1.081-old-wrapper-ext"
postgres15: "15.14.1.081-old-wrapper-ext"

# Non Postgres Extensions
pgbouncer_release: 1.25.1
Expand Down
19 changes: 19 additions & 0 deletions nix/cargo-pgrx/versions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"0.5.6": {
"hash": "sha256-CbQWgt/M/QVKpuOzY04OEZNX4DauYPMz2404WQlAvTw=",
"rust": {
"1.83.0": {
"cargoHash": "sha256-sqAOhSZXzqxOVkEbqpd+9MoXqEFlkFufQ8O1zAXPnLQ="
}
}
},
"0.6.1": {
"hash": "sha256-O4eHVbJBudybsPab+zr2eXnfheREMqLAHAKm2GDbfrs=",
"rust": {
"1.82.0": {
"cargoHash": "sha256-lcnUVO8dJET5g6wM1YgTsj4uP4I3vVZy5PWBKIsvLB8="
},
"1.83.0": {
"cargoHash": "sha256-MucGrA3qXgJOcT2LMNmoNOhQi8QA3LuqgZEHKycLCCo="
}
}
},
Expand All @@ -15,6 +26,14 @@
}
}
},
"0.8.3": {
"hash": "sha256-1SdGPhyT/m65De3QTpEYAGvzbB6eLH1yUZ8XoN9LaVc=",
"rust": {
"1.70.0": {
"cargoHash": "sha256-Sp4SJT0FUyVBviavLXFMDctbOfe70OCLG3zutvbVoUQ="
}
}
},
"0.9.5": {
"hash": "sha256-GpXQUOBuojAqPXyRR+k8AVW2XzBbn6V0+2dhP4w4Vs8=",
"rust": {
Expand Down
19 changes: 18 additions & 1 deletion nix/docs/update-extension.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Update an existing nix extension

## Overview
Expand Down Expand Up @@ -226,3 +225,21 @@ The `nix flake check -L` command is your primary local testing tool:
```bash
nix flake check -L 2>&1 | tee build.log
```

---

### Automating updates with `nix/ext/scripts/update_versions_json.py`

A helper script is at `nix/ext/scripts/update_versions_json.py`. It updates `nix/ext/versions.json` for a given extension by fetching all git tags from the provided repository, keeping only tags that parse as valid version numbers, and computing SRI hashes for each version (the part this mainly aims to automate).

Example usage, Step 1: add tags as ignored placeholders (fast, no hash computation):
```bash
./nix/ext/scripts/update_versions_json.py pg_graphql https://github.com/supabase/pg_graphql --ignore
```

Step 2: remove the versions of interest from the generated list, then re-run the script without `--ignore` to this time compute hashes (this indeed requires `nix`, network access, and may take some time):
```bash
./nix/ext/scripts/update_versions_json.py pg_graphql https://github.com/supabase/pg_graphql
```

After running the script, run the usual verification steps (e.g., `nix build .#psql_15/exts/<extension>-all` and `nix flake check -L`) to validate the new versions.
104 changes: 104 additions & 0 deletions nix/ext/scripts/update_versions_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 git nix-prefetch-git python3Packages.packaging

import subprocess
import json
import argparse
from pathlib import Path
from typing import Dict, List, Union
from packaging.version import parse as parse_version, InvalidVersion

Schema = Dict[str, Dict[str, Dict[str, Union[List[str], str, bool]]]]

POSTGRES_VERSIONS: List[str] = ["15", "17"]
VERSIONS_JSON_PATH = "versions.json"
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix versions.json path resolution (currently relative to CWD).
Running the script from repo root (as documented) will write to ./versions.json, not nix/ext/versions.json. Anchor the path to the script location to avoid updating the wrong file.

🔧 Proposed fix
-VERSIONS_JSON_PATH = "versions.json"
+VERSIONS_JSON_PATH = Path(__file__).resolve().parents[1] / "versions.json"
@@
-    if not Path(VERSIONS_JSON_PATH).exists():
+    if not VERSIONS_JSON_PATH.exists():
         return {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
POSTGRES_VERSIONS: List[str] = ["15", "17"]
VERSIONS_JSON_PATH = "versions.json"
POSTGRES_VERSIONS: List[str] = ["15", "17"]
VERSIONS_JSON_PATH = Path(__file__).resolve().parents[1] / "versions.json"
🤖 Prompt for AI Agents
In `@nix/ext/scripts/update_versions_json.py` around lines 13 - 14, The
VERSIONS_JSON_PATH currently points to "versions.json" which is relative to the
current working directory; update it to be anchored to the script file so it
always targets the nix/ext/versions.json file. In update_versions_json.py,
import Path from pathlib and change VERSIONS_JSON_PATH to compute
Path(__file__).resolve().parent / "versions.json" (keep POSTGRES_VERSIONS
unchanged) and use that Path for open/read/write operations so the script writes
to the script directory regardless of CWD.



def run(cmd: List[str]) -> str:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
return result.stdout.strip()


def get_tags(url: str) -> Dict[str, str]:
output = run(["git", "ls-remote", "--tags", url])
tags: Dict[str, str] = {}
peeled_tags: Dict[str, str] = {}

# First pass: collect both normal and peeled entries
for line in output.splitlines():
parts = line.split("\t")
if len(parts) == 2:
commit_hash, ref = parts
if ref.startswith("refs/tags/"):
if ref.endswith("^{}"):
# This is a peeled tag (commit hash for annotated tag)
tag = ref.removeprefix("refs/tags/").removesuffix("^{}")
peeled_tags[tag] = commit_hash
else:
# Regular tag entry
tag = ref.removeprefix("refs/tags/")
try:
parse_version(tag)
except InvalidVersion:
continue
tags[tag] = commit_hash

# Second pass: prefer peeled commit hashes when available
for tag, _ in tags.items():
if tag in peeled_tags:
tags[tag] = peeled_tags[tag]

return tags


def get_sri_hash(url: str, commit_hash: str) -> str:
output = run(["nix-prefetch-git", "--quiet", "--url", url, "--rev", commit_hash])
nix_hash = json.loads(output)["sha256"]
return "sha256-" + run(["nix", "hash", "to-base64", "--type", "sha256", nix_hash])


def load() -> Schema:
if not Path(VERSIONS_JSON_PATH).exists():
return {}
with open(VERSIONS_JSON_PATH, "r", encoding="utf-8") as f:
return json.load(f)


def build(name: str, url: str, data: Schema, ignore: bool = False) -> Schema:
tags = get_tags(url)
versions = data.get(name, {})
for tag, commit_hash in tags.items():
if tag in versions:
continue
if ignore:
versions[tag] = {"ignore": True}
else:
sri_hash = get_sri_hash(url, commit_hash)
versions[tag] = {"postgresql": POSTGRES_VERSIONS, "hash": sri_hash}
data[name] = versions
return data


def save(data: Schema) -> None:
sorted_data = {}
for name, versions in data.items():
sorted_data[name] = dict(
sorted(versions.items(), key=lambda item: parse_version(item[0]))
)
with open(VERSIONS_JSON_PATH, "w", encoding="utf-8") as f:
json.dump(sorted_data, f, indent=2)
f.write("\n")


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("extension_name")
parser.add_argument("git_repo_url")
parser.add_argument("--ignore", action="store_true")
args = parser.parse_args()

save(build(args.extension_name, args.git_repo_url, load(), ignore=args.ignore))


if __name__ == "__main__":
main()
123 changes: 122 additions & 1 deletion nix/ext/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@
"hash": "sha256-QC77AnPGpPQGEWi6JtJdiNsB2su5+aV2pKg5ImR2B0k="
}
},

"pgsodium": {
"3.0.4": {
"postgresql": [
Expand Down Expand Up @@ -582,6 +581,110 @@
}
},
"wrappers": {
"0.1.7": {
"postgresql": [
"15"
],
"hash": "sha256-aGq46W12XTxGH1KKxk2re0ul+9h0n/OIrFLsylS+Y3U=",
"pgrx": "0.6.1",
"rust": "1.82.0"
},
"0.1.8": {
"postgresql": [
"15"
],
"hash": "sha256-9h5T10mD4W7hEDdbtxkyxiY/pACX1Io33UGetGOlCZA=",
"pgrx": "0.6.1",
"rust": "1.82.0"
},
"0.1.9": {
"postgresql": [
"15"
],
"hash": "sha256-VZxbvPXwOGMbyLHMXFwAMbtzdapDA73qN+2obUdLR5Q=",
"pgrx": "0.6.1",
"rust": "1.82.0"
},
"0.1.10": {
"postgresql": [
"15"
],
"hash": "sha256-472lVh91iqaMNHJk21LUvPIrhm3yIzrvDbNHyUW8aBs=",
"pgrx": "0.6.1",
"rust": "1.82.0"
},
"0.1.11": {
"postgresql": [
"15"
],
"hash": "sha256-3zN8uWeQwVQCQ37+PyLC4wX9oiji6s2L3aIpWYcD28g=",
"pgrx": "0.6.1",
"rust": "1.82.0"
},
"0.1.12": {
"postgresql": [
"15"
],
"hash": "sha256-TScNbX+PBWUYgrBEnFXOaeXXfiOIa488H1oyIAw6v7I=",
"pgrx": "0.8.3",
"rust": "1.70.0"
},
"0.1.14": {
"postgresql": [
"15"
],
"hash": "sha256-w6rijRFUlWmwv4XE0G99ip2GkBF4nGTaX94kQvNRmJs=",
"pgrx": "0.8.3",
"rust": "1.70.0"
},
"0.1.15": {
"postgresql": [
"15"
],
"hash": "sha256-R5MvaCx3BwX8NVDqJPJfCOppC2XtKIshh58Hkbw6VHg=",
"pgrx": "0.9.7",
"rust": "1.70.0"
},
"0.1.16": {
"postgresql": [
"15"
],
"hash": "sha256-pfbTGC/cBgv+YuwJ1qMQpb4jZm6n5uvCFLZLS/ZWcfs=",
"pgrx": "0.9.7",
"rust": "1.70.0"
},
"0.1.17": {
"postgresql": [
"15"
],
"hash": "sha256-Wm4O98ms0/J9z/m4s4eYyxiRwTZhSqd9KpxvY42xyNE=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.1.18": {
"postgresql": [
"15"
],
"hash": "sha256-E4ql7D/lkb/J3Rr1kMEo37KxbFnqYPCdhuAIpVFLgB8=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.1.19": {
"postgresql": [
"15"
],
"hash": "sha256-wvsAqDk+1am6mSBCF5uzDArnbBIpLqTylLzF4VZ/p08=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.2.0": {
"postgresql": [
"15"
],
"hash": "sha256-F+S5uyubL3Tb3RTJ08Zf9gN8oLE/WkCWFA8RcKkDqes=",
"pgrx": "0.11.3",
"rust": "1.76.0"
},
"0.3.0": {
"postgresql": [
"15"
Expand Down Expand Up @@ -650,6 +753,24 @@
"pgrx": "0.12.9",
"rust": "1.84.0"
},
"0.5.1": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-3GfN3vZMFWf4FV/fSOe9ZN6KETmjoNw3Paz+JRzaH3c=",
"pgrx": "0.12.9",
"rust": "1.87.0"
},
"0.5.2": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-9VqQHduoAWnY8gtfRZLDOKiibfwuSTzyVFbH0uhsfCU=",
"pgrx": "0.14.3",
"rust": "1.87.0"
},
"0.5.3": {
"postgresql": [
"15",
Expand Down
Loading
Loading