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

postgresql: reorganize package and its extensions #54319

Merged
merged 5 commits into from
Jan 26, 2019
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
4 changes: 2 additions & 2 deletions nixos/tests/postgresql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with import ../lib/testing.nix { inherit system pkgs; };
with pkgs.lib;

let
postgresql-versions = pkgs.callPackages ../../pkgs/servers/sql/postgresql { };
postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs pkgs;
test-sql = pkgs.writeText "postgresql-test" ''
CREATE EXTENSION pgcrypto; -- just to check if lib loading works
CREATE TABLE sth (
Expand All @@ -29,8 +29,8 @@ let

machine = {...}:
{
services.postgresql.package = postgresql-package;
services.postgresql.enable = true;
services.postgresql.package = postgresql-package;

services.postgresqlBackup.enable = true;
services.postgresqlBackup.databases = optional (!backup-all) "postgres";
Expand Down
84 changes: 68 additions & 16 deletions pkgs/servers/sql/postgresql/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper, tzdata, systemd, icu, pkgconfig }:

let

common = { version, sha256, psqlSchema }:
generic =
# dependencies
{ stdenv, lib, fetchurl, makeWrapper
, glibc, zlib, readline, openssl, icu, systemd, libossp_uuid
, pkgconfig, libxml2, tzdata

# for postgreql.pkgs
, this, self, newScope, buildEnv

# source specification
, version, sha256, psqlSchema
}:
let
atLeast = lib.versionAtLeast version;

# Build with ICU by default on versions that support it
icuEnabled = atLeast "10";
in stdenv.mkDerivation (rec {

in stdenv.mkDerivation rec {
name = "postgresql-${version}";
inherit version;

Expand Down Expand Up @@ -97,50 +105,94 @@ let
disallowedReferences = [ stdenv.cc ];

passthru = {
inherit readline psqlSchema;
inherit readline psqlSchema version;

pkgs = let
scope = { postgresql = this; };
newSelf = self // scope;
newSuper = { callPackage = newScope (scope // this.pkgs); };
in import ./packages.nix newSelf newSuper;

withPackages = postgresqlWithPackages {
inherit makeWrapper buildEnv;
postgresql = this;
}
this.pkgs;
};

meta = with lib; {
homepage = https://www.postgresql.org;
description = "A powerful, open source object-relational database system";
license = licenses.postgresql;
maintainers = with maintainers; [ ocharles thoughtpolice ];
maintainers = with maintainers; [ ocharles thoughtpolice danbst ];
platforms = platforms.unix;
knownVulnerabilities = optional (!atLeast "9.4")
"PostgreSQL versions older than 9.4 are not maintained anymore!";
};
});
};

postgresqlWithPackages = { postgresql, makeWrapper, buildEnv }: pkgs: f: buildEnv {
name = "postgresql-and-plugins-${postgresql.version}";
paths = f pkgs ++ [
postgresql
postgresql.lib
postgresql.man # in case user installs this into environment
];
buildInputs = [ makeWrapper ];

# We include /bin to ensure the $out/bin directory is created, which is
# needed because we'll be removing the files from that directory in postBuild
# below. See #22653
pathsToLink = ["/" "/bin"];

postBuild = ''
mkdir -p $out/bin
rm $out/bin/{pg_config,postgres,pg_ctl}
cp --target-directory=$out/bin ${postgresql}/bin/{postgres,pg_config,pg_ctl}
wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib
'';
};

in {
in self: super: {

postgresql_9_4 = common {
postgresql_9_4 = super.callPackage generic {
version = "9.4.20";
psqlSchema = "9.4";
sha256 = "0zzqjz5jrn624hzh04drpj6axh30a9k6bgawid6rwk45nbfxicgf";
this = self.postgresql_9_4;
inherit self;
};

postgresql_9_5 = common {
postgresql_9_5 = super.callPackage generic {
version = "9.5.15";
psqlSchema = "9.5";
sha256 = "0i2lylgmsmy2g1ixlvl112fryp7jmrd0i2brk8sxb7vzzpg3znnv";
this = self.postgresql_9_5;
inherit self;
};

postgresql_9_6 = common {
postgresql_9_6 = super.callPackage generic {
version = "9.6.11";
psqlSchema = "9.6";
sha256 = "0c55akrkzqd6p6a8hr0338wk246hl76r9j16p4zn3s51d7f0l99q";
this = self.postgresql_9_6;
inherit self;
};

postgresql_10 = common {
postgresql_10 = super.callPackage generic {
version = "10.6";
psqlSchema = "10.0";
sha256 = "0jv26y3f10svrjxzsgqxg956c86b664azyk2wppzpa5x11pjga38";
this = self.postgresql_10;
inherit self;
};

postgresql_11 = common {
postgresql_11 = super.callPackage generic {
version = "11.1";
psqlSchema = "11.1";
sha256 = "026v0sicsh7avzi45waf8shcbhivyxmi7qgn9fd1x0vl520mx0ch";
this = self.postgresql_11;
inherit self;
};

}
}
30 changes: 30 additions & 0 deletions pkgs/servers/sql/postgresql/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
self: super: {

pg_repack = super.callPackage ./ext/pg_repack.nix { };

pg_similarity = super.callPackage ./ext/pg_similarity.nix { };

pgroonga = super.callPackage ./ext/pgroonga.nix { };

plv8 = super.callPackage ./ext/plv8.nix {
v8 = super.callPackage ../../../development/libraries/v8/plv8_6_x.nix {
python = self.python2;
};
};

pgjwt = super.callPackage ./ext/pgjwt.nix { };

cstore_fdw = super.callPackage ./ext/cstore_fdw.nix { };

pg_hll = super.callPackage ./ext/pg_hll.nix { };

pg_cron = super.callPackage ./ext/pg_cron.nix { };

pg_topn = super.callPackage ./ext/pg_topn.nix { };

pgtap = super.callPackage ./ext/pgtap.nix { };

timescaledb = super.callPackage ./ext/timescaledb.nix { };

tsearch_extras = super.callPackage ./ext/tsearch_extras.nix { };
}
14 changes: 14 additions & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ mapAliases ({
postgresql95 = postgresql_9_5;
postgresql96 = postgresql_9_6;
postgresql100 = throw "deprecated 2018-10-21: use postgresql_10 instead";
# postgresql plugins
pgjwt = postgresqlPackages.pgjwt;
pg_repack = postgresqlPackages.pg_repack;
pgroonga = postgresqlPackages.pgroonga;
pg_similarity = postgresqlPackages.pg_similarity;
pgtap = postgresqlPackages.pgtap;
plv8 = postgresqlPackages.plv8;
timescaledb = postgresqlPackages.timescaledb;
tsearch_extras = postgresqlPackages.tsearch_extras;
cstore_fdw = postgresqlPackages.cstore_fdw;
pg_hll = postgresqlPackages.pg_hll;
pg_cron = postgresqlPackages.pg_cron;
pg_topn = postgresqlPackages.pg_topn;
# end
procps-ng = procps; # added 2018-06-08
prometheus-statsd-bridge = prometheus-statsd-exporter; # added 2017-08-27
pulseaudioLight = pulseaudio; # added 2018-04-25
Expand Down
9 changes: 5 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13949,14 +13949,15 @@ in

timescaledb-parallel-copy = callPackage ../development/tools/database/timescaledb-parallel-copy { };

postgresql = postgresql_9_6;

inherit (callPackages ../servers/sql/postgresql { })
inherit (import ../servers/sql/postgresql pkgs super)
postgresql_9_4
postgresql_9_5
postgresql_9_6
postgresql_10
postgresql_11;
postgresql_11
;
postgresql = postgresql_9_6.override { this = postgresql; };
postgresqlPackages = recurseIntoAttrs postgresql.pkgs;

postgresql_jdbc = callPackage ../development/java-modules/postgresql_jdbc { };

Expand Down