Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bringing postgres package into our package set #1195

Merged
merged 2 commits into from
Sep 13, 2024
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
30 changes: 24 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,37 @@
#This variable works the same as 'oriole_pkgs' but builds using the upstream
#nixpkgs builds of postgresql 15 and 16 + the overlays listed below
pkgs = import nixpkgs {
config = { allowUnfree = true; };
config = {
allowUnfree = true;
permittedInsecurePackages = [
"v8-9.7.106.18"
];
};
inherit system;
overlays = [
# NOTE (aseipp): add any needed overlays here. in theory we could
# pull them from the overlays/ directory automatically, but we don't
# want to have an arbitrary order, since it might matter. being
# explicit is better.
(final: prev: {
postgresql = final.callPackage ./nix/postgresql/default.nix {
inherit (final) lib;
inherit (final) stdenv;
inherit (final) fetchurl;
inherit (final) makeWrapper;
inherit (final) callPackage;
};
})
(import ./nix/overlays/cargo-pgrx-0-11-3.nix)
# (import ./nix/overlays/postgis.nix)
#(import ./nix/overlays/gdal-small.nix)

];
};

postgresql_15 = pkgs.postgresql.postgresql_15;
postgresql = pkgs.postgresql.postgresql_15;
sfcgal = pkgs.callPackage ./nix/ext/sfcgal/sfcgal.nix { };
pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { };
pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { inherit postgresql; };

# Our list of PostgreSQL extensions which come from upstream Nixpkgs.
# These are maintained upstream and can easily be used here just by
Expand Down Expand Up @@ -128,7 +143,10 @@
#this var is a convenience setting to import the orioledb patched version of postgresql
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
#postgis_override = pkgs.postgis_override;

getPostgresqlPackage = version:
pkgs.postgresql."postgresql_${version}";
#we will add supported versions to this list in the future
supportedVersions = [ "15" ];
# Create a 'receipt' file for a given postgresql package. This is a way
# of adding a bit of metadata to the package, which can be used by other
# tools to inspect what the contents of the install are: the PSQL
Expand Down Expand Up @@ -170,7 +188,7 @@
in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension;

makeOurPostgresPkgs = version:
let postgresql = pkgs."postgresql_${version}";
let postgresql = getPostgresqlPackage version;
in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions;

# Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension.
Expand Down Expand Up @@ -202,7 +220,7 @@
# basis for building extensions, etc.
makePostgresBin = version:
let
postgresql = pkgs."postgresql_${version}";
postgresql = getPostgresqlPackage version;
upstreamExts = map
(ext: {
name = postgresql.pkgs."${ext}".pname;
Expand Down
2 changes: 2 additions & 0 deletions nix/ext/pg_graphql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ buildPgrxExtension_0_11_3 rec {
buildInputs = [ postgresql ];

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

Expand Down
2 changes: 2 additions & 0 deletions nix/ext/pg_jsonschema.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ buildPgrxExtension_0_11_3 rec {

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

Expand Down
4 changes: 4 additions & 0 deletions nix/postgresql/15.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ./generic.nix {
version = "15.6";
hash = "sha256-hFUUbtnGnJOlfelUrq0DAsr60DXCskIXXWqh4X68svs=";
}
20 changes: 20 additions & 0 deletions nix/postgresql/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
self:
let
#adapted from the postgresql nixpkgs package
versions = {
postgresql_15 = ./15.nix;
};

mkAttributes = jitSupport:
self.lib.mapAttrs' (version: path:
let
attrName = if jitSupport then "${version}_jit" else version;
in
self.lib.nameValuePair attrName (import path {
inherit jitSupport self;
})
) versions;

in
# variations without and with JIT
(mkAttributes false) // (mkAttributes true)
Loading
Loading