nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at gcc-offload 37 lines 2.0 kB view raw
1set -euo pipefail 2 3# The real pg_config needs to be in the same path as the "postgres" binary 4# to return proper paths. However, we want it in the -dev output to prevent 5# cyclic references and to prevent blowing up the runtime closure. Thus, we 6# have wrapped -dev/bin/pg_config to fake its argv0 to be in the default 7# output. Unfortunately, pg_config tries to be smart and tries to find itself - 8# which will then fail with: 9# pg_config: could not find own program executable 10# To counter this, we're creating *this* fake pg_config script and put it into 11# the default output. The real pg_config is happy. 12# Some extensions, e.g. timescaledb, use the reverse logic and look for pg_config 13# in the same path as the "postgres" binary to support multi-version-installs. 14# Thus, they will end up calling this script during build, even though the real 15# pg_config would be available on PATH, provided by nativeBuildInputs. To help 16# this case, we're redirecting the call to pg_config to the one found in PATH, 17# iff we can be convinced that it belongs to our -dev output. 18 19# Avoid infinite recursion 20if [[ ! -v PG_CONFIG_CALLED ]]; then 21 # compares "path of *this* script" with "path, which pg_config on PATH believes it is in" 22 if [[ "$(readlink -f -- "$0")" == "$(PG_CONFIG_CALLED=1 pg_config --bindir)/pg_config" ]]; then 23 # The pg_config in PATH returns the same bindir that we're actually called from. 24 # This means that the pg_config in PATH is the one from "our" -dev output. 25 # This happens when the -dev output has been put in native build 26 # inputs and allows us to call the real pg_config without referencing 27 # the -dev output itself. 28 exec pg_config "$@" 29 fi 30fi 31 32# This will happen in one of these cases: 33# - *this* script is the first on PATH 34# - np pg_config on PATH 35# - some other pg_config on PATH, not from our -dev output 36echo The real pg_config can be found in the -dev output. 37exit 1