Skip to content

Commit ce88f93

Browse files
committed
Fix darwin build by using unix sockets only
Stop using TCP sockets in builds to avoid port conflicts
1 parent 142c32c commit ce88f93

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

nix/cargo-pgrx/buildPgrxExtension.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ let
9494
export PGRX_HOME=$(mktemp -d)
9595
export PGDATA="$PGRX_HOME/data-${pgrxPostgresMajor}/"
9696
cargo-pgrx pgrx init "--pg${pgrxPostgresMajor}" ${lib.getDev postgresql}/bin/pg_config
97-
echo "unix_socket_directories = '$(mktemp -d)'" > "$PGDATA/postgresql.conf"
97+
98+
# unix sockets work in sandbox, too.
99+
export PGHOST="$(mktemp -d)"
100+
cat > "$PGDATA/postgresql.conf" <<EOF
101+
listen_addresses = '''
102+
unix_socket_directories = '$PGHOST'
103+
EOF
98104
99105
# This is primarily for Mac or other Nix systems that don't use the nixbld user.
100106
export USER="$(whoami)"

nix/ext/wrappers/default.nix

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,6 @@ let
5454
env = lib.optionalAttrs stdenv.isDarwin {
5555
POSTGRES_LIB = "${postgresql}/lib";
5656
RUSTFLAGS = "-C link-arg=-undefined -C link-arg=dynamic_lookup";
57-
# Calculate unique port for each PostgreSQL version:
58-
# - Check if version contains underscore (indicating OrioleDB)
59-
# - Add 1 to port if it's OrioleDB
60-
# - Add 2 for each major version above 15
61-
# Examples:
62-
# - PostgreSQL 15.8 → 5435 + 0 + (15-15)*2 = 5435
63-
# - PostgreSQL 17_0 (OrioleDB) → 5435 + 1 + (17-15)*2 = 5440
64-
# - PostgreSQL 17.4 → 5435 + 0 + (17-15)*2 = 5439
65-
PGPORT = toString (
66-
5534
67-
+ (if builtins.match ".*_.*" postgresql.version != null then 1 else 0)
68-
# +1 for OrioleDB
69-
+ ((builtins.fromJSON (builtins.substring 0 2 postgresql.version)) - 15) * 2
70-
); # +2 for each major version
7157
};
7258

7359
OPENSSL_NO_VENDOR = 1;
@@ -176,6 +162,7 @@ buildEnv {
176162
"/share/postgresql/extension"
177163
];
178164
postBuild = ''
165+
179166
# checks
180167
(set -x
181168
test "$(ls -A $out/lib/${pname}*${postgresql.dlSuffix} | wc -l)" = "${

0 commit comments

Comments
 (0)