Skip to content

libpq: fix pg_config --libdir#382380

Merged
Ma27 merged 1 commit intoNixOS:stagingfrom
wolfgangwalther:libpq-pg-config
Feb 20, 2025
Merged

libpq: fix pg_config --libdir#382380
Ma27 merged 1 commit intoNixOS:stagingfrom
wolfgangwalther:libpq-pg-config

Conversation

@wolfgangwalther
Copy link
Copy Markdown
Contributor

With the same reasoning as for postgresql's pg_config, we need to make adjustments to libpq's variant. Otherwise it would not return the correct LIBDIR, pointing at the -dev output instead of -out.

Fixes #359659 (comment)

@sternenseemann can you confirm?

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nix-owners nix-owners Bot requested review from Ma27 and thoughtpolice February 15, 2025 18:11
@github-actions github-actions Bot added 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Feb 15, 2025
With the same reasoning as for postgresql's pg_config, we need to make
adjustments to libpq's variant. Otherwise it would not return the
correct LIBDIR, pointing at the -dev output instead of -out.
@github-actions github-actions Bot added the 6.topic: php PHP is a general-purpose scripting language geared towards web development. label Feb 15, 2025
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.

# 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.

@nix-owners nix-owners Bot requested a review from piotrkwiecinski February 15, 2025 21:21
Comment on lines +124 to +128
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
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"

@Ma27 Ma27 merged commit 6127dba into NixOS:staging Feb 20, 2025
@wolfgangwalther wolfgangwalther deleted the libpq-pg-config branch February 20, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: php PHP is a general-purpose scripting language geared towards web development. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants