24
24
pgsqlSuperuser = "supabase_admin" ;
25
25
nix2img = nix2container . packages . ${ system } . nix2container ;
26
26
27
- # The 'oriole_pkgs' variable holds all the upstream packages in nixpkgs, which
28
- # we can use to build our own images; it is the common name to refer to
29
- # a copy of nixpkgs which contains all its packages.
30
- # it also serves as a base for importing the orioldb/postgres overlay to
31
- #build the orioledb postgres patched version of postgresql16
32
- oriole_pkgs = import nixpkgs {
33
- config = { allowUnfree = true ; } ;
34
- inherit system ;
35
- overlays = [
36
- # NOTE (aseipp): add any needed overlays here. in theory we could
37
- # pull them from the overlays/ directory automatically, but we don't
38
- # want to have an arbitrary order, since it might matter. being
39
- # explicit is better.
40
- ( import ./nix/overlays/cargo-pgrx-0-11-3.nix )
41
- ( import ./nix/overlays/psql_16-oriole.nix )
42
-
43
- ] ;
44
- } ;
45
- #This variable works the same as 'oriole_pkgs' but builds using the upstream
46
- #nixpkgs builds of postgresql 15 and 16 + the overlays listed below
47
27
pkgs = import nixpkgs {
48
28
config = {
49
29
allowUnfree = true ;
59
39
# explicit is better.
60
40
( final : prev : {
61
41
postgresql = final . callPackage ./nix/postgresql/default.nix {
62
- inherit ( final ) lib ;
63
- inherit ( final ) stdenv ;
64
- inherit ( final ) fetchurl ;
65
- inherit ( final ) makeWrapper ;
66
- inherit ( final ) callPackage ;
42
+ inherit ( final ) lib stdenv fetchurl makeWrapper callPackage buildEnv newScope ;
67
43
} ;
68
44
} )
69
45
( import ./nix/overlays/cargo-pgrx-0-11-3.nix )
141
117
x != ./nix/ext/pgvector.nix &&
142
118
x != ./nix/ext/plv8.nix &&
143
119
x != ./nix/ext/postgis.nix &&
144
- x != ./nix/ext/pgrouting.nix &&
145
- x != ./nix/ext/pg_net.nix
120
+ x != ./nix/ext/pgrouting.nix
146
121
) ourExtensions ;
147
122
148
- orioledbExtension = orioleFilteredExtensions ++ [ ./nix/ext/orioledb.nix ] ;
123
+ orioledbExtensions = orioleFilteredExtensions ++ [ ./nix/ext/orioledb.nix ] ;
149
124
150
- #this var is a convenience setting to import the orioledb patched version of postgresql
151
- postgresql_orioledb_16 = oriole_pkgs . postgresql_orioledb ;
152
- #postgis_override = pkgs.postgis_override;
153
125
getPostgresqlPackage = version :
154
- pkgs . postgresql . "postgresql_${ version } " ;
126
+ if version == "orioledb_16"
127
+ then pkgs . postgresql . "postgresql_orioledb-16"
128
+ else pkgs . postgresql . "postgresql_${ version } " ;
155
129
# Create a 'receipt' file for a given postgresql package. This is a way
156
130
# of adding a bit of metadata to the package, which can be used by other
157
131
# tools to inspect what the contents of the install are: the PSQL
180
154
} ;
181
155
extensions = ourExts ;
182
156
183
- # NOTE (aseipp): this field can be used to do cache busting (e.g.
157
+ # NOTE this field can be used to do cache busting (e.g.
184
158
# force a rebuild of the psql packages) but also to helpfully inform
185
159
# tools what version of the schema is being used, for forwards and
186
160
# backwards compatibility
187
161
receipt-version = "1" ;
188
162
} ;
189
163
} ;
190
164
191
- makeOurOrioleDbPostgresPkgs = version : patchedPostgres :
192
- let postgresql = patchedPostgres ;
193
- in map ( path : pkgs . callPackage path { inherit postgresql ; } ) orioledbExtension ;
165
+ # makeOurOrioleDbPostgresPkgs = version: patchedPostgres:
166
+ # let postgresql = patchedPostgres;
167
+ # in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension;
194
168
195
169
makeOurPostgresPkgs = version :
196
- let postgresql = getPostgresqlPackage version ;
197
- in map ( path : pkgs . callPackage path { inherit postgresql ; } ) ourExtensions ;
170
+ let
171
+ postgresql = getPostgresqlPackage version ;
172
+ extensionsToUse = if version == "orioledb-16"
173
+ then orioledbExtensions
174
+ else ourExtensions ;
175
+ in map ( path : pkgs . callPackage path { inherit postgresql ; } ) extensionsToUse ;
198
176
199
- # Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension.
200
- makeOurOrioleDbPostgresPkgsSet = version : patchedPostgres :
201
- ( builtins . listToAttrs ( map
202
- ( drv :
203
- { name = drv . pname ; value = drv ; }
204
- )
205
- ( makeOurOrioleDbPostgresPkgs version patchedPostgres ) ) )
206
- // { recurseForDerivations = true ; } ;
207
177
208
178
# Create an attrset that contains all the extensions included in a server.
209
179
makeOurPostgresPkgsSet = version :
243
213
paths = [ pgbin ( makeReceipt pgbin upstreamExts ourExts ) ] ;
244
214
} ;
245
215
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
- scope = {
277
- inherit ( patchedPostgres ) jitSupport ;
278
- inherit ( oriole_pkgs . llvmPackages ) llvm ;
279
- postgresql = patchedPostgres ;
280
- inherit ( postgresql ) stdenv' ;
281
- } ;
282
- newSelf = self // scope ;
283
- newSuper = { callPackage = oriole_pkgs . newScope ( scope // postgresql . pkgs ) ; } ;
284
-
285
- selectedPackages =
286
- ( map ( ext : postgresql . pkgs . "${ ext } " ) orioledbPsqlExtensions ) ++
287
- ( makeOurOrioleDbPostgresPkgs version postgresql ) ;
288
-
289
- pgbin = oriole_pkgs . buildEnv {
290
- name = "postgresql-and-plugins-${ postgresql . version } " ;
291
- paths = [ postgresql ] ++ selectedPackages ;
292
- buildInputs = [ oriole_pkgs . makeWrapper ] ;
293
- passthru = postgresql . passthru // {
294
- inherit postgresql ;
295
- args = selectedPackages ;
296
- } ;
297
-
298
- postBuild = ''
299
- # Ensure all necessary directories exist
300
- mkdir -p $out/bin
301
- mkdir -p $out/lib/postgresql
302
- mkdir -p $out/share/postgresql/extension
303
-
304
- # Create proper links for all binaries with environment
305
- for bin in ${ postgresql } /bin/*; do
306
- binary_name=$(basename $bin)
307
- rm -f "$out/bin/$binary_name"
308
- makeWrapper $bin $out/bin/$binary_name \
309
- --set POSTGRES_MAJOR_VERSION "${ postgresql . psqlSchema } " \
310
- --prefix PATH : $out/bin \
311
- --prefix LD_LIBRARY_PATH : "$out/lib:$out/lib/postgresql" \
312
- --prefix PKG_CONFIG_PATH : "$out/lib/pkgconfig" \
313
- --set PGDATA "/var/lib/postgresql/${ postgresql . psqlSchema } " \
314
- --set PGHOST "/run/postgresql"
315
- done
316
-
317
- # Ensure extension files are properly linked
318
- for pkg in ${ postgresql } ${ toString selectedPackages } ; do
319
- # Link shared objects
320
- if [ -d "$pkg/lib" ]; then
321
- find "$pkg/lib" -type f -name '*.so' -exec ln -sf {} "$out/lib/postgresql/" \;
322
- fi
323
-
324
- # Link extension control and SQL files
325
- if [ -d "$pkg/share/postgresql/extension" ]; then
326
- find "$pkg/share/postgresql/extension" -type f \( -name '*.control' -o -name '*.sql' \) \
327
- -exec ln -sf {} "$out/share/postgresql/extension/" \;
328
- fi
329
- done
330
-
331
- # Create pg_config if it doesn't exist
332
- if [ ! -e "$out/bin/pg_config" ]; then
333
- makeWrapper ${ postgresql } /bin/pg_config $out/bin/pg_config \
334
- --set prefix "$out" \
335
- --set includedir "$out/include" \
336
- --set pkgincludedir "$out/include/postgresql" \
337
- --set includedir-server "$out/include/postgresql/server" \
338
- --set libdir "$out/lib" \
339
- --set pkglibdir "$out/lib/postgresql" \
340
- --set localedir "$out/share/locale" \
341
- --set mandir "$out/share/man" \
342
- --set sharedir "$out/share/postgresql" \
343
- --set sysconfdir "/etc/postgresql" \
344
- --set pgxs "$out/lib/postgresql/pgxs/src/makefiles/pgxs.mk" \
345
- --set configure "--enable-nls --with-openssl --with-libxml --with-libxslt"
346
- fi
347
- '' ;
348
- } // {
349
- version = postgresql . version ;
350
- } ;
351
- in
352
- pkgs . symlinkJoin {
353
- inherit ( pgbin ) name version ;
354
- paths = [ pgbin ( makeReceipt pgbin upstreamExts ourExts ) ] ;
355
- } ;
356
-
357
216
# Create an attribute set, containing all the relevant packages for a
358
217
# PostgreSQL install, wrapped up with a bow on top. There are three
359
218
# packages:
@@ -368,11 +227,6 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
368
227
exts = makeOurPostgresPkgsSet version ;
369
228
recurseForDerivations = true ;
370
229
} ;
371
- makeOrioleDbPostgres = version : patchedPostgres : rec {
372
- bin = makeOrioleDbPostgresBin version patchedPostgres ;
373
- exts = makeOurOrioleDbPostgresPkgsSet version patchedPostgres ;
374
- recurseForDerivations = true ;
375
- } ;
376
230
377
231
# The base set of packages that we export from this Nix Flake, that can
378
232
# be used with 'nix build'. Don't use the names listed below; check the
@@ -390,7 +244,7 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
390
244
postgresVersions = {
391
245
psql_15 = makePostgres "15" ;
392
246
psql_16 = makePostgres "16" ;
393
- psql_oriole -16 = makeOrioleDbPostgres " 16" postgresql_orioledb_16 ;
247
+ psql_orioledb -16 = makePostgres "orioledb- 16" ;
394
248
} ;
395
249
396
250
# Find the active PostgreSQL version
@@ -406,20 +260,20 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
406
260
} ;
407
261
postgresql_15 = getPostgresqlPackage "15" ;
408
262
postgresql_16 = getPostgresqlPackage "16" ;
409
- postgresql_oriole -16 = postgresql_orioledb_16 ;
263
+ postgresql_orioledb -16 = getPostgresqlPackage "orioledb-16" ;
410
264
in
411
265
postgresVersions // {
412
266
supabase-groonga = supabase-groonga ;
413
267
# PostgreSQL versions.
414
268
psql_15 = postgresVersions . psql_15 ;
415
269
psql_16 = postgresVersions . psql_16 ;
416
- psql_oriole -16 = postgresVersions . psql_oriole -16;
270
+ psql_orioledb -16 = postgresVersions . psql_orioledb -16;
417
271
sfcgal = sfcgal ;
418
272
pg_prove = pkgs . perlPackages . TAPParserSourceHandlerpgTAP ;
419
- inherit postgresql_15 postgresql_16 postgresql_oriole -16;
273
+ inherit postgresql_15 postgresql_16 postgresql_orioledb -16;
420
274
postgresql_15_debug = if pkgs . stdenv . isLinux then postgresql_15 . debug else null ;
421
275
postgresql_16_debug = if pkgs . stdenv . isLinux then postgresql_16 . debug else null ;
422
- postgresql_oriole -16_debug = if pkgs . stdenv . isLinux then postgresql_orioledb_16 . debug else null ;
276
+ postgresql_orioledb -16_debug = if pkgs . stdenv . isLinux then postgresql_orioledb-16 . debug else null ;
423
277
postgresql_15_src = pkgs . stdenv . mkDerivation {
424
278
pname = "postgresql-15-src" ;
425
279
version = postgresql_15 . version ;
@@ -464,9 +318,9 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
464
318
platforms = platforms . all ;
465
319
} ;
466
320
} ;
467
- postgresql_oriole -16_src = pkgs . stdenv . mkDerivation {
321
+ postgresql_orioledb -16_src = pkgs . stdenv . mkDerivation {
468
322
pname = "postgresql-16-src" ;
469
- version = postgresql_oriole -16. version ;
323
+ version = postgresql_orioledb -16. version ;
470
324
471
325
src = postgresql_16 . src ;
472
326
@@ -545,7 +399,7 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
545
399
--subst-var-by 'PSQL15_BINDIR' '${ basePackages . psql_15 . bin } ' \
546
400
--subst-var-by 'PSQL_CONF_FILE' $out/etc/postgresql/postgresql.conf \
547
401
--subst-var-by 'PSQL16_BINDIR' '${ basePackages . psql_16 . bin } ' \
548
- --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${ basePackages . psql_oriole -16. bin } ' \
402
+ --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${ basePackages . psql_orioledb -16. bin } ' \
549
403
--subst-var-by 'PGSODIUM_GETKEY' '${ getkeyScript } ' \
550
404
--subst-var-by 'READREPL_CONF_FILE' "$out/etc/postgresql-custom/read-replica.conf" \
551
405
--subst-var-by 'LOGGING_CONF_FILE' "$out/etc/postgresql-custom/logging.conf" \
@@ -575,7 +429,7 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
575
429
--subst-var-by 'PGSQL_SUPERUSER' '${ pgsqlSuperuser } ' \
576
430
--subst-var-by 'PSQL15_BINDIR' '${ basePackages . psql_15 . bin } ' \
577
431
--subst-var-by 'PSQL16_BINDIR' '${ basePackages . psql_16 . bin } ' \
578
- --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${ basePackages . psql_oriole -16. bin } ' \
432
+ --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${ basePackages . psql_orioledb -16. bin } ' \
579
433
--subst-var-by 'MIGRATIONS_DIR' '${ migrationsDir } ' \
580
434
--subst-var-by 'POSTGRESQL_SCHEMA_SQL' '${ postgresqlSchemaSql } ' \
581
435
--subst-var-by 'PGBOUNCER_AUTH_SCHEMA_SQL' '${ pgbouncerAuthSchemaSql } ' \
0 commit comments