From 77d6fb58fc9164ac2295b384e8df9f945d6959be Mon Sep 17 00:00:00 2001 From: Paul Cioanca Date: Mon, 9 Sep 2024 18:43:37 +0300 Subject: [PATCH] fix: run nix-gc before pg_upgrade --- .../pg_upgrade_scripts/initiate.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh index f9c35ed16..21fec9ed9 100755 --- a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh +++ b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh @@ -277,16 +277,23 @@ function initiate_upgrade { NIX_FLAKE_VERSION=$(cat "$PG_UPGRADE_BIN_DIR/nix_flake_version") if [ "$IS_NIX_BASED_SYSTEM" = "false" ]; then - echo "1.1. Nix is not installed; installing." - - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \ - --extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \ - --extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + if [ ! -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then + if ! command -v nix > /dev/null; then + echo "1.1. Nix is not installed; installing." + + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \ + --extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \ + --extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + else + echo "1.1. Nix is installed; moving on." + fi + fi fi echo "1.2. Installing flake revision: $NIX_FLAKE_VERSION" # shellcheck disable=SC1091 source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + nix-collect-garbage -d > /tmp/pg_upgrade-nix-gc.log 2>&1 || true 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) PGSHARENEW="$PG_UPGRADE_BIN_DIR/share/postgresql" fi