Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: && with above into one condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would unfortunately never run :[

The nix binary is generally located in /root/.nix-profile/bin - with the path provided by sourcing /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

In truth, if /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh doesn't exist, neither will /root/.nix-profile/bin/nix, which makes ! command -v nix > /dev/null kind of superfluous.

Will remove the secondary check once we figure out the avenue of hosting the installer ourselves, as I'm not sure how stable the /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh path is at the moment

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
Expand Down
Loading