postgresql: reorganize package and its extensions (#54319)
* postgresql: reorganize package and it's extensions Extracts some useful parts of https://github.com/NixOS/nixpkgs/pull/38698, in particular, it's vision that postgresql plugins should be namespaced.
This commit is contained in:
parent
841a6838ff
commit
8e985dced0
@ -7,7 +7,7 @@ with import ../lib/testing.nix { inherit system pkgs; };
|
|||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
postgresql-versions = pkgs.callPackages ../../pkgs/servers/sql/postgresql { };
|
postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs pkgs;
|
||||||
test-sql = pkgs.writeText "postgresql-test" ''
|
test-sql = pkgs.writeText "postgresql-test" ''
|
||||||
CREATE EXTENSION pgcrypto; -- just to check if lib loading works
|
CREATE EXTENSION pgcrypto; -- just to check if lib loading works
|
||||||
CREATE TABLE sth (
|
CREATE TABLE sth (
|
||||||
@ -29,8 +29,8 @@ let
|
|||||||
|
|
||||||
machine = {...}:
|
machine = {...}:
|
||||||
{
|
{
|
||||||
services.postgresql.package = postgresql-package;
|
|
||||||
services.postgresql.enable = true;
|
services.postgresql.enable = true;
|
||||||
|
services.postgresql.package = postgresql-package;
|
||||||
|
|
||||||
services.postgresqlBackup.enable = true;
|
services.postgresqlBackup.enable = true;
|
||||||
services.postgresqlBackup.databases = optional (!backup-all) "postgres";
|
services.postgresqlBackup.databases = optional (!backup-all) "postgres";
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper, tzdata, systemd, icu, pkgconfig }:
|
|
||||||
|
|
||||||
let
|
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
|
let
|
||||||
atLeast = lib.versionAtLeast version;
|
atLeast = lib.versionAtLeast version;
|
||||||
|
|
||||||
# Build with ICU by default on versions that support it
|
|
||||||
icuEnabled = atLeast "10";
|
icuEnabled = atLeast "10";
|
||||||
in stdenv.mkDerivation (rec {
|
|
||||||
|
in stdenv.mkDerivation rec {
|
||||||
name = "postgresql-${version}";
|
name = "postgresql-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
@ -97,50 +105,94 @@ let
|
|||||||
disallowedReferences = [ stdenv.cc ];
|
disallowedReferences = [ stdenv.cc ];
|
||||||
|
|
||||||
passthru = {
|
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; {
|
meta = with lib; {
|
||||||
homepage = https://www.postgresql.org;
|
homepage = https://www.postgresql.org;
|
||||||
description = "A powerful, open source object-relational database system";
|
description = "A powerful, open source object-relational database system";
|
||||||
license = licenses.postgresql;
|
license = licenses.postgresql;
|
||||||
maintainers = with maintainers; [ ocharles thoughtpolice ];
|
maintainers = with maintainers; [ ocharles thoughtpolice danbst ];
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
knownVulnerabilities = optional (!atLeast "9.4")
|
knownVulnerabilities = optional (!atLeast "9.4")
|
||||||
"PostgreSQL versions older than 9.4 are not maintained anymore!";
|
"PostgreSQL versions older than 9.4 are not maintained anymore!";
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
||||||
in {
|
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 ];
|
||||||
|
|
||||||
postgresql_9_4 = common {
|
# 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 self: super: {
|
||||||
|
|
||||||
|
postgresql_9_4 = super.callPackage generic {
|
||||||
version = "9.4.20";
|
version = "9.4.20";
|
||||||
psqlSchema = "9.4";
|
psqlSchema = "9.4";
|
||||||
sha256 = "0zzqjz5jrn624hzh04drpj6axh30a9k6bgawid6rwk45nbfxicgf";
|
sha256 = "0zzqjz5jrn624hzh04drpj6axh30a9k6bgawid6rwk45nbfxicgf";
|
||||||
|
this = self.postgresql_9_4;
|
||||||
|
inherit self;
|
||||||
};
|
};
|
||||||
|
|
||||||
postgresql_9_5 = common {
|
postgresql_9_5 = super.callPackage generic {
|
||||||
version = "9.5.15";
|
version = "9.5.15";
|
||||||
psqlSchema = "9.5";
|
psqlSchema = "9.5";
|
||||||
sha256 = "0i2lylgmsmy2g1ixlvl112fryp7jmrd0i2brk8sxb7vzzpg3znnv";
|
sha256 = "0i2lylgmsmy2g1ixlvl112fryp7jmrd0i2brk8sxb7vzzpg3znnv";
|
||||||
|
this = self.postgresql_9_5;
|
||||||
|
inherit self;
|
||||||
};
|
};
|
||||||
|
|
||||||
postgresql_9_6 = common {
|
postgresql_9_6 = super.callPackage generic {
|
||||||
version = "9.6.11";
|
version = "9.6.11";
|
||||||
psqlSchema = "9.6";
|
psqlSchema = "9.6";
|
||||||
sha256 = "0c55akrkzqd6p6a8hr0338wk246hl76r9j16p4zn3s51d7f0l99q";
|
sha256 = "0c55akrkzqd6p6a8hr0338wk246hl76r9j16p4zn3s51d7f0l99q";
|
||||||
|
this = self.postgresql_9_6;
|
||||||
|
inherit self;
|
||||||
};
|
};
|
||||||
|
|
||||||
postgresql_10 = common {
|
postgresql_10 = super.callPackage generic {
|
||||||
version = "10.6";
|
version = "10.6";
|
||||||
psqlSchema = "10.0";
|
psqlSchema = "10.0";
|
||||||
sha256 = "0jv26y3f10svrjxzsgqxg956c86b664azyk2wppzpa5x11pjga38";
|
sha256 = "0jv26y3f10svrjxzsgqxg956c86b664azyk2wppzpa5x11pjga38";
|
||||||
|
this = self.postgresql_10;
|
||||||
|
inherit self;
|
||||||
};
|
};
|
||||||
|
|
||||||
postgresql_11 = common {
|
postgresql_11 = super.callPackage generic {
|
||||||
version = "11.1";
|
version = "11.1";
|
||||||
psqlSchema = "11.1";
|
psqlSchema = "11.1";
|
||||||
sha256 = "026v0sicsh7avzi45waf8shcbhivyxmi7qgn9fd1x0vl520mx0ch";
|
sha256 = "026v0sicsh7avzi45waf8shcbhivyxmi7qgn9fd1x0vl520mx0ch";
|
||||||
|
this = self.postgresql_11;
|
||||||
|
inherit self;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
30
pkgs/servers/sql/postgresql/packages.nix
Normal file
30
pkgs/servers/sql/postgresql/packages.nix
Normal file
@ -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 { };
|
||||||
|
}
|
@ -240,6 +240,20 @@ mapAliases ({
|
|||||||
postgresql95 = postgresql_9_5;
|
postgresql95 = postgresql_9_5;
|
||||||
postgresql96 = postgresql_9_6;
|
postgresql96 = postgresql_9_6;
|
||||||
postgresql100 = throw "deprecated 2018-10-21: use postgresql_10 instead";
|
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
|
procps-ng = procps; # added 2018-06-08
|
||||||
prometheus-statsd-bridge = prometheus-statsd-exporter; # added 2017-08-27
|
prometheus-statsd-bridge = prometheus-statsd-exporter; # added 2017-08-27
|
||||||
pulseaudioLight = pulseaudio; # added 2018-04-25
|
pulseaudioLight = pulseaudio; # added 2018-04-25
|
||||||
|
@ -13949,14 +13949,15 @@ in
|
|||||||
|
|
||||||
timescaledb-parallel-copy = callPackage ../development/tools/database/timescaledb-parallel-copy { };
|
timescaledb-parallel-copy = callPackage ../development/tools/database/timescaledb-parallel-copy { };
|
||||||
|
|
||||||
postgresql = postgresql_9_6;
|
inherit (import ../servers/sql/postgresql pkgs super)
|
||||||
|
|
||||||
inherit (callPackages ../servers/sql/postgresql { })
|
|
||||||
postgresql_9_4
|
postgresql_9_4
|
||||||
postgresql_9_5
|
postgresql_9_5
|
||||||
postgresql_9_6
|
postgresql_9_6
|
||||||
postgresql_10
|
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 { };
|
postgresql_jdbc = callPackage ../development/java-modules/postgresql_jdbc { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user