Skip to content
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
15 changes: 15 additions & 0 deletions pkgs/servers/sql/postgresql/libpq.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# build dependencies
bison,
flex,
makeWrapper,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using makeBinaryWrapper instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to understand why one or the other would be better. I just looked up the nixpkgs manual, which reads:

Using the makeBinaryWrapper implementation is usually preferred, as it creates a tiny compiled wrapper executable, that can be used as a shebang interpreter. This is needed mostly on Darwin, where shebangs cannot point to scripts, due to a limitation with the execve-syscall.

I don't get what a shebang has to do with it. pg_config is surely not used as a shebang.

Why do you think makeBinaryWrapper is better?

Copy link
Copy Markdown
Contributor

@drupol drupol Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just would simply use makeBinaryWrapper by default everywhere, since if offers better compatibility with Darwin systems. That's the only reason for me. Also, why do you use makeWrapper instead of makeBinaryWrapper ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do you use makeWrapper instead of makeBinaryWrapper ?

Here? Just because generic.nix does the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. My comment was not a blocker so, feel free to implement what you prefer.

perl,
pkg-config,

Expand Down Expand Up @@ -62,6 +63,7 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
bison
flex
makeWrapper
perl
pkg-config
];
Expand Down Expand Up @@ -111,7 +113,20 @@ stdenv.mkDerivation (finalAttrs: {
make -C src/interfaces/libpq install
make -C src/port install

# Pretend pg_config is located in $out/bin to return correct paths, but
# 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
Comment on lines +124 to +128
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
cat << EOF > "$out/bin/pg_config"
#!${stdenv.shell}
echo The real pg_config can be found in the -dev output.
exit 1
EOF
chmod +x "$out/bin/pg_config"


moveToOutput "lib/*.a" "$dev"

rm -rfv $out/share
Expand Down
2 changes: 0 additions & 2 deletions pkgs/top-level/php-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ lib.makeScope pkgs.newScope (
{
name = "pdo_pgsql";
internalDeps = [ php.extensions.pdo ];
buildInputs = [ libpq ];
configureFlags = [ "--with-pdo-pgsql=${lib.getDev libpq}" ];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ma27 we added libpq as a buildInput here as a last fix in #359659 (comment), even though we had it via --with-pdo-pgsql already.

This explains why - it now builds fine without passing it as extra buildInput again, because pg_config returns the right values.

doCheck = false;
}
Expand All @@ -651,7 +650,6 @@ lib.makeScope pkgs.newScope (
name = "pgsql";
buildInputs = [
pcre2
libpq
];
configureFlags = [ "--with-pgsql=${lib.getDev libpq}" ];
doCheck = false;
Expand Down