Skip to content

Commit 90d602a

Browse files
authored
fix: run nix-gc before pg_upgrade (#1189)
1 parent ac116f7 commit 90d602a

File tree

1 file changed

+12
-5
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+12
-5
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,23 @@ function initiate_upgrade {
277277
NIX_FLAKE_VERSION=$(cat "$PG_UPGRADE_BIN_DIR/nix_flake_version")
278278

279279
if [ "$IS_NIX_BASED_SYSTEM" = "false" ]; then
280-
echo "1.1. Nix is not installed; installing."
281-
282-
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
283-
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
284-
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
280+
if [ ! -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
281+
if ! command -v nix > /dev/null; then
282+
echo "1.1. Nix is not installed; installing."
283+
284+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
285+
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
286+
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
287+
else
288+
echo "1.1. Nix is installed; moving on."
289+
fi
290+
fi
285291
fi
286292

287293
echo "1.2. Installing flake revision: $NIX_FLAKE_VERSION"
288294
# shellcheck disable=SC1091
289295
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
296+
nix-collect-garbage -d > /tmp/pg_upgrade-nix-gc.log 2>&1 || true
290297
PG_UPGRADE_BIN_DIR=$(nix build "github:supabase/postgres/${NIX_FLAKE_VERSION}#psql_15/bin" --no-link --print-out-paths --extra-experimental-features nix-command --extra-experimental-features flakes)
291298
PGSHARENEW="$PG_UPGRADE_BIN_DIR/share/postgresql"
292299
fi

0 commit comments

Comments
 (0)