Wolfgang Walther 88dfade94b
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.
2025-03-21 18:05:38 +01:00

75 lines
1.5 KiB
Nix

{
lib,
stdenv,
fetchurl,
pkg-config,
openssl,
libxslt,
perl,
curl,
pcre,
libxml2,
librdf_rasqal,
gmp,
libmysqlclient,
withMysql ? false,
libpq,
withPostgresql ? false,
sqlite,
withSqlite ? true,
db,
withBdb ? false,
}:
stdenv.mkDerivation rec {
pname = "redland";
version = "1.0.17";
src = fetchurl {
url = "http://download.librdf.org/source/redland-${version}.tar.gz";
sha256 = "de1847f7b59021c16bdc72abb4d8e2d9187cd6124d69156f3326dd34ee043681";
};
nativeBuildInputs = [
perl
pkg-config
] ++ lib.optional withPostgresql libpq.pg_config;
buildInputs =
[
openssl
libxslt
curl
pcre
libxml2
gmp
]
++ lib.optional withMysql libmysqlclient
++ lib.optional withSqlite sqlite
++ lib.optional withPostgresql libpq
++ lib.optional withBdb db;
propagatedBuildInputs = [ librdf_rasqal ];
postInstall = "rm -rvf $out/share/gtk-doc";
configureFlags =
[ "--with-threads" ]
++ lib.optionals withBdb [
"--with-bdb-include=${db.dev}/include"
"--with-bdb-lib=${db.out}/lib"
];
# Fix broken DT_NEEDED in lib/redland/librdf_storage_sqlite.so.
NIX_CFLAGS_LINK = "-lraptor2";
doCheck = false; # fails 1 out of 17 tests with a segmentation fault
meta = with lib; {
description = "C libraries that provide support for the Resource Description Framework (RDF)";
homepage = "https://librdf.org/";
platforms = platforms.unix;
license = licenses.asl20;
};
}