mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
postgresql: replace pg_config with custom script
By replacing upstream's pg_config binary with a shell script, we: - gain the ability to run pg_config easily when cross-compiling, - can remove the fake pg_config in the default output, - can remove the pg_config wrapper script dealing with special cases. Some 20 years ago, pg_config *was* a shell script upstream, too. It was changed to a binary, when it was made "relocatable", so it would return paths depending on the location of the "postgres" binary. However, this is exactly the thing that just hurts us in nixpkgs - we don't want those paths to change, we want them to always point at the right outputs. By writing the script ourselves, this becomes a lot less painful. This approach means more lines of codes, but all of them are dead simple and we have a lot less complexity overall. Additionally, pg_config is now made a separate derivation, only exposed as "postgresql.pg_config". This has the nice side-effect, that all users of postgresql and libpq in nixpkgs must be very *explicit* about their dependency on pg_config. This gives a lot more visibility into the state of affairs regarding pkg-config support for libpq, which ultimately is the much better solution.
This commit is contained in:
parent
4b631f7101
commit
88dfade94b
32 changed files with 221 additions and 93 deletions
|
@ -154,7 +154,7 @@ let
|
||||||
defaultGemConfig = pkgs.defaultGemConfig // {
|
defaultGemConfig = pkgs.defaultGemConfig // {
|
||||||
pg = attrs: {
|
pg = attrs: {
|
||||||
buildFlags =
|
buildFlags =
|
||||||
[ "--with-pg-config=${lib.getDev pkgs."postgresql_${pg_version}"}/bin/pg_config" ];
|
[ "--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -172,7 +172,7 @@ let
|
||||||
gemConfig = pkgs.defaultGemConfig // {
|
gemConfig = pkgs.defaultGemConfig // {
|
||||||
pg = attrs: {
|
pg = attrs: {
|
||||||
buildFlags =
|
buildFlags =
|
||||||
[ "--with-pg-config=${lib.getDev pkgs."postgresql_${pg_version}"}/bin/pg_config" ];
|
[ "--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -190,7 +190,7 @@ let
|
||||||
defaultGemConfig = super.defaultGemConfig // {
|
defaultGemConfig = super.defaultGemConfig // {
|
||||||
pg = attrs: {
|
pg = attrs: {
|
||||||
buildFlags = [
|
buildFlags = [
|
||||||
"--with-pg-config=${lib.getDev pkgs."postgresql_${pg_version}"}/bin/pg_config"
|
"--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
- `squid` has been updated to version 7, this release includes multiple breaking changes, like ESI removal.
|
- `squid` has been updated to version 7, this release includes multiple breaking changes, like ESI removal.
|
||||||
For more information, [check the release notes](https://github.com/squid-cache/squid/releases/tag/SQUID_7_0_1).
|
For more information, [check the release notes](https://github.com/squid-cache/squid/releases/tag/SQUID_7_0_1).
|
||||||
|
|
||||||
|
- `postgresql` and `libpq` don't provide `pg_config` by default anymore. Instead, `pg_config` is available via `postgresql.pg_config` or `libpq.pg_config`. This allowed implementing it as a shell script, which can be build for both the build and host systems when cross-compiling. If your build fails to find `pg_config`, add `postgresql.pg_config` or `libpq.pg_config` to `nativeBuildInputs`.
|
||||||
|
|
||||||
- The [`no-broken-symlinks` hook](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) was added to catch builds containing dangling or reflexive symlinks, as these are indicative of problems with packaging.
|
- The [`no-broken-symlinks` hook](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) was added to catch builds containing dangling or reflexive symlinks, as these are indicative of problems with packaging.
|
||||||
The hook can be disabled by providing `dontCheckForBrokenSymlinks = true;` as an argument to `mkDerivation`.
|
The hook can be disabled by providing `dontCheckForBrokenSymlinks = true;` as an argument to `mkDerivation`.
|
||||||
For more information, [check the docs](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) or [see this PR](https://github.com/NixOS/nixpkgs/pull/370750).
|
For more information, [check the docs](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) or [see this PR](https://github.com/NixOS/nixpkgs/pull/370750).
|
||||||
|
|
|
@ -59,7 +59,10 @@ stdenv.mkDerivation rec {
|
||||||
++ lib.optional withPgSQL libpq
|
++ lib.optional withPgSQL libpq
|
||||||
++ lib.optional withSQLite sqlite
|
++ lib.optional withSQLite sqlite
|
||||||
++ lib.optional withDB db;
|
++ lib.optional withDB db;
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [
|
||||||
|
libpq.pg_config
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
# patch out libmysql >= 5 check, since mariadb-connector is at 3.x
|
# patch out libmysql >= 5 check, since mariadb-connector is at 3.x
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
sed -i 's/atoi(m) >= 5/1/g' configure m4/mysql_drv.m4
|
sed -i 's/atoi(m) >= 5/1/g' configure m4/mysql_drv.m4
|
||||||
|
@ -87,8 +90,7 @@ stdenv.mkDerivation rec {
|
||||||
++ lib.optionals withMySQL [
|
++ lib.optionals withMySQL [
|
||||||
"--with-mysql-includes=${mariadb-connector-c.dev}/include/mysql"
|
"--with-mysql-includes=${mariadb-connector-c.dev}/include/mysql"
|
||||||
"--with-mysql-libraries=${mariadb-connector-c.out}/lib/mysql"
|
"--with-mysql-libraries=${mariadb-connector-c.out}/lib/mysql"
|
||||||
]
|
];
|
||||||
++ lib.optional withPgSQL "--with-pgsql-libraries=${libpq}/lib";
|
|
||||||
|
|
||||||
# Workaround build failure on -fno-common toolchains like upstream
|
# Workaround build failure on -fno-common toolchains like upstream
|
||||||
# gcc-10. Otherwise build fails as:
|
# gcc-10. Otherwise build fails as:
|
||||||
|
|
|
@ -159,6 +159,9 @@ stdenv.mkDerivation rec {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
perl
|
perl
|
||||||
pkg-config
|
pkg-config
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.elem "pgsql" extraModules) [
|
||||||
|
libpq.pg_config
|
||||||
];
|
];
|
||||||
buildInputs = extraInputs;
|
buildInputs = extraInputs;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
|
||||||
"--localstatedir=/var"
|
"--localstatedir=/var"
|
||||||
"--with-openssl=${lib.getDev openssl}"
|
"--with-openssl=${lib.getDev openssl}"
|
||||||
]
|
]
|
||||||
++ lib.optional withPostgres "--with-pgsql=${lib.getDev libpq}/bin/pg_config"
|
++ lib.optional withPostgres "--with-pgsql=${libpq.pg_config}/bin/pg_config"
|
||||||
++ lib.optional withMysql "--with-mysql=${lib.getDev libmysqlclient}/bin/mysql_config";
|
++ lib.optional withMysql "--with-mysql=${lib.getDev libmysqlclient}/bin/mysql_config";
|
||||||
|
|
||||||
postConfigure = ''
|
postConfigure = ''
|
||||||
|
|
|
@ -18,7 +18,10 @@ stdenv.mkDerivation rec {
|
||||||
sha256 = "sha256-joGaCoRMGpEqq7pnT4Qd7XySjZ5wlZPW27WfOv1UFF4=";
|
sha256 = "sha256-joGaCoRMGpEqq7pnT4Qd7XySjZ5wlZPW27WfOv1UFF4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ libxslt.bin ];
|
nativeBuildInputs = [
|
||||||
|
libxslt.bin
|
||||||
|
postgresql.pg_config
|
||||||
|
];
|
||||||
|
|
||||||
buildInputs = [ postgresql ];
|
buildInputs = [ postgresql ];
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkg-config
|
pkg-config
|
||||||
|
postgresql.pg_config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
|
|
|
@ -33,6 +33,10 @@ stdenv.mkDerivation {
|
||||||
openssl
|
openssl
|
||||||
];
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
libpq.pg_config
|
||||||
|
];
|
||||||
|
|
||||||
passthru.tests.sign-in = nixosTests.pgmanage;
|
passthru.tests.sign-in = nixosTests.pgmanage;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
|
|
@ -35,6 +35,7 @@ stdenv.mkDerivation rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
libpq.pg_config
|
||||||
pkg-config
|
pkg-config
|
||||||
] ++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
|
] ++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
autoreconfHook
|
autoreconfHook
|
||||||
|
libpq.pg_config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
|
|
@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
validatePkgConfig
|
validatePkgConfig
|
||||||
libpq # for pg_config
|
libpq.pg_config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
|
|
@ -58,6 +58,7 @@ stdenv.mkDerivation rec {
|
||||||
gtk-doc
|
gtk-doc
|
||||||
autoconf-archive
|
autoconf-archive
|
||||||
yelp-tools
|
yelp-tools
|
||||||
|
libpq.pg_config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
|
|
|
@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
perl
|
perl
|
||||||
pkg-config
|
pkg-config
|
||||||
];
|
] ++ lib.optional withPostgresql libpq.pg_config;
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[
|
[
|
||||||
|
|
|
@ -23,6 +23,10 @@ buildOctavePackage rec {
|
||||||
libpq
|
libpq
|
||||||
];
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
libpq.pg_config
|
||||||
|
];
|
||||||
|
|
||||||
requiredOctavePackages = [
|
requiredOctavePackages = [
|
||||||
struct
|
struct
|
||||||
];
|
];
|
||||||
|
|
|
@ -73,8 +73,7 @@ let
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cython
|
cython
|
||||||
# needed to find pg_config with strictDeps
|
libpq.pg_config
|
||||||
libpq
|
|
||||||
setuptools
|
setuptools
|
||||||
tomli
|
tomli
|
||||||
];
|
];
|
||||||
|
|
|
@ -38,7 +38,7 @@ buildPythonPackage rec {
|
||||||
# some linker flags are added but the linker ignores them because they're incompatible
|
# some linker flags are added but the linker ignores them because they're incompatible
|
||||||
# https://github.com/psycopg/psycopg2/blob/89005ac5b849c6428c05660b23c5a266c96e677d/setup.py
|
# https://github.com/psycopg/psycopg2/blob/89005ac5b849c6428c05660b23c5a266c96e677d/setup.py
|
||||||
substituteInPlace setup.py \
|
substituteInPlace setup.py \
|
||||||
--replace-fail "self.pg_config_exe = self.build_ext.pg_config" 'self.pg_config_exe = "${lib.getDev buildPackages.libpq}/bin/pg_config"'
|
--replace-fail "self.pg_config_exe = self.build_ext.pg_config" 'self.pg_config_exe = "${libpq.pg_config}/bin/pg_config"'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
|
|
@ -31,8 +31,7 @@ buildPythonPackage rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildInputs = [ libpq ];
|
buildInputs = [ libpq ];
|
||||||
# To find pg_config
|
nativeBuildInputs = [ libpq.pg_config ];
|
||||||
nativeBuildInputs = [ libpq ];
|
|
||||||
|
|
||||||
build-system = [
|
build-system = [
|
||||||
setuptools
|
setuptools
|
||||||
|
|
|
@ -483,7 +483,7 @@ let
|
||||||
RODBC = [ pkgs.libiodbc ];
|
RODBC = [ pkgs.libiodbc ];
|
||||||
rpanel = [ pkgs.tclPackages.bwidget ];
|
rpanel = [ pkgs.tclPackages.bwidget ];
|
||||||
Rpoppler = [ pkgs.poppler ];
|
Rpoppler = [ pkgs.poppler ];
|
||||||
RPostgreSQL = with pkgs; [ libpq ];
|
RPostgreSQL = with pkgs; [ libpq.pg_config ];
|
||||||
RProtoBuf = [ pkgs.protobuf ];
|
RProtoBuf = [ pkgs.protobuf ];
|
||||||
RSclient = [ pkgs.openssl.dev ];
|
RSclient = [ pkgs.openssl.dev ];
|
||||||
Rserve = [ pkgs.openssl ];
|
Rserve = [ pkgs.openssl ];
|
||||||
|
|
|
@ -669,7 +669,7 @@ in
|
||||||
# Force pkg-config lookup for libpq.
|
# Force pkg-config lookup for libpq.
|
||||||
# See https://github.com/ged/ruby-pg/blob/6629dec6656f7ca27619e4675b45225d9e422112/ext/extconf.rb#L34-L55
|
# See https://github.com/ged/ruby-pg/blob/6629dec6656f7ca27619e4675b45225d9e422112/ext/extconf.rb#L34-L55
|
||||||
#
|
#
|
||||||
# Note that setting --with-pg-config=${lib.getDev postgresql}/bin/pg_config would add
|
# Note that setting --with-pg-config=${postgresql.pg_config}/bin/pg_config would add
|
||||||
# an unnecessary reference to the entire postgresql package.
|
# an unnecessary reference to the entire postgresql package.
|
||||||
buildFlags = [ "--with-pg-config=ignore" ];
|
buildFlags = [ "--with-pg-config=ignore" ];
|
||||||
nativeBuildInputs = [ pkg-config ];
|
nativeBuildInputs = [ pkg-config ];
|
||||||
|
|
|
@ -93,7 +93,7 @@ let
|
||||||
preBuildAndTest = ''
|
preBuildAndTest = ''
|
||||||
export PGRX_HOME="$(mktemp -d)"
|
export PGRX_HOME="$(mktemp -d)"
|
||||||
export PGDATA="$PGRX_HOME/data-${pgrxPostgresMajor}/"
|
export PGDATA="$PGRX_HOME/data-${pgrxPostgresMajor}/"
|
||||||
cargo-pgrx pgrx init "--pg${pgrxPostgresMajor}" ${lib.getDev postgresql}/bin/pg_config
|
cargo-pgrx pgrx init "--pg${pgrxPostgresMajor}" ${postgresql.pg_config}/bin/pg_config
|
||||||
|
|
||||||
# unix sockets work in sandbox, too.
|
# unix sockets work in sandbox, too.
|
||||||
export PGHOST="$(mktemp -d)"
|
export PGHOST="$(mktemp -d)"
|
||||||
|
@ -140,7 +140,7 @@ let
|
||||||
PGRX_BUILD_FLAGS="--frozen -j $NIX_BUILD_CORES ${builtins.concatStringsSep " " cargoBuildFlags}" \
|
PGRX_BUILD_FLAGS="--frozen -j $NIX_BUILD_CORES ${builtins.concatStringsSep " " cargoBuildFlags}" \
|
||||||
${lib.optionalString stdenv.hostPlatform.isDarwin ''RUSTFLAGS="''${RUSTFLAGS:+''${RUSTFLAGS} }-Clink-args=-Wl,-undefined,dynamic_lookup"''} \
|
${lib.optionalString stdenv.hostPlatform.isDarwin ''RUSTFLAGS="''${RUSTFLAGS:+''${RUSTFLAGS} }-Clink-args=-Wl,-undefined,dynamic_lookup"''} \
|
||||||
cargo pgrx package \
|
cargo pgrx package \
|
||||||
--pg-config ${lib.getDev postgresql}/bin/pg_config \
|
--pg-config ${postgresql.pg_config}/bin/pg_config \
|
||||||
${maybeDebugFlag} \
|
${maybeDebugFlag} \
|
||||||
--features "${builtins.concatStringsSep " " buildFeatures}" \
|
--features "${builtins.concatStringsSep " " buildFeatures}" \
|
||||||
--out-dir "$out"
|
--out-dir "$out"
|
||||||
|
|
|
@ -34,7 +34,10 @@ callPackage ../nginx/generic.nix args rec {
|
||||||
--replace "b/" "b/bundle/nginx-${nginxVersion}/"
|
--replace "b/" "b/bundle/nginx-${nginxVersion}/"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
nativeBuildInputs = [
|
||||||
|
libpq.pg_config
|
||||||
|
perl
|
||||||
|
];
|
||||||
|
|
||||||
buildInputs = [ libpq ];
|
buildInputs = [ libpq ];
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,6 @@ assert sqliteSupport -> !mysqlSupport && !postgresqlSupport;
|
||||||
let
|
let
|
||||||
inherit (lib) optional optionalString;
|
inherit (lib) optional optionalString;
|
||||||
|
|
||||||
fake_pg_config = buildPackages.writeShellScript "pg_config" ''
|
|
||||||
if [[ "$1" == "--version" ]]; then
|
|
||||||
$PKG_CONFIG libpq --modversion
|
|
||||||
else
|
|
||||||
$PKG_CONFIG libpq --variable="''${1//--/}"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
fake_mysql_config = buildPackages.writeShellScript "mysql_config" ''
|
fake_mysql_config = buildPackages.writeShellScript "mysql_config" ''
|
||||||
if [[ "$1" == "--version" ]]; then
|
if [[ "$1" == "--version" ]]; then
|
||||||
$PKG_CONFIG mysqlclient --modversion
|
$PKG_CONFIG mysqlclient --modversion
|
||||||
|
@ -60,7 +52,9 @@ import ./versions.nix (
|
||||||
inherit hash;
|
inherit hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ pkg-config ];
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
] ++ optional postgresqlSupport libpq.pg_config;
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[
|
[
|
||||||
curl
|
curl
|
||||||
|
@ -93,7 +87,7 @@ import ./versions.nix (
|
||||||
++ optional sqliteSupport "--with-sqlite3=${sqlite.dev}"
|
++ optional sqliteSupport "--with-sqlite3=${sqlite.dev}"
|
||||||
++ optional sshSupport "--with-ssh2=${libssh2.dev}"
|
++ optional sshSupport "--with-ssh2=${libssh2.dev}"
|
||||||
++ optional mysqlSupport "--with-mysql=${fake_mysql_config}"
|
++ optional mysqlSupport "--with-mysql=${fake_mysql_config}"
|
||||||
++ optional postgresqlSupport "--with-postgresql=${fake_pg_config}";
|
++ optional postgresqlSupport "--with-postgresql";
|
||||||
|
|
||||||
prePatch = ''
|
prePatch = ''
|
||||||
find database -name data.sql -exec sed -i 's|/usr/bin/||g' {} +
|
find database -name data.sql -exec sed -i 's|/usr/bin/||g' {} +
|
||||||
|
|
|
@ -50,7 +50,7 @@ import ./versions.nix (
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
autoreconfHook
|
autoreconfHook
|
||||||
pkg-config
|
pkg-config
|
||||||
];
|
] ++ optional postgresqlSupport libpq.pg_config;
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[
|
[
|
||||||
curl
|
curl
|
||||||
|
|
|
@ -76,6 +76,7 @@ postgresqlBuildExtension (finalAttrs: {
|
||||||
dontDisableStatic = true;
|
dontDisableStatic = true;
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [
|
||||||
|
postgresql
|
||||||
postgresqlTestHook
|
postgresqlTestHook
|
||||||
cunit
|
cunit
|
||||||
libxslt
|
libxslt
|
||||||
|
@ -93,6 +94,7 @@ postgresqlBuildExtension (finalAttrs: {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configureFlags = [
|
configureFlags = [
|
||||||
|
"--with-pgconfig=${postgresql.pg_config}/bin/pg_config"
|
||||||
"--with-gdalconfig=${gdal}/bin/gdal-config"
|
"--with-gdalconfig=${gdal}/bin/gdal-config"
|
||||||
"--with-jsondir=${json_c.dev}"
|
"--with-jsondir=${json_c.dev}"
|
||||||
"--disable-extension-upgrades-install"
|
"--disable-extension-upgrades-install"
|
||||||
|
|
|
@ -42,6 +42,7 @@ let
|
||||||
|
|
||||||
# passthru
|
# passthru
|
||||||
buildEnv,
|
buildEnv,
|
||||||
|
buildPackages,
|
||||||
newScope,
|
newScope,
|
||||||
nixosTests,
|
nixosTests,
|
||||||
postgresqlTestHook,
|
postgresqlTestHook,
|
||||||
|
@ -126,8 +127,6 @@ let
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
stdenv;
|
stdenv;
|
||||||
|
|
||||||
pg_config = writeShellScriptBin "pg_config" (builtins.readFile ./pg_config.sh);
|
|
||||||
in
|
in
|
||||||
stdenv'.mkDerivation (finalAttrs: {
|
stdenv'.mkDerivation (finalAttrs: {
|
||||||
inherit version;
|
inherit version;
|
||||||
|
@ -341,8 +340,7 @@ let
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace "src/Makefile.global.in" --subst-var out
|
substituteInPlace "src/Makefile.global.in" --subst-var out
|
||||||
# Hardcode the path to pgxs so pg_config returns the path in $dev
|
cat ${./pg_config.env.mk} >> src/common/Makefile
|
||||||
substituteInPlace "src/common/config_info.c" --subst-var dev
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postInstall =
|
postInstall =
|
||||||
|
@ -350,12 +348,9 @@ let
|
||||||
moveToOutput "bin/ecpg" "$dev"
|
moveToOutput "bin/ecpg" "$dev"
|
||||||
moveToOutput "lib/pgxs" "$dev"
|
moveToOutput "lib/pgxs" "$dev"
|
||||||
|
|
||||||
# Pretend pg_config is located in $out/bin to return correct paths, but
|
rm "$out/bin/pg_config"
|
||||||
# actually have it in -dev to avoid pulling in all other outputs. See the
|
make -C src/common pg_config.env
|
||||||
# pg_config.sh script's comments for details.
|
install -D src/common/pg_config.env "$dev/nix-support/pg_config.env"
|
||||||
moveToOutput "bin/pg_config" "$dev"
|
|
||||||
install -c -m 755 "${pg_config}"/bin/pg_config "$out/bin/pg_config"
|
|
||||||
wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config"
|
|
||||||
|
|
||||||
# postgres exposes external symbols get_pkginclude_path and similar. Those
|
# postgres exposes external symbols get_pkginclude_path and similar. Those
|
||||||
# can't be stripped away by --gc-sections/LTO, because they could theoretically
|
# can't be stripped away by --gc-sections/LTO, because they could theoretically
|
||||||
|
@ -458,6 +453,8 @@ let
|
||||||
postgresql = this;
|
postgresql = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pg_config = buildPackages.callPackage ./pg_config.nix { inherit (finalAttrs) finalPackage; };
|
||||||
|
|
||||||
tests =
|
tests =
|
||||||
{
|
{
|
||||||
postgresql = nixosTests.postgresql.postgresql.passthru.override finalAttrs.finalPackage;
|
postgresql = nixosTests.postgresql.postgresql.passthru.override finalAttrs.finalPackage;
|
||||||
|
@ -519,6 +516,7 @@ let
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit installedExtensions;
|
inherit installedExtensions;
|
||||||
inherit (postgresql)
|
inherit (postgresql)
|
||||||
|
pg_config
|
||||||
psqlSchema
|
psqlSchema
|
||||||
version
|
version
|
||||||
;
|
;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
# passthru / meta
|
# passthru / meta
|
||||||
postgresql,
|
postgresql,
|
||||||
|
buildPackages,
|
||||||
|
|
||||||
# GSSAPI
|
# GSSAPI
|
||||||
gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic,
|
gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic,
|
||||||
|
@ -107,29 +108,19 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
./patches/socketdir-in-run-13+.patch
|
./patches/socketdir-in-run-13+.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
cat ${./pg_config.env.mk} >> src/common/Makefile
|
||||||
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
make -C src/bin/pg_config install
|
make -C src/common install pg_config.env
|
||||||
make -C src/common install
|
|
||||||
make -C src/include install
|
make -C src/include install
|
||||||
make -C src/interfaces/libpq install
|
make -C src/interfaces/libpq install
|
||||||
make -C src/port install
|
make -C src/port install
|
||||||
|
|
||||||
# Pretend pg_config is located in $out/bin to return correct paths, but
|
install -D src/common/pg_config.env "$dev/nix-support/pg_config.env"
|
||||||
# actually have it in -dev to avoid pulling in all other outputs.
|
|
||||||
moveToOutput bin/pg_config "$dev"
|
|
||||||
wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config"
|
|
||||||
|
|
||||||
# To prevent a "pg_config: could not find own program executable" error, we fake
|
|
||||||
# pg_config in the default output.
|
|
||||||
mkdir -p "$out/bin"
|
|
||||||
cat << EOF > "$out/bin/pg_config" && chmod +x "$out/bin/pg_config"
|
|
||||||
#!${stdenv.shell}
|
|
||||||
echo The real pg_config can be found in the -dev output.
|
|
||||||
exit 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
moveToOutput "lib/*.a" "$dev"
|
moveToOutput "lib/*.a" "$dev"
|
||||||
|
|
||||||
rm -rfv $out/share
|
rm -rfv $out/share
|
||||||
|
@ -150,6 +141,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
|
passthru.pg_config = buildPackages.callPackage ./pg_config.nix {
|
||||||
|
inherit (finalAttrs) finalPackage;
|
||||||
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
inherit (postgresql.meta)
|
inherit (postgresql.meta)
|
||||||
homepage
|
homepage
|
||||||
|
|
13
pkgs/servers/sql/postgresql/pg_config.env.mk
Normal file
13
pkgs/servers/sql/postgresql/pg_config.env.mk
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Everything that pg_config normally returns is put into pg_config.env, so
|
||||||
|
# that we can read it from our own pg_config script later on.
|
||||||
|
pg_config.env: $(top_builddir)/src/port/pg_config_paths.h | $(top_builddir)/src/include/pg_config.h
|
||||||
|
echo "CC=\"$(CC)\"" >$@
|
||||||
|
echo "CPPFLAGS=\"$(STD_CPPFLAGS)\"" >>$@
|
||||||
|
echo "CFLAGS=\"$(CFLAGS)\"" >>$@
|
||||||
|
echo "CFLAGS_SL=\"$(CFLAGS_SL)\"" >>$@
|
||||||
|
echo "LDFLAGS=\"$(STD_LDFLAGS)\"" >>$@
|
||||||
|
echo "LDFLAGS_EX=\"$(LDFLAGS_EX)\"" >>$@
|
||||||
|
echo "LDFLAGS_SL=\"$(LDFLAGS_SL)\"" >>$@
|
||||||
|
echo "LIBS=\"$(LIBS)\"" >>$@
|
||||||
|
cat $(top_builddir)/src/port/pg_config_paths.h $(top_builddir)/src/include/pg_config.h \
|
||||||
|
| sed -nE 's/^#define ([^ ]+) ("?)(.*)\2$$/\1="\3"/p' >>$@
|
18
pkgs/servers/sql/postgresql/pg_config.nix
Normal file
18
pkgs/servers/sql/postgresql/pg_config.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
replaceVarsWith,
|
||||||
|
runtimeShell,
|
||||||
|
# PostgreSQL package
|
||||||
|
finalPackage,
|
||||||
|
}:
|
||||||
|
|
||||||
|
replaceVarsWith {
|
||||||
|
name = "pg_config";
|
||||||
|
src = ./pg_config.sh;
|
||||||
|
dir = "bin";
|
||||||
|
isExecutable = true;
|
||||||
|
replacements = {
|
||||||
|
inherit runtimeShell;
|
||||||
|
postgresql-dev = lib.getDev finalPackage;
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,37 +1,122 @@
|
||||||
|
#!@runtimeShell@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# The real pg_config needs to be in the same path as the "postgres" binary
|
# This replacement script for the pg_config binary is based on the original pg_config
|
||||||
# to return proper paths. However, we want it in the -dev output to prevent
|
# shell script, which was removed from PostgreSQL's codebase in 2004:
|
||||||
# cyclic references and to prevent blowing up the runtime closure. Thus, we
|
# https://github.com/postgres/postgres/commit/cc07f8cfe73f56fce1ddda4ea25d7b0b6c4f0ae9
|
||||||
# have wrapped -dev/bin/pg_config to fake its argv0 to be in the default
|
#
|
||||||
# output. Unfortunately, pg_config tries to be smart and tries to find itself -
|
# The main reason for removal was the ability to relocate an existing installation, which
|
||||||
# which will then fail with:
|
# is exactly the one feature that we are trying to work around in nixpkgs.
|
||||||
# pg_config: could not find own program executable
|
# Going back to a shell script is much better for cross compiling.
|
||||||
# To counter this, we're creating *this* fake pg_config script and put it into
|
#
|
||||||
# the default output. The real pg_config is happy.
|
# This file is a combination of the following two files:
|
||||||
# Some extensions, e.g. timescaledb, use the reverse logic and look for pg_config
|
# https://github.com/postgres/postgres/blob/7510ac6203bc8e3c56eae95466feaeebfc1b4f31/src/bin/pg_config/pg_config.sh
|
||||||
# in the same path as the "postgres" binary to support multi-version-installs.
|
# https://github.com/postgres/postgres/blob/master/src/bin/pg_config/pg_config.c
|
||||||
# Thus, they will end up calling this script during build, even though the real
|
|
||||||
# pg_config would be available on PATH, provided by nativeBuildInputs. To help
|
|
||||||
# this case, we're redirecting the call to pg_config to the one found in PATH,
|
|
||||||
# iff we can be convinced that it belongs to our -dev output.
|
|
||||||
|
|
||||||
# Avoid infinite recursion
|
source @postgresql-dev@/nix-support/pg_config.env
|
||||||
if [[ ! -v PG_CONFIG_CALLED ]]; then
|
|
||||||
# compares "path of *this* script" with "path, which pg_config on PATH believes it is in"
|
help="
|
||||||
if [[ "$(readlink -f -- "$0")" == "$(PG_CONFIG_CALLED=1 pg_config --bindir)/pg_config" ]]; then
|
pg_config provides information about the installed version of PostgreSQL.
|
||||||
# The pg_config in PATH returns the same bindir that we're actually called from.
|
|
||||||
# This means that the pg_config in PATH is the one from "our" -dev output.
|
Usage:
|
||||||
# This happens when the -dev output has been put in native build
|
pg_config [OPTION]...
|
||||||
# inputs and allows us to call the real pg_config without referencing
|
|
||||||
# the -dev output itself.
|
Options:
|
||||||
exec pg_config "$@"
|
--bindir show location of user executables
|
||||||
fi
|
--docdir show location of documentation files
|
||||||
|
--htmldir show location of HTML documentation files
|
||||||
|
--includedir show location of C header files of the client
|
||||||
|
interfaces
|
||||||
|
--pkgincludedir show location of other C header files
|
||||||
|
--includedir-server show location of C header files for the server
|
||||||
|
--libdir show location of object code libraries
|
||||||
|
--pkglibdir show location of dynamically loadable modules
|
||||||
|
--localedir show location of locale support files
|
||||||
|
--mandir show location of manual pages
|
||||||
|
--sharedir show location of architecture-independent support files
|
||||||
|
--sysconfdir show location of system-wide configuration files
|
||||||
|
--pgxs show location of extension makefile
|
||||||
|
--configure show options given to \"configure\" script when
|
||||||
|
PostgreSQL was built
|
||||||
|
--cc show CC value used when PostgreSQL was built
|
||||||
|
--cppflags show CPPFLAGS value used when PostgreSQL was built
|
||||||
|
--cflags show CFLAGS value used when PostgreSQL was built
|
||||||
|
--cflags_sl show CFLAGS_SL value used when PostgreSQL was built
|
||||||
|
--ldflags show LDFLAGS value used when PostgreSQL was built
|
||||||
|
--ldflags_ex show LDFLAGS_EX value used when PostgreSQL was built
|
||||||
|
--ldflags_sl show LDFLAGS_SL value used when PostgreSQL was built
|
||||||
|
--libs show LIBS value used when PostgreSQL was built
|
||||||
|
--version show the PostgreSQL version
|
||||||
|
-?, --help show this help, then exit
|
||||||
|
|
||||||
|
With no arguments, all known items are shown.
|
||||||
|
|
||||||
|
Report bugs to <${PACKAGE_BUGREPORT}>.
|
||||||
|
${PACKAGE_NAME} home page: <${PACKAGE_URL}>"
|
||||||
|
|
||||||
|
show=()
|
||||||
|
|
||||||
|
for opt; do
|
||||||
|
case "$opt" in
|
||||||
|
--bindir) show+=("$PGBINDIR") ;;
|
||||||
|
--docdir) show+=("$DOCDIR") ;;
|
||||||
|
--htmldir) show+=("$HTMLDIR") ;;
|
||||||
|
--includedir) show+=("$INCLUDEDIR") ;;
|
||||||
|
--pkgincludedir) show+=("$PKGINCLUDEDIR") ;;
|
||||||
|
--includedir-server) show+=("$INCLUDEDIRSERVER") ;;
|
||||||
|
--libdir) show+=("$LIBDIR") ;;
|
||||||
|
--pkglibdir) show+=("$PKGLIBDIR") ;;
|
||||||
|
--localedir) show+=("$LOCALEDIR") ;;
|
||||||
|
--mandir) show+=("$MANDIR") ;;
|
||||||
|
--sharedir) show+=("$PGSHAREDIR") ;;
|
||||||
|
--sysconfdir) show+=("$SYSCONFDIR") ;;
|
||||||
|
--pgxs) show+=("@postgresql-dev@/lib/pgxs/src/makefiles/pgxs.mk") ;;
|
||||||
|
--configure) show+=("$CONFIGURE_ARGS") ;;
|
||||||
|
--cc) show+=("$CC") ;;
|
||||||
|
--cppflags) show+=("$CPPFLAGS") ;;
|
||||||
|
--cflags) show+=("$CFLAGS") ;;
|
||||||
|
--cflags_sl) show+=("$CFLAGS_SL") ;;
|
||||||
|
--ldflags) show+=("$LDFLAGS") ;;
|
||||||
|
--ldflags_ex) show+=("$LDFLAGS_EX") ;;
|
||||||
|
--ldflags_sl) show+=("$LDFLAGS_SL") ;;
|
||||||
|
--libs) show+=("$LIBS") ;;
|
||||||
|
--version) show+=("PostgreSQL $PG_VERSION") ;;
|
||||||
|
--help|-\?) echo "$help"
|
||||||
|
exit 0 ;;
|
||||||
|
*) >&2 echo "pg_config: invalid argument: $opt"
|
||||||
|
>&2 echo "Try \"pg_config --help\" for more information."
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#show[@]} -gt 0 ]; then
|
||||||
|
printf '%s\n' "${show[@]}"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This will happen in one of these cases:
|
# no arguments -> print everything
|
||||||
# - *this* script is the first on PATH
|
cat <<EOF
|
||||||
# - np pg_config on PATH
|
BINDIR = $PGBINDIR
|
||||||
# - some other pg_config on PATH, not from our -dev output
|
DOCDIR = $DOCDIR
|
||||||
echo The real pg_config can be found in the -dev output.
|
HTMLDIR = $HTMLDIR
|
||||||
exit 1
|
INCLUDEDIR = $INCLUDEDIR
|
||||||
|
PKGINCLUDEDIR = $PKGINCLUDEDIR
|
||||||
|
INCLUDEDIR-SERVER = $INCLUDEDIRSERVER
|
||||||
|
LIBDIR = $LIBDIR
|
||||||
|
PKGLIBDIR = $PKGLIBDIR
|
||||||
|
LOCALEDIR = $LOCALEDIR
|
||||||
|
MANDIR = $MANDIR
|
||||||
|
SHAREDIR = $PGSHAREDIR
|
||||||
|
SYSCONFDIR = $SYSCONFDIR
|
||||||
|
PGXS = @postgresql-dev@/lib/pgxs/src/makefiles/pgxs.mk
|
||||||
|
CONFIGURE = $CONFIGURE_ARGS
|
||||||
|
CC = $CC
|
||||||
|
CPPFLAGS = $CPPFLAGS
|
||||||
|
CFLAGS = $CFLAGS
|
||||||
|
CFLAGS_SL = $CFLAGS_SL
|
||||||
|
LDFLAGS = $LDFLAGS
|
||||||
|
LDFLAGS_EX = $LDFLAGS_EX
|
||||||
|
LDFLAGS_SL = $LDFLAGS_SL
|
||||||
|
LIBS = $LIBS
|
||||||
|
VERSION = PostgreSQL $PG_VERSION
|
||||||
|
EOF
|
||||||
|
|
|
@ -86,7 +86,7 @@ let
|
||||||
|
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
buildInputs = [ postgresql ] ++ prevAttrs.buildInputs or [ ];
|
buildInputs = [ postgresql ] ++ prevAttrs.buildInputs or [ ];
|
||||||
nativeBuildInputs = [ postgresql ] ++ prevAttrs.nativeBuildInputs or [ ];
|
nativeBuildInputs = [ postgresql.pg_config ] ++ prevAttrs.nativeBuildInputs or [ ];
|
||||||
|
|
||||||
installFlags = [
|
installFlags = [
|
||||||
"DESTDIR=${placeholder "out"}"
|
"DESTDIR=${placeholder "out"}"
|
||||||
|
|
|
@ -7268,7 +7268,7 @@ with self; {
|
||||||
buildInputs = [ pkgs.postgresql ];
|
buildInputs = [ pkgs.postgresql ];
|
||||||
propagatedBuildInputs = [ DBI ];
|
propagatedBuildInputs = [ DBI ];
|
||||||
|
|
||||||
makeMakerFlags = [ "POSTGRES_HOME=${pkgs.postgresql}" ];
|
nativeBuildInputs = [ pkgs.postgresql.pg_config ];
|
||||||
|
|
||||||
# tests freeze in a sandbox
|
# tests freeze in a sandbox
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
|
@ -640,7 +640,7 @@ lib.makeScope pkgs.newScope (
|
||||||
{
|
{
|
||||||
name = "pdo_pgsql";
|
name = "pdo_pgsql";
|
||||||
internalDeps = [ php.extensions.pdo ];
|
internalDeps = [ php.extensions.pdo ];
|
||||||
configureFlags = [ "--with-pdo-pgsql=${lib.getDev libpq}" ];
|
configureFlags = [ "--with-pdo-pgsql=${libpq.pg_config}" ];
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -655,7 +655,7 @@ lib.makeScope pkgs.newScope (
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pcre2
|
pcre2
|
||||||
];
|
];
|
||||||
configureFlags = [ "--with-pgsql=${lib.getDev libpq}" ];
|
configureFlags = [ "--with-pgsql=${libpq.pg_config}" ];
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue