Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.5.1.052-orioledb"
postgres17: "17.6.1.031"
postgres15: "15.14.1.031"
postgresorioledb-17: "17.5.1.053-orioledb"
postgres17: "17.6.1.032"
postgres15: "15.14.1.032"

# Non Postgres Extensions
pgbouncer_release: 1.19.0
Expand Down
106 changes: 86 additions & 20 deletions nix/ext/pg_hashids.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,99 @@
stdenv,
fetchFromGitHub,
postgresql,
buildEnv,
}:

stdenv.mkDerivation rec {
let
pname = "pg_hashids";
version = "cd0e1b31d52b394a0df64079406a14a4f7387cd6";
build =
version: hash: revision:
stdenv.mkDerivation rec {
inherit pname version;

buildInputs = [ postgresql ];
buildInputs = [ postgresql ];

src = fetchFromGitHub {
owner = "iCyberon";
repo = pname;
rev = "${version}";
hash = "sha256-Nmb7XLqQflYZfqj0yrewfb1Hl5YgEB5wfjBunPwIuOU=";
};
src = fetchFromGitHub {
owner = "iCyberon";
repo = pname;
rev = revision;
inherit hash;
};

installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

mv ${pname}${postgresql.dlSuffix} $out/lib/${pname}-${version}${postgresql.dlSuffix}

create_sql_files() {
if test -f ${pname}--${version}.sql; then
cp ${pname}--${version}.sql $out/share/postgresql/extension
fi
echo "Creating SQL files for previous versions..."
if [[ "${version}" == "${latestVersion}" ]]; then
cp *.sql $out/share/postgresql/extension

# anything after 1.2.1 is unreleased
cp pg_hashids--1.3.sql $out/share/postgresql/extension/pg_hashids--${version}.sql
cp pg_hashids--1.2.1--1.3.sql $out/share/postgresql/extension/pg_hashids--1.2.1--${version}.sql
fi
}

create_control_files() {
sed -e "/^default_version =/d" \
-e "s|^module_pathname = .*|module_pathname = '\$libdir/${pname}'|" \
${pname}.control > $out/share/postgresql/extension/${pname}--${version}.control

if [[ "${version}" == "${latestVersion}" ]]; then
{
echo "default_version = '${latestVersion}'"
cat $out/share/postgresql/extension/${pname}--${latestVersion}.control
} > $out/share/postgresql/extension/${pname}.control
ln -sfn ${pname}-${latestVersion}${postgresql.dlSuffix} $out/lib/${pname}${postgresql.dlSuffix}
fi
}

installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}
create_sql_files
create_control_files
'';

cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
meta = with lib; {
description = "Generate short unique IDs in PostgreSQL";
homepage = "https://github.com/iCyberon/pg_hashids";
license = licenses.postgresql;
inherit (postgresql.meta) platforms;
};
};
allVersions = (builtins.fromJSON (builtins.readFile ./versions.json)).pg_hashids;
supportedVersions = lib.filterAttrs (
_: value: builtins.elem (lib.versions.major postgresql.version) value.postgresql
) allVersions;
versions = lib.naturalSort (lib.attrNames supportedVersions);
latestVersion = lib.last versions;
numberOfVersions = builtins.length versions;
packages = builtins.attrValues (
lib.mapAttrs (name: value: build name value.hash (value.revision or name)) supportedVersions
);
in
buildEnv {
name = pname;
paths = packages;
pathsToLink = [
"/lib"
"/share/postgresql/extension"
];
postBuild = ''
# checks
(set -x
test "$(ls -A $out/lib/${pname}*${postgresql.dlSuffix} | wc -l)" = "${
toString (numberOfVersions + 1)
}"
)
'';

meta = with lib; {
description = "Generate short unique IDs in PostgreSQL";
homepage = "https://github.com/iCyberon/pg_hashids";
platforms = postgresql.meta.platforms;
license = licenses.postgresql;
passthru = {
inherit versions numberOfVersions;
pname = "${pname}-all";
version =
"multi-" + lib.concatStringsSep "-" (map (v: lib.replaceStrings [ "." ] [ "-" ] v) versions);
};
}
1 change: 1 addition & 0 deletions nix/ext/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ builtins.listToAttrs (
"hypopg"
"index_advisor"
"pg_cron"
"pg_hashids"
"pg_graphql"
"pg_jsonschema"
"pg_net"
Expand Down
18 changes: 18 additions & 0 deletions nix/ext/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,23 @@
],
"hash": "sha256-wfjiLkx+S3zVrAynisX1GdazueVJ3EOwQEPcgUQt7eA="
}
},
"pg_hashids": {
"1.2.1": {
"postgresql": [
"15",
"17"
],
"revision": "v1.2.1",
"hash": "sha256-2yQ0JrhwZF9dGEIydOviDpQ+3ZhJ8T16dQt6KIirAJ0="
},
"1.3.0-cd0e1b31d52b394a0df64079406a14a4f7387cd6": {
"postgresql": [
"15",
"17"
],
"revision": "cd0e1b31d52b394a0df64079406a14a4f7387cd6",
"hash": "sha256-Nmb7XLqQflYZfqj0yrewfb1Hl5YgEB5wfjBunPwIuOU="
}
}
}