Skip to content

Commit e0b791e

Browse files
committed
fix: handle flake check user in darwin env
1 parent 7d5f16b commit e0b791e

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

nix/checks.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,29 @@
171171
#First we need to create a generic pg cluster for pgtap tests and run those
172172
export GRN_PLUGINS_DIR=${pkgs.supabase-groonga}/lib/groonga/plugins
173173
PGTAP_CLUSTER=$(mktemp -d)
174+
# Set USER environment variable to handle root user restriction on macOS
175+
# This is a common pattern in Nix builds to handle user-related issues
176+
export USER="$(whoami)"
177+
if [[ "$(uname)" == "Darwin" ]]; then
178+
# On macOS, ensure we're not running as root for initdb
179+
if [[ "$USER" == "root" ]]; then
180+
export USER="nobody"
181+
fi
182+
fi
174183
175-
# Use --allow-group-access to allow initdb to run as root (needed on macOS)
176-
initdb --locale=C --username=supabase_admin --allow-group-access -D "$PGTAP_CLUSTER"
184+
# Initialize database with proper flags based on version
185+
if [ "${majorVersion}" = "orioledb-17" ]; then
186+
initdb -D "$PGTAP_CLUSTER" \
187+
--allow-group-access \
188+
--username=supabase_admin \
189+
--locale-provider=icu \
190+
--encoding=UTF-8 \
191+
--icu-locale=en_US.UTF-8
192+
else
193+
initdb -D "$PGTAP_CLUSTER" \
194+
--allow-group-access \
195+
--username=supabase_admin
196+
fi
177197
substitute ${./tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \
178198
--subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey"
179199
echo "listen_addresses = '*'" >> "$PGTAP_CLUSTER"/postgresql.conf

0 commit comments

Comments
 (0)