Skip to content

Commit d8e6308

Browse files
authored
feat: bringing postgres package into our package set (#1195)
* feat: bringing postgres package into our package set * chore: on macos we need to set specific ports for the build --------- Co-authored-by: Sam Rose <[email protected]>
1 parent 22f0ce3 commit d8e6308

16 files changed

+511
-11
lines changed

flake.nix

+24-6
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,37 @@
4646
#This variable works the same as 'oriole_pkgs' but builds using the upstream
4747
#nixpkgs builds of postgresql 15 and 16 + the overlays listed below
4848
pkgs = import nixpkgs {
49-
config = { allowUnfree = true; };
49+
config = {
50+
allowUnfree = true;
51+
permittedInsecurePackages = [
52+
"v8-9.7.106.18"
53+
];
54+
};
5055
inherit system;
5156
overlays = [
5257
# NOTE (aseipp): add any needed overlays here. in theory we could
5358
# pull them from the overlays/ directory automatically, but we don't
5459
# want to have an arbitrary order, since it might matter. being
5560
# explicit is better.
61+
(final: prev: {
62+
postgresql = final.callPackage ./nix/postgresql/default.nix {
63+
inherit (final) lib;
64+
inherit (final) stdenv;
65+
inherit (final) fetchurl;
66+
inherit (final) makeWrapper;
67+
inherit (final) callPackage;
68+
};
69+
})
5670
(import ./nix/overlays/cargo-pgrx-0-11-3.nix)
5771
# (import ./nix/overlays/postgis.nix)
5872
#(import ./nix/overlays/gdal-small.nix)
5973

6074
];
6175
};
62-
76+
postgresql_15 = pkgs.postgresql.postgresql_15;
77+
postgresql = pkgs.postgresql.postgresql_15;
6378
sfcgal = pkgs.callPackage ./nix/ext/sfcgal/sfcgal.nix { };
64-
pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { };
79+
pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { inherit postgresql; };
6580

6681
# Our list of PostgreSQL extensions which come from upstream Nixpkgs.
6782
# These are maintained upstream and can easily be used here just by
@@ -128,7 +143,10 @@
128143
#this var is a convenience setting to import the orioledb patched version of postgresql
129144
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
130145
#postgis_override = pkgs.postgis_override;
131-
146+
getPostgresqlPackage = version:
147+
pkgs.postgresql."postgresql_${version}";
148+
#we will add supported versions to this list in the future
149+
supportedVersions = [ "15" ];
132150
# Create a 'receipt' file for a given postgresql package. This is a way
133151
# of adding a bit of metadata to the package, which can be used by other
134152
# tools to inspect what the contents of the install are: the PSQL
@@ -170,7 +188,7 @@
170188
in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension;
171189

172190
makeOurPostgresPkgs = version:
173-
let postgresql = pkgs."postgresql_${version}";
191+
let postgresql = getPostgresqlPackage version;
174192
in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions;
175193

176194
# Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension.
@@ -202,7 +220,7 @@
202220
# basis for building extensions, etc.
203221
makePostgresBin = version:
204222
let
205-
postgresql = pkgs."postgresql_${version}";
223+
postgresql = getPostgresqlPackage version;
206224
upstreamExts = map
207225
(ext: {
208226
name = postgresql.pkgs."${ext}".pname;

nix/ext/pg_graphql.nix

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ buildPgrxExtension_0_11_3 rec {
1616
buildInputs = [ postgresql ];
1717

1818
CARGO="${cargo}/bin/cargo";
19+
#darwin env needs PGPORT to be unique for build to not clash with other pgrx extensions
1920
env = lib.optionalAttrs stdenv.isDarwin {
2021
POSTGRES_LIB = "${postgresql}/lib";
2122
RUSTFLAGS = "-C link-arg=-undefined -C link-arg=dynamic_lookup";
23+
PGPORT = "5434";
2224
};
2325
cargoHash = "sha256-WkHufMw8OvinMRYd06ZJACnVvY9OLi069nCgq3LSmMY=";
2426

nix/ext/pg_jsonschema.nix

+2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ buildPgrxExtension_0_11_3 rec {
1919

2020
previousVersions = ["0.3.0" "0.2.0" "0.1.4" "0.1.4" "0.1.2" "0.1.1" "0.1.0"];
2121
CARGO="${cargo}/bin/cargo";
22+
#darwin env needs PGPORT to be unique for build to not clash with other pgrx extensions
2223
env = lib.optionalAttrs stdenv.isDarwin {
2324
POSTGRES_LIB = "${postgresql}/lib";
2425
RUSTFLAGS = "-C link-arg=-undefined -C link-arg=dynamic_lookup";
26+
PGPORT = "5433";
2527
};
2628
cargoHash = "sha256-VcS+efMDppofuFW2zNrhhsbC28By3lYekDFquHPta2g=";
2729

nix/postgresql/15.nix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import ./generic.nix {
2+
version = "15.6";
3+
hash = "sha256-hFUUbtnGnJOlfelUrq0DAsr60DXCskIXXWqh4X68svs=";
4+
}

nix/postgresql/default.nix

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
self:
2+
let
3+
#adapted from the postgresql nixpkgs package
4+
versions = {
5+
postgresql_15 = ./15.nix;
6+
};
7+
8+
mkAttributes = jitSupport:
9+
self.lib.mapAttrs' (version: path:
10+
let
11+
attrName = if jitSupport then "${version}_jit" else version;
12+
in
13+
self.lib.nameValuePair attrName (import path {
14+
inherit jitSupport self;
15+
})
16+
) versions;
17+
18+
in
19+
# variations without and with JIT
20+
(mkAttributes false) // (mkAttributes true)

0 commit comments

Comments
 (0)