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

postgresql: improve fake pg_config in default output #341421

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

wolfgangwalther
Copy link
Contributor

Description of changes

This fixes some build systems which look up the location of pg_config via the location of the postgres binary itself, e.g. timescaledb, instead of calling pg_config which is on PATH.

Since the -dev output is correctly placed before the default output of postgresql in PATH, we can rely on that and call "pg_config" from the default output's fake script. Only do that, when the one on PATH is actually a different file, though, to prevent infinite loops.

@Ma27 could you have a look?

Resolves #341408, CC @zoechi

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.11 Release Notes (or backporting 23.11 and 24.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.

pkgs/servers/sql/postgresql/generic.nix Outdated Show resolved Hide resolved
pkgs/servers/sql/postgresql/generic.nix Outdated Show resolved Hide resolved
Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

Looking good now, except for one remark.
Currently testing the change.

If no further issues arise during testing, we can merge as soon as this is fixed.

Thank you for your work!

pkgs/servers/sql/postgresql/pg_config.sh Outdated Show resolved Hide resolved
pkgs/servers/sql/postgresql/pg_config.sh Outdated Show resolved Hide resolved
@wolfgangwalther
Copy link
Contributor Author

I'm not happy with the current implementation, yet. Two reasons:

  • cycle detection to prevent infinite loops of calling pg_config.sh itself is potentially brittle when someone creates a wrapper script around it. This can be improved by setting an environment variable before calling the pg_config in PATH and checking that instead.
  • when I execute this script on my local system, I get entirely different values returned - because I do have a pg_config on path. This means the script will return potentially entirely wrong stuff. We can improve that, by calling pg_config --bindir first - and confirming that the pg_config we are about to call will actually "belong" to the same derivation that we're currently in.

@wolfgangwalther
Copy link
Contributor Author

Ok, the latest version is one that I am quite happy with, it should check all the boxes.

@wolfgangwalther wolfgangwalther marked this pull request as ready for review September 19, 2024 16:46
@wolfgangwalther wolfgangwalther force-pushed the postgresql-pg-config branch 2 times, most recently from d67e3f2 to 09d6dc3 Compare September 19, 2024 16:48
@wolfgangwalther
Copy link
Contributor Author

Ok, the latest version is one that I am quite happy with, it should check all the boxes.

Except that the prevention of infinite recursion doesn't work as expected, yet.

This fixes some build systems which look up the location of pg_config
via the location of the postgres binary itself, e.g. timescaledb,
instead of calling pg_config which is on PATH.

Since the -dev output is correctly placed before the default output of
postgresql in PATH, we can rely on that and call "pg_config" from the
default output's fake script. Only do that, when the one on PATH is
actually a different file, though, to prevent infinite loops.

Resolves NixOS#341408
@wolfgangwalther
Copy link
Contributor Author

Ok, the latest version is one that I am quite happy with, it should check all the boxes.

Except that the prevention of infinite recursion doesn't work as expected, yet.

But now it does, after the latest push.

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.

2 participants