Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskellPackages.postgresql-libpq: Use pkg-config instead of pg_config to find libpq #286370

Conversation

wolfgangwalther
Copy link
Contributor

During configure, postgresql-libpq's Setup.hs will try to execute pg_config to find libpq. This will not work when cross-compiling, because pg_config was compiled for the target system, but needs to run on the host.

The "use-pkg-config" flag allows to do this via pkg-config instead, which works better in those cases.

To replicate this, one needs to be able to build a cross-postgresql at first. Examples for a separate libpq derivation / output are in #234470 and #273175, those could possibly already work to compile to pkgsStatic. Alternatively, a quick hack for a test would be to remove icu and systemd dependencies from pkgs/servers/sql/postgresql/default.nix and then build pkgsCross.musl64.postgresql.

Once postgresql builds, but before this patch, nix-build -A pkgsCross.musl64.haskellPackages.postgresql-libpq will fail with:

Error: Setup: The program 'pg_config' is required but it could not be found.

Which makes sense, I assume, because postgresql would not be in the path anymore as a buildInput, but not nativeBuildInput.

After the change to use pkg-config, pkgsCross.musl64.haskellPackages.postgresql-libpq builds successfully. Of course, I also tested regular haskellPackages.postgresql-libpq, which still builds fine.

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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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.

Copy link
Member

@sternenseemann sternenseemann left a comment

Choose a reason for hiding this comment

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

As this is a permanent override, I'd suggest moving this to configuration-nix.nix.

pkgs/development/haskell-modules/configuration-common.nix Outdated Show resolved Hide resolved
… to find libpq

During configure, postgresql-libpq's Setup.hs will try to execute pg_config to
find libpq. This will not work when cross-compiling, because pg_config was compiled
for the target system, but needs to run on the host.

The "use-pkg-config" flag allows to do this via pkg-config instead, which works
better in those cases.
@wolfgangwalther
Copy link
Contributor Author

As this is a permanent override, I'd suggest moving this to configuration-nix.nix.

Yes, that makes sense - done that way.

@sternenseemann sternenseemann merged commit 16209df into NixOS:haskell-updates Feb 8, 2024
22 of 23 checks passed
@wolfgangwalther wolfgangwalther deleted the postgresql-libpq-pkg-config branch February 10, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants