Skip to content

Commit 6a5648b

Browse files
committed
wip for orioledb push to build on linux
1 parent e1c199c commit 6a5648b

File tree

2 files changed

+83
-27
lines changed

2 files changed

+83
-27
lines changed

flake.nix

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
./nix/ext/pg_cron.nix
117117
./nix/ext/pgsql-http.nix
118118
./nix/ext/pg_plan_filter.nix
119-
./nix/ext/pg_net.nix
119+
#./nix/ext/pg_net.nix
120120
./nix/ext/pg_hashids.nix
121121
./nix/ext/pgsodium.nix
122122
./nix/ext/pg_graphql.nix
@@ -141,13 +141,14 @@
141141
x != ./nix/ext/pgvector.nix &&
142142
x != ./nix/ext/plv8.nix &&
143143
x != ./nix/ext/postgis.nix &&
144-
x != ./nix/ext/pgrouting.nix
144+
x != ./nix/ext/pgrouting.nix &&
145+
x != ./nix/ext/pg_net.nix
145146
) ourExtensions;
146147

147148
orioledbExtension = orioleFilteredExtensions ++ [ ./nix/ext/orioledb.nix ];
148149

149150
#this var is a convenience setting to import the orioledb patched version of postgresql
150-
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
151+
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb;
151152
#postgis_override = pkgs.postgis_override;
152153
getPostgresqlPackage = version:
153154
pkgs.postgresql."postgresql_${version}";
@@ -242,26 +243,81 @@
242243
paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ];
243244
};
244245

245-
makeOrioleDbPostgresBin = version: patchedPostgres:
246-
let
247-
postgresql = patchedPostgres;
248-
upstreamExts = map
249-
(ext: {
250-
name = postgresql.pkgs."${ext}".pname;
251-
version = postgresql.pkgs."${ext}".version;
252-
})
253-
orioledbPsqlExtensions;
254-
ourExts = map (ext: { name = ext.pname; version = ext.version; }) (makeOurOrioleDbPostgresPkgs version postgresql);
255-
256-
pgbin = postgresql.withPackages (ps:
257-
(map (ext: ps."${ext}") orioledbPsqlExtensions) ++ (makeOurOrioleDbPostgresPkgs version postgresql)
258-
);
259-
in
260-
pkgs.symlinkJoin {
261-
inherit (pgbin) name version;
262-
paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ];
263-
};
264-
246+
# makeOrioleDbPostgresBin = version: patchedPostgres:
247+
# let
248+
# postgresql = patchedPostgres;
249+
# upstreamExts = map
250+
# (ext: {
251+
# name = postgresql.pkgs."${ext}".pname;
252+
# version = postgresql.pkgs."${ext}".version;
253+
# })
254+
# orioledbPsqlExtensions;
255+
# ourExts = map (ext: { name = ext.pname; version = ext.version; }) (makeOurOrioleDbPostgresPkgs version postgresql);
256+
257+
# pgbin = postgresql.withPackages (ps:
258+
# (map (ext: ps."${ext}") orioledbPsqlExtensions) ++ (makeOurOrioleDbPostgresPkgs version postgresql)
259+
# );
260+
# in
261+
# pkgs.symlinkJoin {
262+
# inherit (pgbin) name version;
263+
# paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ];
264+
# };
265+
makeOrioleDbPostgresBin = version: patchedPostgres:
266+
let
267+
postgresql = patchedPostgres;
268+
upstreamExts = map
269+
(ext: {
270+
name = patchedPostgres.pkgs."${ext}".pname;
271+
version = patchedPostgres.pkgs."${ext}".version;
272+
})
273+
orioledbPsqlExtensions;
274+
ourExts = map (ext: { name = ext.pname; version = ext.version; }) (makeOurOrioleDbPostgresPkgs version patchedPostgres);
275+
276+
# Create the scope and new self/super for package resolution
277+
scope = {
278+
inherit (patchedPostgres) jitSupport;
279+
inherit (oriole_pkgs.llvmPackages) llvm;
280+
postgresql = patchedPostgres;
281+
inherit (postgresql) stdenv';
282+
};
283+
newSelf = self // scope;
284+
newSuper = { callPackage = oriole_pkgs.newScope (scope // postgresql.pkgs); };
285+
286+
# Get the packages using the passthru pattern
287+
selectedPackages =
288+
(map (ext: postgresql.pkgs."${ext}") orioledbPsqlExtensions) ++
289+
(makeOurOrioleDbPostgresPkgs version postgresql);
290+
291+
# Build the environment with the selected packages
292+
pgbin = oriole_pkgs.buildEnv {
293+
name = "postgresql-and-plugins-${postgresql.version}";
294+
paths = [ postgresql ] ++ selectedPackages;
295+
buildInputs = [ oriole_pkgs.makeWrapper ];
296+
passthru = postgresql.passthru // {
297+
inherit postgresql;
298+
args = selectedPackages;
299+
};
300+
301+
postBuild = ''
302+
mkdir -p $out/bin
303+
for bin in ${postgresql}/bin/*; do
304+
ln -sf $bin $out/bin/
305+
done
306+
307+
rm -f $out/bin/postgres
308+
makeWrapper ${postgresql}/bin/postgres $out/bin/postgres \
309+
--set POSTGRES_MAJOR_VERSION "${postgresql.psqlSchema}" \
310+
--prefix PATH : $out/bin \
311+
--prefix LD_LIBRARY_PATH : $out/lib
312+
'';
313+
}// {
314+
version = postgresql.version;
315+
};
316+
in
317+
pkgs.symlinkJoin {
318+
inherit (pgbin) name version;
319+
paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ];
320+
};
265321

266322
# Create an attribute set, containing all the relevant packages for a
267323
# PostgreSQL install, wrapped up with a bow on top. There are three
@@ -299,7 +355,7 @@
299355
postgresVersions = {
300356
psql_15 = makePostgres "15";
301357
psql_16 = makePostgres "16";
302-
psql_oriole-16 = makeOrioleDbPostgres "16_31" postgresql_orioledb_16;
358+
psql_oriole-16 = makeOrioleDbPostgres "16" postgresql_orioledb_16;
303359
};
304360

305361
# Find the active PostgreSQL version

nix/overlays/psql_16-oriole.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
final: prev: {
2-
postgresql_16 = prev.postgresql_16.overrideAttrs (old: {
3-
pname = "postgresql_16";
2+
pg_orioledb = prev.postgresql_16.overrideAttrs (old: {
3+
pname = "postgresql_orioledb";
44
version = "16_31";
55
src = prev.fetchurl {
66
url = "https://github.com/orioledb/postgres/archive/refs/tags/patches16_31.tar.gz";
@@ -17,5 +17,5 @@ final: prev: {
1717
prev.perl
1818
];
1919
});
20-
postgresql_orioledb_16 = final.postgresql_16;
20+
postgresql_orioledb = final.pg_orioledb;
2121
}

0 commit comments

Comments
 (0)