Skip to content

Commit 9b2c570

Browse files
samrosesoedirgo
authored andcommitted
fix: nix flake check
1 parent c77821d commit 9b2c570

File tree

5 files changed

+75
-39
lines changed

5 files changed

+75
-39
lines changed

ansible/files/postgresql_config/postgresql.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ default_text_search_config = 'pg_catalog.english'
688688
#local_preload_libraries = ''
689689
#session_preload_libraries = ''
690690

691-
shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter' # (change requires restart)
691+
shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, supabase_vault' # (change requires restart)
692692
jit_provider = 'llvmjit' # JIT library to use
693693

694694
# - Other Defaults -

flake.nix

+45-34
Original file line numberDiff line numberDiff line change
@@ -571,42 +571,49 @@
571571
sqlTests = ./nix/tests/smoke;
572572
pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
573573
pg_regress = basePackages.pg_regress;
574-
getkey-script = pkgs.writeScriptBin "pgsodium-getkey" ''
575-
#!${pkgs.bash}/bin/bash
576-
set -euo pipefail
577-
578-
TMPDIR_BASE=$(mktemp -d)
579-
580-
if [[ "$(uname)" == "Darwin" ]]; then
581-
KEY_DIR="/private/tmp/pgsodium"
582-
else
583-
KEY_DIR="''${PGSODIUM_KEY_DIR:-$TMPDIR_BASE/pgsodium}"
584-
fi
585-
KEY_FILE="$KEY_DIR/pgsodium.key"
586-
587-
if ! mkdir -p "$KEY_DIR" 2>/dev/null; then
588-
echo "Error: Could not create key directory $KEY_DIR" >&2
589-
exit 1
590-
fi
591-
chmod 1777 "$KEY_DIR"
592-
593-
if [[ ! -f "$KEY_FILE" ]]; then
594-
if ! (dd if=/dev/urandom bs=32 count=1 2>/dev/null | od -A n -t x1 | tr -d ' \n' > "$KEY_FILE"); then
595-
if ! (openssl rand -hex 32 > "$KEY_FILE"); then
596-
echo "00000000000000000000000000000000" > "$KEY_FILE"
597-
echo "Warning: Using fallback key" >&2
574+
getkey-script = pkgs.stdenv.mkDerivation {
575+
name = "pgsodium-getkey";
576+
buildCommand = ''
577+
mkdir -p $out/bin
578+
cat > $out/bin/pgsodium-getkey << 'EOF'
579+
#!${pkgs.bash}/bin/bash
580+
set -euo pipefail
581+
582+
TMPDIR_BASE=$(mktemp -d)
583+
584+
if [[ "$(uname)" == "Darwin" ]]; then
585+
KEY_DIR="/private/tmp/pgsodium"
586+
else
587+
KEY_DIR="''${PGSODIUM_KEY_DIR:-$TMPDIR_BASE/pgsodium}"
588+
fi
589+
KEY_FILE="$KEY_DIR/pgsodium.key"
590+
591+
if ! mkdir -p "$KEY_DIR" 2>/dev/null; then
592+
echo "Error: Could not create key directory $KEY_DIR" >&2
593+
exit 1
594+
fi
595+
chmod 1777 "$KEY_DIR"
596+
597+
if [[ ! -f "$KEY_FILE" ]]; then
598+
if ! (dd if=/dev/urandom bs=32 count=1 2>/dev/null | od -A n -t x1 | tr -d ' \n' > "$KEY_FILE"); then
599+
if ! (openssl rand -hex 32 > "$KEY_FILE"); then
600+
echo "00000000000000000000000000000000" > "$KEY_FILE"
601+
echo "Warning: Using fallback key" >&2
602+
fi
598603
fi
604+
chmod 644 "$KEY_FILE"
599605
fi
600-
chmod 644 "$KEY_FILE"
601-
fi
602-
603-
if [[ -f "$KEY_FILE" && -r "$KEY_FILE" ]]; then
604-
cat "$KEY_FILE"
605-
else
606-
echo "Error: Cannot read key file $KEY_FILE" >&2
607-
exit 1
608-
fi
609-
'';
606+
607+
if [[ -f "$KEY_FILE" && -r "$KEY_FILE" ]]; then
608+
cat "$KEY_FILE"
609+
else
610+
echo "Error: Cannot read key file $KEY_FILE" >&2
611+
exit 1
612+
fi
613+
EOF
614+
chmod +x $out/bin/pgsodium-getkey
615+
'';
616+
};
610617

611618
# Use the shared setup but with a test-specific name
612619
start-postgres-server-bin = makePostgresDevSetup {
@@ -670,9 +677,13 @@
670677
export GRN_PLUGINS_DIR=${supabase-groonga}/lib/groonga/plugins
671678
PGTAP_CLUSTER=$(mktemp -d)
672679
initdb --locale=C --username=supabase_admin -D "$PGTAP_CLUSTER"
680+
substitute ${./nix/tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \
681+
--subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey"
673682
echo "listen_addresses = '*'" >> "$PGTAP_CLUSTER"/postgresql.conf
674683
echo "port = 5435" >> "$PGTAP_CLUSTER"/postgresql.conf
675684
echo "host all all 127.0.0.1/32 trust" >> $PGTAP_CLUSTER/pg_hba.conf
685+
echo "Checking shared_preload_libraries setting:"
686+
grep -rn "shared_preload_libraries" "$PGTAP_CLUSTER"/postgresql.conf
676687
# Remove timescaledb if running orioledb-17 check
677688
echo "I AM ${pgpkg.version}===================================================="
678689
if [[ "${pgpkg.version}" == *"17"* ]]; then

0 commit comments

Comments
 (0)