Skip to content

Commit

Permalink
postgresql: improve fake pg_config in default output
Browse files Browse the repository at this point in the history
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 #341408
  • Loading branch information
wolfgangwalther committed Sep 12, 2024
1 parent fd34cba commit fcf27fe
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkgs/servers/sql/postgresql/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,17 @@ let
moveToOutput "bin/pg_config" "$dev"
# To prevent a "pg_config: could not find own program executable" error, we fake
# pg_config in the default output.
cat << EOF > "$out/bin/pg_config" && chmod +x "$out/bin/pg_config"
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
my_path="$(readlink -f -- "$0")"
on_path="$(readlink -f -- "$(which pg_config)")"
if [[ "$my_path" == "$on_path" ]]; then
echo The real pg_config can be found in the -dev output.
exit 1
else
# There is a different pg_config in PATH, let's call this instead.
pg_config "$@"
fi
EOF
wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config"
Expand Down

0 comments on commit fcf27fe

Please sign in to comment.